diff options
author | Stefan Berger <stefanb@linux.ibm.com> | 2024-04-18 11:24:44 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2024-04-26 17:26:09 +0800 |
commit | b9b16f5f27d2fba430baa8c5c7c543ae08afa7e1 (patch) | |
tree | 3f7efda657c4e36ffa38b23cb151f78a6ded2b11 /crypto/ctr.c | |
parent | 554253f2da3750d96563c641dec0cea09231878a (diff) | |
download | linux-crypto-b9b16f5f27d2fba430baa8c5c7c543ae08afa7e1.tar.gz linux-crypto-b9b16f5f27d2fba430baa8c5c7c543ae08afa7e1.zip |
crypto: ecdh - Pass private key in proper byte order to check valid key
ecc_is_key_valid expects a key with the most significant digit in the last
entry of the digit array. Currently ecdh_set_secret passes a reversed key
to ecc_is_key_valid that then passes the rather simple test checking
whether the private key is in range [2, n-3]. For all current ecdh-
supported curves (NIST P192/256/384) the 'n' parameter is a rather large
number, therefore easily passing this test.
Throughout the ecdh and ecc codebase the variable 'priv' is used for a
private_key holding the bytes in proper byte order. Therefore, introduce
priv in ecdh_set_secret and copy the bytes from ctx->private_key into
priv in proper byte order by using ecc_swap_digits. Pass priv to
ecc_is_valid_key.
Cc: Ard Biesheuvel <ardb@kernel.org>
Cc: Salvatore Benedetto <salvatore.benedetto@intel.com>
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Acked-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto/ctr.c')
0 files changed, 0 insertions, 0 deletions