From: Hao Fang fanghao11@huawei.com
If flen > num_bytes, need to free from_buf.
Signed-off-by: Hao Fang fanghao11@huawei.com --- src/uadk_rsa.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/src/uadk_rsa.c b/src/uadk_rsa.c index fa4d354..1289fd3 100644 --- a/src/uadk_rsa.c +++ b/src/uadk_rsa.c @@ -1491,11 +1491,16 @@ static int uadk_e_rsa_public_encrypt(int flen, const unsigned char *from, }
ret = rsa_create_pub_bn_ctx(rsa, pub_enc, &from_buf, &num_bytes); - if (ret <= 0 || flen > num_bytes) { + if (ret <= 0) { ret = UADK_DO_SOFT; goto free_sess; }
+ if (flen > num_bytes) { + ret = UADK_DO_SOFT; + goto free_buf; + } + ret = add_rsa_pubenc_padding(flen, from, from_buf, num_bytes, padding); if (!ret) { ret = UADK_DO_SOFT; @@ -1756,11 +1761,16 @@ static int uadk_e_rsa_public_verify(int flen, const unsigned char *from, }
ret = rsa_create_pub_bn_ctx(rsa, pub, &from_buf, &num_bytes); - if (ret <= 0 || flen > num_bytes) { + if (ret <= 0) { ret = UADK_DO_SOFT; goto free_sess; }
+ if (flen > num_bytes) { + ret = UADK_DO_SOFT; + goto free_buf; + } + ret = rsa_fill_pubkey(pub, rsa_sess, from_buf, to); if (!ret) { ret = UADK_DO_SOFT;