crypto: aead - Add skcipher null for IV generators
authorHerbert Xu <herbert@gondor.apana.org.au>
Tue, 12 Jul 2016 05:17:42 +0000 (13:17 +0800)
committerHerbert Xu <herbert@gondor.apana.org.au>
Mon, 18 Jul 2016 09:35:42 +0000 (17:35 +0800)
This patch adds an skcipher null object alongside the existing
null blkcipher so that IV generators using it can switch over
to skcipher.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
crypto/aead.c
include/crypto/internal/geniv.h

index b155cbc3a0dd91e344f0cce0b0ca2ee7ee487704..a5d9a83f90e4de99ea990fd381c33eb7c05207b1 100644 (file)
@@ -294,10 +294,15 @@ int aead_init_geniv(struct crypto_aead *aead)
        if (err)
                goto out;
 
+       ctx->sknull = crypto_get_default_null_skcipher2();
+       err = PTR_ERR(ctx->sknull);
+       if (IS_ERR(ctx->sknull))
+               goto out;
+
        ctx->null = crypto_get_default_null_skcipher();
        err = PTR_ERR(ctx->null);
        if (IS_ERR(ctx->null))
-               goto out;
+               goto drop_sknull;
 
        child = crypto_spawn_aead(aead_instance_ctx(inst));
        err = PTR_ERR(child);
@@ -315,6 +320,8 @@ out:
 
 drop_null:
        crypto_put_default_null_skcipher();
+drop_sknull:
+       crypto_put_default_null_skcipher2();
        goto out;
 }
 EXPORT_SYMBOL_GPL(aead_init_geniv);
@@ -325,6 +332,7 @@ void aead_exit_geniv(struct crypto_aead *tfm)
 
        crypto_free_aead(ctx->child);
        crypto_put_default_null_skcipher();
+       crypto_put_default_null_skcipher2();
 }
 EXPORT_SYMBOL_GPL(aead_exit_geniv);
 
index 59333635e712d15a109919f03c70107183df473e..e8447c9c14e6e64233d0d426c8f499040ac1bf6d 100644 (file)
@@ -21,6 +21,7 @@ struct aead_geniv_ctx {
        spinlock_t lock;
        struct crypto_aead *child;
        struct crypto_blkcipher *null;
+       struct crypto_skcipher *sknull;
        u8 salt[] __attribute__ ((aligned(__alignof__(u32))));
 };