Skip to content

Commit 41cdf7a

Browse files
committed
crypto: authencesn - Fix digest_null crash
When authencesn is used together with digest_null a crash will occur on the decrypt path. This is because normally we perform a special setup to preserve the ESN, but this is skipped if there is no authentication. However, on the post-authentication path it always expects the preservation to be in place, thus causing a crash when digest_null is used. This patch fixes this by also skipping the post-processing when there is no authentication. Fixes: 104880a ("crypto: authencesn - Convert to new AEAD...") Cc: <[email protected]> Reported-by: Jan Tluka <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent efc856e commit 41cdf7a

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

crypto/authencesn.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,9 @@ static int crypto_authenc_esn_decrypt_tail(struct aead_request *req,
248248
u8 *ihash = ohash + crypto_ahash_digestsize(auth);
249249
u32 tmp[2];
250250

251+
if (!authsize)
252+
goto decrypt;
253+
251254
/* Move high-order bits of sequence number back. */
252255
scatterwalk_map_and_copy(tmp, dst, 4, 4, 0);
253256
scatterwalk_map_and_copy(tmp + 1, dst, assoclen + cryptlen, 4, 0);
@@ -256,6 +259,8 @@ static int crypto_authenc_esn_decrypt_tail(struct aead_request *req,
256259
if (crypto_memneq(ihash, ohash, authsize))
257260
return -EBADMSG;
258261

262+
decrypt:
263+
259264
sg_init_table(areq_ctx->dst, 2);
260265
dst = scatterwalk_ffwd(areq_ctx->dst, dst, assoclen);
261266

0 commit comments

Comments
 (0)