Skip to content

Commit fd16931

Browse files
ardbiesheuvelherbertx
authored andcommitted
crypto: arm/chacha-neon - add missing counter increment
Commit 86cd97e ("crypto: arm/chacha-neon - optimize for non-block size multiples") refactored the chacha block handling in the glue code in a way that may result in the counter increment to be omitted when calling chacha_block_xor_neon() to process a full block. This violates the skcipher API, which requires that the output IV is suitable for handling more input as long as the preceding input has been presented in round multiples of the block size. Also, the same code is exposed via the chacha library interface whose callers may actually rely on this increment to occur even for final blocks that are smaller than the chacha block size. So increment the counter after calling chacha_block_xor_neon(). Fixes: 86cd97e ("crypto: arm/chacha-neon - optimize for non-block size multiples") Reported-by: Eric Biggers <[email protected]> Signed-off-by: Ard Biesheuvel <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent 5c8fe58 commit fd16931

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

arch/arm/crypto/chacha-glue.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ static void chacha_doneon(u32 *state, u8 *dst, const u8 *src,
6060
chacha_block_xor_neon(state, d, s, nrounds);
6161
if (d != dst)
6262
memcpy(dst, buf, bytes);
63+
state[12]++;
6364
}
6465
}
6566

0 commit comments

Comments
 (0)