diff options
author | Dag-Erling Smørgrav <des@FreeBSD.org> | 2016-09-27 21:11:07 +0000 |
---|---|---|
committer | Dag-Erling Smørgrav <des@FreeBSD.org> | 2016-09-27 21:11:07 +0000 |
commit | 27c2fff0f2fef695b0599fc3931cacfc16376e88 (patch) | |
tree | b2599c622858ea78bd8237ce2ee38b62725dabf9 /sldns/keyraw.c | |
parent | a6533d88996e7570cf04db0d99b6012d25a953d3 (diff) | |
download | src-test2-27c2fff0f2fef695b0599fc3931cacfc16376e88.tar.gz src-test2-27c2fff0f2fef695b0599fc3931cacfc16376e88.zip |
Notes
Diffstat (limited to 'sldns/keyraw.c')
-rw-r--r-- | sldns/keyraw.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/sldns/keyraw.c b/sldns/keyraw.c index 8d28bf40ab32..e8f2da089d6a 100644 --- a/sldns/keyraw.c +++ b/sldns/keyraw.c @@ -23,6 +23,15 @@ #ifdef HAVE_OPENSSL_ENGINE_H # include <openssl/engine.h> #endif +#ifdef HAVE_OPENSSL_BN_H +#include <openssl/bn.h> +#endif +#ifdef HAVE_OPENSSL_RSA_H +#include <openssl/rsa.h> +#endif +#ifdef HAVE_OPENSSL_DSA_H +#include <openssl/dsa.h> +#endif #endif /* HAVE_SSL */ size_t @@ -215,6 +224,7 @@ sldns_key_buf2dsa_raw(unsigned char* key, size_t len) BN_free(Y); return NULL; } +#if OPENSSL_VERSION_NUMBER < 0x10100000 || defined(HAVE_LIBRESSL) #ifndef S_SPLINT_S dsa->p = P; dsa->q = Q; @@ -222,6 +232,25 @@ sldns_key_buf2dsa_raw(unsigned char* key, size_t len) dsa->pub_key = Y; #endif /* splint */ +#else /* OPENSSL_VERSION_NUMBER */ + if (!DSA_set0_pqg(dsa, P, Q, G)) { + /* QPG not yet attached, need to free */ + BN_free(Q); + BN_free(P); + BN_free(G); + + DSA_free(dsa); + BN_free(Y); + return NULL; + } + if (!DSA_set0_key(dsa, Y, NULL)) { + /* QPG attached, cleaned up by DSA_fre() */ + DSA_free(dsa); + BN_free(Y); + return NULL; + } +#endif + return dsa; } @@ -273,11 +302,21 @@ sldns_key_buf2rsa_raw(unsigned char* key, size_t len) BN_free(modulus); return NULL; } +#if OPENSSL_VERSION_NUMBER < 0x10100000 || defined(HAVE_LIBRESSL) #ifndef S_SPLINT_S rsa->n = modulus; rsa->e = exponent; #endif /* splint */ +#else /* OPENSSL_VERSION_NUMBER */ + if (!RSA_set0_key(rsa, modulus, exponent, NULL)) { + BN_free(exponent); + BN_free(modulus); + RSA_free(rsa); + return NULL; + } +#endif + return rsa; } |