diff options
author | David Benjamin <davidben@google.com> | 2017-11-21 20:33:36 -0500 |
---|---|---|
committer | CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org> | 2017-11-22 18:43:38 +0000 |
commit | 8dc226ca8f1ef60737e1c1bf8cfcabf51d4068c7 (patch) | |
tree | be9ed02f91eafe3d344273f362bb8c0238405446 | |
parent | 855d5046c7899f19e2fad6ac83504a40cd92c6cc (diff) | |
download | boringssl-8dc226ca8f1ef60737e1c1bf8cfcabf51d4068c7.zip boringssl-8dc226ca8f1ef60737e1c1bf8cfcabf51d4068c7.tar.gz boringssl-8dc226ca8f1ef60737e1c1bf8cfcabf51d4068c7.tar.bz2 |
Add some missing OpenSSL 1.1.0 accessors.
wpa_supplicant appear to be using these.
Change-Id: I1f220cae69162901bcd9452e8daf67379c5e276c
Reviewed-on: https://boringssl-review.googlesource.com/23324
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
-rw-r--r-- | crypto/evp/p_rsa_asn1.c | 2 | ||||
-rw-r--r-- | crypto/fipsmodule/ecdsa/ecdsa.c | 21 | ||||
-rw-r--r-- | crypto/fipsmodule/rsa/rsa.c | 2 | ||||
-rw-r--r-- | include/openssl/ecdsa.h | 10 | ||||
-rw-r--r-- | include/openssl/rsa.h | 3 |
5 files changed, 37 insertions, 1 deletions
diff --git a/crypto/evp/p_rsa_asn1.c b/crypto/evp/p_rsa_asn1.c index a188538..85f6fc8 100644 --- a/crypto/evp/p_rsa_asn1.c +++ b/crypto/evp/p_rsa_asn1.c @@ -161,7 +161,7 @@ static int int_rsa_size(const EVP_PKEY *pkey) { } static int rsa_bits(const EVP_PKEY *pkey) { - return BN_num_bits(pkey->pkey.rsa->n); + return RSA_bits(pkey->pkey.rsa); } static void int_rsa_free(EVP_PKEY *pkey) { RSA_free(pkey->pkey.rsa); } diff --git a/crypto/fipsmodule/ecdsa/ecdsa.c b/crypto/fipsmodule/ecdsa/ecdsa.c index 8d01c6f..4bed580 100644 --- a/crypto/fipsmodule/ecdsa/ecdsa.c +++ b/crypto/fipsmodule/ecdsa/ecdsa.c @@ -116,6 +116,27 @@ void ECDSA_SIG_free(ECDSA_SIG *sig) { OPENSSL_free(sig); } +void ECDSA_SIG_get0(const ECDSA_SIG *sig, const BIGNUM **out_r, + const BIGNUM **out_s) { + if (out_r != NULL) { + *out_r = sig->r; + } + if (out_s != NULL) { + *out_s = sig->s; + } +} + +int ECDSA_SIG_set0(ECDSA_SIG *sig, BIGNUM *r, BIGNUM *s) { + if (r == NULL || s == NULL) { + return 0; + } + BN_free(sig->r); + BN_free(sig->s); + sig->r = r; + sig->s = s; + return 1; +} + ECDSA_SIG *ECDSA_do_sign(const uint8_t *digest, size_t digest_len, const EC_KEY *key) { return ECDSA_do_sign_ex(digest, digest_len, NULL, NULL, key); diff --git a/crypto/fipsmodule/rsa/rsa.c b/crypto/fipsmodule/rsa/rsa.c index d001d7b..4a84314 100644 --- a/crypto/fipsmodule/rsa/rsa.c +++ b/crypto/fipsmodule/rsa/rsa.c @@ -157,6 +157,8 @@ int RSA_up_ref(RSA *rsa) { return 1; } +unsigned RSA_bits(const RSA *rsa) { return BN_num_bits(rsa->n); } + void RSA_get0_key(const RSA *rsa, const BIGNUM **out_n, const BIGNUM **out_e, const BIGNUM **out_d) { if (out_n != NULL) { diff --git a/include/openssl/ecdsa.h b/include/openssl/ecdsa.h index ff26fe4..d2a828d 100644 --- a/include/openssl/ecdsa.h +++ b/include/openssl/ecdsa.h @@ -106,6 +106,16 @@ OPENSSL_EXPORT ECDSA_SIG *ECDSA_SIG_new(void); // ECDSA_SIG_free frees |sig| its member |BIGNUM|s. OPENSSL_EXPORT void ECDSA_SIG_free(ECDSA_SIG *sig); +// ECDSA_SIG_get0 sets |*out_r| and |*out_s|, if non-NULL, to the two +// components of |sig|. +OPENSSL_EXPORT void ECDSA_SIG_get0(const ECDSA_SIG *sig, const BIGNUM **out_r, + const BIGNUM **out_s); + +// ECDSA_SIG_set0 sets |sig|'s components to |r| and |s|, neither of which may +// be NULL. On success, it takes ownership of each argument and returns one. +// Otherwise, it returns zero. +OPENSSL_EXPORT int ECDSA_SIG_set0(ECDSA_SIG *sig, BIGNUM *r, BIGNUM *s); + // ECDSA_do_sign signs |digest_len| bytes from |digest| with |key| and returns // the resulting signature structure, or NULL on error. OPENSSL_EXPORT ECDSA_SIG *ECDSA_do_sign(const uint8_t *digest, diff --git a/include/openssl/rsa.h b/include/openssl/rsa.h index 74268cf..11aa8e4 100644 --- a/include/openssl/rsa.h +++ b/include/openssl/rsa.h @@ -89,6 +89,9 @@ OPENSSL_EXPORT int RSA_up_ref(RSA *rsa); // Properties. +// RSA_bits returns the size of |rsa|, in bits. +OPENSSL_EXPORT unsigned RSA_bits(const RSA *rsa); + // RSA_get0_key sets |*out_n|, |*out_e|, and |*out_d|, if non-NULL, to |rsa|'s // modulus, public exponent, and private exponent, respectively. If |rsa| is a // public key, the private exponent will be set to NULL. |