diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2006-08-13 00:16:39 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2006-09-20 21:41:02 -0400 |
commit | 560c06ae1ab7c677002ea3b6ac83521bf12ee07d (patch) | |
tree | 374ed69a7e23ba9d07458d20672aac6ae552ae51 /crypto/des.c | |
parent | 25cdbcd9e5d20e431f829cafce48a418830011f4 (diff) |
[CRYPTO] api: Get rid of flags argument to setkey
Now that the tfm is passed directly to setkey instead of the ctx, we no
longer need to pass the &tfm->crt_flags pointer.
This patch also gets rid of a few unnecessary checks on the key length
for ciphers as the cipher layer guarantees that the key length is within
the bounds specified by the algorithm.
Rather than testing dia_setkey every time, this patch does it only once
during crypto_alloc_tfm. The redundant check from crypto_digest_setkey
is also removed.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto/des.c')
-rw-r--r-- | crypto/des.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/crypto/des.c b/crypto/des.c index a9d3c235a6af..1df3a714fa47 100644 --- a/crypto/des.c +++ b/crypto/des.c | |||
@@ -784,9 +784,10 @@ static void dkey(u32 *pe, const u8 *k) | |||
784 | } | 784 | } |
785 | 785 | ||
786 | static int des_setkey(struct crypto_tfm *tfm, const u8 *key, | 786 | static int des_setkey(struct crypto_tfm *tfm, const u8 *key, |
787 | unsigned int keylen, u32 *flags) | 787 | unsigned int keylen) |
788 | { | 788 | { |
789 | struct des_ctx *dctx = crypto_tfm_ctx(tfm); | 789 | struct des_ctx *dctx = crypto_tfm_ctx(tfm); |
790 | u32 *flags = &tfm->crt_flags; | ||
790 | u32 tmp[DES_EXPKEY_WORDS]; | 791 | u32 tmp[DES_EXPKEY_WORDS]; |
791 | int ret; | 792 | int ret; |
792 | 793 | ||
@@ -864,11 +865,12 @@ static void des_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src) | |||
864 | * | 865 | * |
865 | */ | 866 | */ |
866 | static int des3_ede_setkey(struct crypto_tfm *tfm, const u8 *key, | 867 | static int des3_ede_setkey(struct crypto_tfm *tfm, const u8 *key, |
867 | unsigned int keylen, u32 *flags) | 868 | unsigned int keylen) |
868 | { | 869 | { |
869 | const u32 *K = (const u32 *)key; | 870 | const u32 *K = (const u32 *)key; |
870 | struct des3_ede_ctx *dctx = crypto_tfm_ctx(tfm); | 871 | struct des3_ede_ctx *dctx = crypto_tfm_ctx(tfm); |
871 | u32 *expkey = dctx->expkey; | 872 | u32 *expkey = dctx->expkey; |
873 | u32 *flags = &tfm->crt_flags; | ||
872 | 874 | ||
873 | if (unlikely(!((K[0] ^ K[2]) | (K[1] ^ K[3])) || | 875 | if (unlikely(!((K[0] ^ K[2]) | (K[1] ^ K[3])) || |
874 | !((K[2] ^ K[4]) | (K[3] ^ K[5])))) | 876 | !((K[2] ^ K[4]) | (K[3] ^ K[5])))) |