aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/digest.c
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2006-08-13 00:16:39 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2006-09-20 21:41:02 -0400
commit560c06ae1ab7c677002ea3b6ac83521bf12ee07d (patch)
tree374ed69a7e23ba9d07458d20672aac6ae552ae51 /crypto/digest.c
parent25cdbcd9e5d20e431f829cafce48a418830011f4 (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.c15
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
79static 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
79static int setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen) 85static 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
87static void digest(struct crypto_tfm *tfm, 91static void digest(struct crypto_tfm *tfm,
@@ -100,12 +104,13 @@ int crypto_init_digest_flags(struct crypto_tfm *tfm, u32 flags)
100int crypto_init_digest_ops(struct crypto_tfm *tfm) 104int 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}