summaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2023-01-10 12:22:39 +0100
committerRichard Levitte <levitte@openssl.org>2023-01-11 23:53:02 +0100
commitf51b4ebb07948d942cd6536fe48e325655349d97 (patch)
tree51e7264bfaad5b1c3904713f4489a5b145182e2b /crypto
parent5601648e91d99696bc7ae37e8972c5b4b15cf832 (diff)
In OSSL_PARAM_set_BN(), make sure that the data_size field is at least 1
This way, we guarantee that a zero is represented with one byte of data that's set to zero. Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/20013) (cherry picked from commit c2ae89148343750e420b72ef1b709ebbc16e47b8) (cherry picked from commit fcc224a3c5c868ee4c0f5ab71d2f47e7f620bc98)
Diffstat (limited to 'crypto')
-rw-r--r--crypto/params.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/crypto/params.c b/crypto/params.c
index 9049041e3b..8196e91672 100644
--- a/crypto/params.c
+++ b/crypto/params.c
@@ -932,6 +932,10 @@ int OSSL_PARAM_set_BN(OSSL_PARAM *p, const BIGNUM *val)
return 0;
bytes = (size_t)BN_num_bytes(val);
+ /* We make sure that at least one byte is used, so zero is properly set */
+ if (bytes == 0)
+ bytes++;
+
p->return_size = bytes;
if (p->data == NULL)
return 1;