diff options
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/hmac.c | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/crypto/hmac.c b/crypto/hmac.c index d52b234835cf..b521bcd2b2c6 100644 --- a/crypto/hmac.c +++ b/crypto/hmac.c | |||
@@ -92,13 +92,17 @@ static int hmac_init(struct hash_desc *pdesc) | |||
92 | struct hmac_ctx *ctx = align_ptr(ipad + bs * 2 + ds, sizeof(void *)); | 92 | struct hmac_ctx *ctx = align_ptr(ipad + bs * 2 + ds, sizeof(void *)); |
93 | struct hash_desc desc; | 93 | struct hash_desc desc; |
94 | struct scatterlist tmp; | 94 | struct scatterlist tmp; |
95 | int err; | ||
95 | 96 | ||
96 | desc.tfm = ctx->child; | 97 | desc.tfm = ctx->child; |
97 | desc.flags = pdesc->flags & CRYPTO_TFM_REQ_MAY_SLEEP; | 98 | desc.flags = pdesc->flags & CRYPTO_TFM_REQ_MAY_SLEEP; |
98 | sg_set_buf(&tmp, ipad, bs); | 99 | sg_set_buf(&tmp, ipad, bs); |
99 | 100 | ||
100 | return unlikely(crypto_hash_init(&desc)) ?: | 101 | err = crypto_hash_init(&desc); |
101 | crypto_hash_update(&desc, &tmp, bs); | 102 | if (unlikely(err)) |
103 | return err; | ||
104 | |||
105 | return crypto_hash_update(&desc, &tmp, bs); | ||
102 | } | 106 | } |
103 | 107 | ||
104 | static int hmac_update(struct hash_desc *pdesc, | 108 | static int hmac_update(struct hash_desc *pdesc, |
@@ -123,13 +127,17 @@ static int hmac_final(struct hash_desc *pdesc, u8 *out) | |||
123 | struct hmac_ctx *ctx = align_ptr(digest + ds, sizeof(void *)); | 127 | struct hmac_ctx *ctx = align_ptr(digest + ds, sizeof(void *)); |
124 | struct hash_desc desc; | 128 | struct hash_desc desc; |
125 | struct scatterlist tmp; | 129 | struct scatterlist tmp; |
130 | int err; | ||
126 | 131 | ||
127 | desc.tfm = ctx->child; | 132 | desc.tfm = ctx->child; |
128 | desc.flags = pdesc->flags & CRYPTO_TFM_REQ_MAY_SLEEP; | 133 | desc.flags = pdesc->flags & CRYPTO_TFM_REQ_MAY_SLEEP; |
129 | sg_set_buf(&tmp, opad, bs + ds); | 134 | sg_set_buf(&tmp, opad, bs + ds); |
130 | 135 | ||
131 | return unlikely(crypto_hash_final(&desc, digest)) ?: | 136 | err = crypto_hash_final(&desc, digest); |
132 | crypto_hash_digest(&desc, &tmp, bs + ds, out); | 137 | if (unlikely(err)) |
138 | return err; | ||
139 | |||
140 | return crypto_hash_digest(&desc, &tmp, bs + ds, out); | ||
133 | } | 141 | } |
134 | 142 | ||
135 | static int hmac_digest(struct hash_desc *pdesc, struct scatterlist *sg, | 143 | static int hmac_digest(struct hash_desc *pdesc, struct scatterlist *sg, |
@@ -145,6 +153,7 @@ static int hmac_digest(struct hash_desc *pdesc, struct scatterlist *sg, | |||
145 | struct hash_desc desc; | 153 | struct hash_desc desc; |
146 | struct scatterlist sg1[2]; | 154 | struct scatterlist sg1[2]; |
147 | struct scatterlist sg2[1]; | 155 | struct scatterlist sg2[1]; |
156 | int err; | ||
148 | 157 | ||
149 | desc.tfm = ctx->child; | 158 | desc.tfm = ctx->child; |
150 | desc.flags = pdesc->flags & CRYPTO_TFM_REQ_MAY_SLEEP; | 159 | desc.flags = pdesc->flags & CRYPTO_TFM_REQ_MAY_SLEEP; |
@@ -154,8 +163,11 @@ static int hmac_digest(struct hash_desc *pdesc, struct scatterlist *sg, | |||
154 | sg1[1].length = 0; | 163 | sg1[1].length = 0; |
155 | sg_set_buf(sg2, opad, bs + ds); | 164 | sg_set_buf(sg2, opad, bs + ds); |
156 | 165 | ||
157 | return unlikely(crypto_hash_digest(&desc, sg1, nbytes + bs, digest)) ?: | 166 | err = crypto_hash_digest(&desc, sg1, nbytes + bs, digest); |
158 | crypto_hash_digest(&desc, sg2, bs + ds, out); | 167 | if (unlikely(err)) |
168 | return err; | ||
169 | |||
170 | return crypto_hash_digest(&desc, sg2, bs + ds, out); | ||
159 | } | 171 | } |
160 | 172 | ||
161 | static int hmac_init_tfm(struct crypto_tfm *tfm) | 173 | static int hmac_init_tfm(struct crypto_tfm *tfm) |