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/digest.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/digest.c')
-rw-r--r-- | crypto/digest.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/crypto/digest.c b/crypto/digest.c index 603006a7bef2..0df7f392a56a 100644 --- a/crypto/digest.c +++ b/crypto/digest.c | |||
@@ -76,12 +76,16 @@ static void final(struct crypto_tfm *tfm, u8 *out) | |||
76 | tfm->__crt_alg->cra_digest.dia_final(tfm, out); | 76 | tfm->__crt_alg->cra_digest.dia_final(tfm, out); |
77 | } | 77 | } |
78 | 78 | ||
79 | static int nosetkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen) | ||
80 | { | ||
81 | tfm->crt_flags &= ~CRYPTO_TFM_RES_MASK; | ||
82 | return -ENOSYS; | ||
83 | } | ||
84 | |||
79 | static int setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen) | 85 | static int setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen) |
80 | { | 86 | { |
81 | u32 flags; | 87 | tfm->crt_flags &= ~CRYPTO_TFM_RES_MASK; |
82 | if (tfm->__crt_alg->cra_digest.dia_setkey == NULL) | 88 | return tfm->__crt_alg->cra_digest.dia_setkey(tfm, key, keylen); |
83 | return -ENOSYS; | ||
84 | return tfm->__crt_alg->cra_digest.dia_setkey(tfm, key, keylen, &flags); | ||
85 | } | 89 | } |
86 | 90 | ||
87 | static void digest(struct crypto_tfm *tfm, | 91 | static void digest(struct crypto_tfm *tfm, |
@@ -100,12 +104,13 @@ int crypto_init_digest_flags(struct crypto_tfm *tfm, u32 flags) | |||
100 | int crypto_init_digest_ops(struct crypto_tfm *tfm) | 104 | int crypto_init_digest_ops(struct crypto_tfm *tfm) |
101 | { | 105 | { |
102 | struct digest_tfm *ops = &tfm->crt_digest; | 106 | struct digest_tfm *ops = &tfm->crt_digest; |
107 | struct digest_alg *dalg = &tfm->__crt_alg->cra_digest; | ||
103 | 108 | ||
104 | ops->dit_init = init; | 109 | ops->dit_init = init; |
105 | ops->dit_update = update; | 110 | ops->dit_update = update; |
106 | ops->dit_final = final; | 111 | ops->dit_final = final; |
107 | ops->dit_digest = digest; | 112 | ops->dit_digest = digest; |
108 | ops->dit_setkey = setkey; | 113 | ops->dit_setkey = dalg->dia_setkey ? setkey : nosetkey; |
109 | 114 | ||
110 | return crypto_alloc_hmac_block(tfm); | 115 | return crypto_alloc_hmac_block(tfm); |
111 | } | 116 | } |