Skip to content

Commit

Permalink
crypto: aead - Add skcipher null for IV generators
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
herbertx committed Jul 18, 2016
1 parent 1e1f006 commit ca0494c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
10 changes: 9 additions & 1 deletion crypto/aead.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -315,6 +320,8 @@ int aead_init_geniv(struct crypto_aead *aead)

drop_null:
crypto_put_default_null_skcipher();
drop_sknull:
crypto_put_default_null_skcipher2();
goto out;
}
EXPORT_SYMBOL_GPL(aead_init_geniv);
Expand All @@ -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);

Expand Down
1 change: 1 addition & 0 deletions include/crypto/internal/geniv.h
Original file line number Diff line number Diff line change
Expand Up @@ -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))));
};

Expand Down

0 comments on commit ca0494c

Please sign in to comment.