Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1430234 > unrolled thread
| Started by | Tadeusz Struk <tadeusz.struk@intel.com> |
|---|---|
| First post | 2016-06-24 01:00 +0200 |
| Last post | 2016-06-24 08:10 +0200 |
| Articles | 3 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH v8 0/6] crypto: algif - add akcipher Tadeusz Struk <tadeusz.struk@intel.com> - 2016-06-24 01:00 +0200
[PATCH v8 2/6] crypto: AF_ALG -- add setpubkey setsockopt call Tadeusz Struk <tadeusz.struk@intel.com> - 2016-06-24 01:00 +0200
Re: [PATCH v8 0/6] crypto: algif - add akcipher Stephan Mueller <smueller@chronox.de> - 2016-06-24 08:10 +0200
| From | Tadeusz Struk <tadeusz.struk@intel.com> |
|---|---|
| Date | 2016-06-24 01:00 +0200 |
| Subject | [PATCH v8 0/6] crypto: algif - add akcipher |
| Message-ID | <rNlLj-8gl-3@gated-at.bofh.it> |
First four patches are a resend algif_akcipher from
Stephan Mueller, with minor changes after rebase on top of 4.7-rc1.
The next three patches add support for keys stored in system
keyring subsystem.
First patch adds algif_akcipher nokey hadlers.
Second patch adds generic sign, verify, encrypt, decrypt accessors
functions to the asymmetric key type. These will be defined by
asymmetric subtypes, similarly to how public_key currently defines
the verify_signature function.
Third patch adds support for ALG_SET_KEY_ID and ALG_SET_PUBKEY_ID
commands to AF_ALG and setkeyid operation to the af_alg_type struct.
If the keyid is used then the afalg layer acquires the key for the
keyring subsystem and uses the new asymmetric accessor functions
instead of akcipher api. The asymmetric subtypes can use akcipher
api internally.
Patches are generate against:
http://git.kernel.org/cgit/linux/kernel/git/dhowells/linux-fs.git/log/?h=keys-next
v8 hanges:
- copy the result to user for verify after the signature_verify
operation. Before only the return code was checked, but not the
actual data. Reported by Mat Martineau
- remove the constrain on the output buffer size as requested by
Mat Martineau
- ifx uninitialize variable issue, reported by Mat Martineau
v7 changes:
- update to reflect changes in kernel_pkey_params struct
v6 changes:
- rabased on top of
http://git.kernel.org/cgit/linux/kernel/git/dhowells/linux-fs.git/log/?h=keys-asym-keyctl
v5 changes:
- drop public key changes and use new version provided by David
v4 changes:
- don't use internal public_key struct in af_alg.
- add generic accessor functions to asymmetric key type, which take
the generic struct key type and resolve the specific subtype internally
v3 changes:
- include Stephan's patches (rebased on 4.6-rc1)
- add algif_akcipher nokey hadlers
- add public_key info struct to public_key and helper query functions
- add a check if a key is a software accessible key on af_alg, and
return -ENOKEY if it isn't
v2 changes:
- pass the original skcipher request in ablkcipher.base.data instead of
casting it back from the ablkcipher request.
- rename _req to base_req
- dropped 3/3
---
Stephan Mueller (4):
crypto: AF_ALG -- add sign/verify API
crypto: AF_ALG -- add setpubkey setsockopt call
crypto: AF_ALG -- add asymmetric cipher interface
crypto: algif_akcipher - enable compilation
Tadeusz Struk (2):
crypto: algif_akcipher - add ops_nokey
crypto: AF_ALG - add support for key_id
crypto/Kconfig | 9
crypto/Makefile | 1
crypto/af_alg.c | 28 +
crypto/algif_akcipher.c | 878 +++++++++++++++++++++++++++++++++++++++++++
include/crypto/if_alg.h | 2
include/uapi/linux/if_alg.h | 5
6 files changed, 918 insertions(+), 5 deletions(-)
create mode 100644 crypto/algif_akcipher.c
--
TS
[toc] | [next] | [standalone]
| From | Tadeusz Struk <tadeusz.struk@intel.com> |
|---|---|
| Date | 2016-06-24 01:00 +0200 |
| Subject | [PATCH v8 2/6] crypto: AF_ALG -- add setpubkey setsockopt call |
| Message-ID | <rNlLk-8gl-13@gated-at.bofh.it> |
| In reply to | #1430234 |
From: Stephan Mueller <smueller@chronox.de>
For supporting asymmetric ciphers, user space must be able to set the
public key. The patch adds a new setsockopt call for setting the public
key.
Signed-off-by: Stephan Mueller <smueller@chronox.de>
Signed-off-by: Tadeusz Struk <tadeusz.struk@intel.com>
---
crypto/af_alg.c | 18 +++++++++++++-----
include/crypto/if_alg.h | 1 +
2 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/crypto/af_alg.c b/crypto/af_alg.c
index f5e18c2..24dc082 100644
--- a/crypto/af_alg.c
+++ b/crypto/af_alg.c
@@ -202,13 +202,17 @@ unlock:
}
static int alg_setkey(struct sock *sk, char __user *ukey,
- unsigned int keylen)
+ unsigned int keylen,
+ int (*setkey)(void *private, const u8 *key,
+ unsigned int keylen))
{
struct alg_sock *ask = alg_sk(sk);
- const struct af_alg_type *type = ask->type;
u8 *key;
int err;
+ if (!setkey)
+ return -ENOPROTOOPT;
+
key = sock_kmalloc(sk, keylen, GFP_KERNEL);
if (!key)
return -ENOMEM;
@@ -217,7 +221,7 @@ static int alg_setkey(struct sock *sk, char __user *ukey,
if (copy_from_user(key, ukey, keylen))
goto out;
- err = type->setkey(ask->private, key, keylen);
+ err = setkey(ask->private, key, keylen);
out:
sock_kzfree_s(sk, key, keylen);
@@ -247,10 +251,14 @@ static int alg_setsockopt(struct socket *sock, int level, int optname,
case ALG_SET_KEY:
if (sock->state == SS_CONNECTED)
goto unlock;
- if (!type->setkey)
+
+ err = alg_setkey(sk, optval, optlen, type->setkey);
+ break;
+ case ALG_SET_PUBKEY:
+ if (sock->state == SS_CONNECTED)
goto unlock;
- err = alg_setkey(sk, optval, optlen);
+ err = alg_setkey(sk, optval, optlen, type->setpubkey);
break;
case ALG_SET_AEAD_AUTHSIZE:
if (sock->state == SS_CONNECTED)
diff --git a/include/crypto/if_alg.h b/include/crypto/if_alg.h
index a2bfd78..6c3e6e7 100644
--- a/include/crypto/if_alg.h
+++ b/include/crypto/if_alg.h
@@ -52,6 +52,7 @@ struct af_alg_type {
void *(*bind)(const char *name, u32 type, u32 mask);
void (*release)(void *private);
int (*setkey)(void *private, const u8 *key, unsigned int keylen);
+ int (*setpubkey)(void *private, const u8 *key, unsigned int keylen);
int (*accept)(void *private, struct sock *sk);
int (*accept_nokey)(void *private, struct sock *sk);
int (*setauthsize)(void *private, unsigned int authsize);
[toc] | [prev] | [next] | [standalone]
| From | Stephan Mueller <smueller@chronox.de> |
|---|---|
| Date | 2016-06-24 08:10 +0200 |
| Message-ID | <rNstr-4rr-3@gated-at.bofh.it> |
| In reply to | #1430234 |
Am Donnerstag, 23. Juni 2016, 15:55:26 schrieb Tadeusz Struk: Hi Tadeusz, > First four patches are a resend algif_akcipher from > Stephan Mueller, with minor changes after rebase on top of 4.7-rc1. The first four patches: Acked-by: Stephan Mueller <smueller@chronox.de> Ciao Stephan
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web