Skip to content

Commit b557ccd

Browse files
stefanbergergregkh
authored andcommitted
crypto: ecc - Fix off-by-one missing to clear most significant digit
[ Upstream commit 1dcf865 ] Fix an off-by-one error where the most significant digit was not initialized leading to signature verification failures by the testmgr. Example: If a curve requires ndigits (=9) and diff (=2) indicates that 2 digits need to be set to zero then start with digit 'ndigits - diff' (=7) and clear 'diff' digits starting from there, so 7 and 8. Reported-by: Venkat Rao Bagalkote <venkat88@linux.vnet.ibm.com> Closes: https://lore.kernel.org/linux-crypto/619bc2de-b18a-4939-a652-9ca886bf6349@linux.ibm.com/T/#m045d8812409ce233c17fcdb8b88b6629c671f9f4 Fixes: 2fd2a82 ("crypto: ecdsa - Use ecc_digits_from_bytes to create hash digits array") Signed-off-by: Stefan Berger <stefanb@linux.ibm.com> Tested-by: Venkat Rao Bagalkote <venkat88@linux.vnet.ibm.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 5483458 commit b557ccd

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

crypto/ecc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ void ecc_digits_from_bytes(const u8 *in, unsigned int nbytes,
7878
/* diff > 0: not enough input bytes: set most significant digits to 0 */
7979
if (diff > 0) {
8080
ndigits -= diff;
81-
memset(&out[ndigits - 1], 0, diff * sizeof(u64));
81+
memset(&out[ndigits], 0, diff * sizeof(u64));
8282
}
8383

8484
if (o) {

0 commit comments

Comments
 (0)