diff options
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 | } |