diff options
author | Matt Caswell <matt@openssl.org> | 2023-06-23 11:50:17 +0100 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2023-06-26 09:35:01 +0100 |
commit | 8ebc73453746e5303d5249986e2e42e7937a67ad (patch) | |
tree | e59a9270ad71e07828bf9d2a05d999704b21c671 /apps/lib/apps.c | |
parent | 8d6ea2d2c3cfdb1f09898ee98362b057893e6f14 (diff) |
Don't truncate the input when decrypting in pkeyutl
The pkeyutl app was truncating the input file for decryption leading to
incorrect results. This was probably ok historically when RSA was being
used for decryption which has short maximum sizes. This is not ok with SM2.
Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21272)
(cherry picked from commit 849450746f38a5658ef783abb0a8c79ae2861464)
Diffstat (limited to 'apps/lib/apps.c')
-rw-r--r-- | apps/lib/apps.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/apps/lib/apps.c b/apps/lib/apps.c index 891af71730..bbaecb8c72 100644 --- a/apps/lib/apps.c +++ b/apps/lib/apps.c @@ -2003,7 +2003,8 @@ int bio_to_mem(unsigned char **out, int maxlen, BIO *in) BIO_free(mem); return -1; } - maxlen -= len; + if (maxlen != -1) + maxlen -= len; if (maxlen == 0) break; |