Re: [PATCH] crypto: algif - change algif_skcipher to be asynchronous

2015-01-23 Thread Tadeusz Struk
On 01/15/2015 06:00 PM, Herbert Xu wrote:
>> But then would you like to extend AIO interface to take the IV and
>> > something that would indicate the encrypt/decrypt operation on
>> > aio_write()? Also as far as I can see AIO doesn't support splice()
> Any metadata such as the IV can still go through the existing
> sendmsg interface, just as you would do a sendmsg before a sendfile
> to set things up.
> 
>> > operation for zero copy, which is the main thing here.
> The AIO interface itself can accomodate zero-copy.  It's just that
> we currently don't have any support for it in the network socket
> API.
> 
Hi,
Ok, It looks to me that we *do* have all we need to implement zero copy
and AIO with algif_skcipher. The only thing we need to do is to add
support for it in skcipher_recvmsg(). I think no change is required in
neither skcipher_sendmsg(), skcipher_sendpage(), nor the if_alg interface.
Then to start using the interface asynchronously an application will
need to call aio_read() or lio_listio() instead of read(), but if
someone will use read(), then it will still work in the same
(synchronous) way as it is today.
How does this sound to you, Herbert?
I'll send a v2 shortly.
Thanks,
Tadeusz

--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] crypto: aesni - make driver-gcm-aes-aesni helper a proper aead alg

2015-01-23 Thread Tadeusz Struk
Changed the __driver-gcm-aes-aesni to be a proper aead algorithm.

Signed-off-by: Tadeusz Struk 
---
 arch/x86/crypto/aesni-intel_glue.c |   53 ++--
 1 file changed, 39 insertions(+), 14 deletions(-)

diff --git a/arch/x86/crypto/aesni-intel_glue.c 
b/arch/x86/crypto/aesni-intel_glue.c
index 947c6bf..5544ad9 100644
--- a/arch/x86/crypto/aesni-intel_glue.c
+++ b/arch/x86/crypto/aesni-intel_glue.c
@@ -890,15 +890,12 @@ out_free_ablkcipher:
return ret;
 }
 
-static int rfc4106_set_key(struct crypto_aead *parent, const u8 *key,
-  unsigned int key_len)
+static int common_rfc4106_set_key(struct crypto_aead *aead, const u8 *key,
+ unsigned int key_len)
 {
int ret = 0;
-   struct crypto_tfm *tfm = crypto_aead_tfm(parent);
-   struct aesni_rfc4106_gcm_ctx *ctx = aesni_rfc4106_gcm_ctx_get(parent);
-   struct crypto_aead *cryptd_child = cryptd_aead_child(ctx->cryptd_tfm);
-   struct aesni_rfc4106_gcm_ctx *child_ctx =
- aesni_rfc4106_gcm_ctx_get(cryptd_child);
+   struct crypto_tfm *tfm = crypto_aead_tfm(aead);
+   struct aesni_rfc4106_gcm_ctx *ctx = aesni_rfc4106_gcm_ctx_get(aead);
u8 *new_key_align, *new_key_mem = NULL;
 
if (key_len < 4) {
@@ -943,20 +940,29 @@ static int rfc4106_set_key(struct crypto_aead *parent, 
const u8 *key,
goto exit;
}
ret = rfc4106_set_hash_subkey(ctx->hash_subkey, key, key_len);
-   memcpy(child_ctx, ctx, sizeof(*ctx));
 exit:
kfree(new_key_mem);
return ret;
 }
 
-/* This is the Integrity Check Value (aka the authentication tag length and can
- * be 8, 12 or 16 bytes long. */
-static int rfc4106_set_authsize(struct crypto_aead *parent,
-   unsigned int authsize)
+static int rfc4106_set_key(struct crypto_aead *parent, const u8 *key,
+  unsigned int key_len)
 {
struct aesni_rfc4106_gcm_ctx *ctx = aesni_rfc4106_gcm_ctx_get(parent);
struct crypto_aead *cryptd_child = cryptd_aead_child(ctx->cryptd_tfm);
+   struct aesni_rfc4106_gcm_ctx *child_ctx =
+   aesni_rfc4106_gcm_ctx_get(cryptd_child);
+   int ret;
 
+   ret = common_rfc4106_set_key(parent, key, key_len);
+   if (!ret)
+   memcpy(child_ctx, ctx, sizeof(*ctx));
+   return ret;
+}
+
+static int common_rfc4106_set_authsize(struct crypto_aead *aead,
+  unsigned int authsize)
+{
switch (authsize) {
case 8:
case 12:
@@ -965,11 +971,26 @@ static int rfc4106_set_authsize(struct crypto_aead 
*parent,
default:
return -EINVAL;
}
-   crypto_aead_crt(parent)->authsize = authsize;
-   crypto_aead_crt(cryptd_child)->authsize = authsize;
+   crypto_aead_crt(aead)->authsize = authsize;
return 0;
 }
 
+/* This is the Integrity Check Value (aka the authentication tag length and can
+ * be 8, 12 or 16 bytes long. */
+static int rfc4106_set_authsize(struct crypto_aead *parent,
+   unsigned int authsize)
+{
+   struct aesni_rfc4106_gcm_ctx *ctx = aesni_rfc4106_gcm_ctx_get(parent);
+   struct crypto_aead *cryptd_child = cryptd_aead_child(ctx->cryptd_tfm);
+   int ret;
+
+   ret = common_rfc4106_set_authsize(parent, authsize);
+   if (!ret)
+   ret = common_rfc4106_set_authsize(cryptd_child, authsize);
+
+   return ret;
+}
+
 static int rfc4106_encrypt(struct aead_request *req)
 {
int ret;
@@ -1366,8 +1387,12 @@ static struct crypto_alg aesni_algs[] = { {
.cra_module = THIS_MODULE,
.cra_u = {
.aead = {
+   .setkey = common_rfc4106_set_key,
+   .setauthsize= common_rfc4106_set_authsize,
.encrypt= __driver_rfc4106_encrypt,
.decrypt= __driver_rfc4106_decrypt,
+   .ivsize = 8,
+   .maxauthsize= 16,
},
},
 }, {

--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] crypto/testmgr: mark rfc4106(gcm(aes)) as fips_allowed

2015-01-23 Thread Stephan Mueller
Am Freitag, 23. Januar 2015, 12:42:15 schrieb Jarod Wilson:

Hi Jarod,

>This gcm variant is popular for ipsec use, and there are folks who
>would like to use it while in fips mode. Mark it with fips_allowed=1
>to facilitate that.

Acked-by: Stephan Mueller 

For the records: this change is ok as the RFC4106 "wrapper" only 
massages the input data like IV or keys without changing the 
cryptographic logic of GCM. As the basic cipher is not changed allowing 
RFC4106 is harmless with respect to FIPS 140-2 to use and apply this 
RFC4106 wrapper. This implies that the RFC4106 wrapper can be used in 
FIPS mode.
>
>CC: LKML 
>CC: Stephan Mueller 
>Signed-off-by: Jarod Wilson 
>---
> crypto/testmgr.c | 1 +
> 1 file changed, 1 insertion(+)
>
>diff --git a/crypto/testmgr.c b/crypto/testmgr.c
>index 235b1ff..758d028 100644
>--- a/crypto/testmgr.c
>+++ b/crypto/testmgr.c
>@@ -3293,6 +3293,7 @@ static const struct alg_test_desc
>alg_test_descs[] = { }, {
>   .alg = "rfc4106(gcm(aes))",
>   .test = alg_test_aead,
>+  .fips_allowed = 1,
>   .suite = {
>   .aead = {
>   .enc = {


Ciao
Stephan


--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] crypto/testmgr: mark rfc4106(gcm(aes)) as fips_allowed

2015-01-23 Thread Jarod Wilson
This gcm variant is popular for ipsec use, and there are folks who would
like to use it while in fips mode. Mark it with fips_allowed=1 to
facilitate that.

CC: LKML 
CC: Stephan Mueller 
Signed-off-by: Jarod Wilson 
---
 crypto/testmgr.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/crypto/testmgr.c b/crypto/testmgr.c
index 235b1ff..758d028 100644
--- a/crypto/testmgr.c
+++ b/crypto/testmgr.c
@@ -3293,6 +3293,7 @@ static const struct alg_test_desc alg_test_descs[] = {
}, {
.alg = "rfc4106(gcm(aes))",
.test = alg_test_aead,
+   .fips_allowed = 1,
.suite = {
.aead = {
.enc = {
-- 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] crypto: ccp: terminate ccp_support array with empty element

2015-01-23 Thread Tom Lendacky

On 01/21/2015 09:06 AM, Andrey Ryabinin wrote:

x86_match_cpu() expects array of x86_cpu_ids terminated
with empty element.

Signed-off-by: Andrey Ryabinin 


Acked-by: Tom Lendacky 


---
  drivers/crypto/ccp/ccp-dev.c | 1 +
  1 file changed, 1 insertion(+)

diff --git a/drivers/crypto/ccp/ccp-dev.c b/drivers/crypto/ccp/ccp-dev.c
index c6e6171..ca29c12 100644
--- a/drivers/crypto/ccp/ccp-dev.c
+++ b/drivers/crypto/ccp/ccp-dev.c
@@ -583,6 +583,7 @@ bool ccp_queues_suspended(struct ccp_device *ccp)
  #ifdef CONFIG_X86
  static const struct x86_cpu_id ccp_support[] = {
{ X86_VENDOR_AMD, 22, },
+   { },
  };
  #endif



--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html