crypto: hisilicon/hpre - add check before gx modulo p
PATCH 1/1 crypto: hisilicon/hpre - add check before gx modulo p
The result of gx modulo p is zero if gx is equal to p, so return error immediately if gx is equal to p.
Signed-off-by Hui Tang <[email protected]>
--- drivers/crypto/hisilicon/hpre/hpre_crypto.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/crypto/hisilicon/hpre/hpre_crypto.c +5 -1
@@ -1841,8 +1841,12 @@ static int hpre_curve25519_src_init(struct hpre_asym_request *hpre_req,* When src_data equals (2^255 - 19) ~ (2^255 - 1), it is out of p, * we get its modulus to p, and then use it. */ -if (memcmp (ptr, p, ctx->key_sz) >=0 ) +if (memcmp (ptr, p, ctx->key_sz) ==0 ) { +dev_err (dev,"gx is p!\n" ); +return -EINVAL ; + }else if (memcmp (ptr, p, ctx->key_sz) >0 ) {hpre_curve25519_src_modulo_p (ptr); + } hpre_req->src = ptr; msg->in =cpu_to_le64 (dma);
Signature · 1 line
2.8.1
Herbert Xu
maintainerQuoted 7 lines · Hui Tang
The result of gx modulo p is zero if gx is equal to p, so return error immediately if gx is equal to p.
Signed-off-by Hui Tang <[email protected]>--- drivers/crypto/hisilicon/hpre/hpre_crypto.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
Patch applied. Thanks.
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt