diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2024-05-20 08:47:54 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2024-05-20 08:47:54 -0700 |
commit | ec8510235d02e9910630e94c40922f6aa2ccde12 (patch) | |
tree | fb60ad49679839af2acafe0322e19f62da0a004e | |
parent | e0cf716c05f08f65df486c00680e904345863e79 (diff) | |
parent | 196eca8607cf9dc44c8b17d0c66619afa0a841cd (diff) | |
download | linux-crypto-ec8510235d02e9910630e94c40922f6aa2ccde12.tar.gz linux-crypto-ec8510235d02e9910630e94c40922f6aa2ccde12.zip |
Merge tag 'v6.10-p2' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6HEADstabledavem/net
Pull crypto fixes from Herbert Xu:
"Fix a bug in the new ecc P521 code as well as a buggy fix in qat"
* tag 'v6.10-p2' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6:
crypto: ecc - Prevent ecc_digits_from_bytes from reading too many bytes
crypto: qat - Fix ADF_DEV_RESET_SYNC memory leak
Diffstat (limited to '')
-rw-r--r-- | crypto/ecc.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/crypto/ecc.c b/crypto/ecc.c index c1d2e884..fe761256 100644 --- a/crypto/ecc.c +++ b/crypto/ecc.c @@ -68,6 +68,28 @@ const struct ecc_curve *ecc_get_curve(unsigned int curve_id) } EXPORT_SYMBOL(ecc_get_curve); +void ecc_digits_from_bytes(const u8 *in, unsigned int nbytes, + u64 *out, unsigned int ndigits) +{ + int diff = ndigits - DIV_ROUND_UP(nbytes, sizeof(u64)); + unsigned int o = nbytes & 7; + __be64 msd = 0; + + /* diff > 0: not enough input bytes: set most significant digits to 0 */ + if (diff > 0) { + ndigits -= diff; + memset(&out[ndigits - 1], 0, diff * sizeof(u64)); + } + + if (o) { + memcpy((u8 *)&msd + sizeof(msd) - o, in, o); + out[--ndigits] = be64_to_cpu(msd); + in += o; + } + ecc_swap_digits(in, out, ndigits); +} +EXPORT_SYMBOL(ecc_digits_from_bytes); + static u64 *ecc_alloc_digits_space(unsigned int ndigits) { size_t len = ndigits * sizeof(u64); |