summaryrefslogtreecommitdiffstats
path: root/crypto/param_build.c
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2021-11-19 13:18:34 +0100
committerRichard Levitte <levitte@openssl.org>2021-11-23 11:43:07 +0100
commitb5a4f7f56fc8601c6aadd58a5e22ab1a1954ba5a (patch)
tree074114676356b0183f958d6506ca5c29dc2b1705 /crypto/param_build.c
parent38e2957249c90317a26a080c7e7eb186dd5b6598 (diff)
Make OSSL_PARAM_BLD_push_BN{,_pad}() return an error on negative numbers
Adding documentation to that fact as well. Fixes #17070 Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/17074) (cherry picked from commit db65eabefe76e44818ff8bd19c68990e7dcc70d3)
Diffstat (limited to 'crypto/param_build.c')
-rw-r--r--crypto/param_build.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/crypto/param_build.c b/crypto/param_build.c
index e64deaa88f..eaece0026d 100644
--- a/crypto/param_build.c
+++ b/crypto/param_build.c
@@ -204,6 +204,12 @@ int OSSL_PARAM_BLD_push_BN_pad(OSSL_PARAM_BLD *bld, const char *key,
OSSL_PARAM_BLD_DEF *pd;
if (bn != NULL) {
+ if (BN_is_negative(bn)) {
+ ERR_raise_data(ERR_LIB_CRYPTO, ERR_R_UNSUPPORTED,
+ "Negative big numbers are unsupported for OSSL_PARAM");
+ return 0;
+ }
+
n = BN_num_bytes(bn);
if (n < 0) {
ERR_raise(ERR_LIB_CRYPTO, CRYPTO_R_ZERO_LENGTH_NUMBER);