diff options
author | Richard Levitte <levitte@openssl.org> | 2023-01-10 12:22:39 +0100 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2023-01-11 23:51:47 +0100 |
commit | fcc224a3c5c868ee4c0f5ab71d2f47e7f620bc98 (patch) | |
tree | 272792bd9833026a814dab3ee77169f2fe2305eb /crypto | |
parent | 2b7b7eebf9b7d01f8abab88b9ae0685f33c74b54 (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)
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/params.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/crypto/params.c b/crypto/params.c index b270d7d849..e774dc5d27 100644 --- a/crypto/params.c +++ b/crypto/params.c @@ -1063,6 +1063,10 @@ int OSSL_PARAM_set_BN(OSSL_PARAM *p, const BIGNUM *val) } 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; |