diff options
Diffstat (limited to '')
-rw-r--r-- | external/unbound/sldns/keyraw.c | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/external/unbound/sldns/keyraw.c b/external/unbound/sldns/keyraw.c index 59e8000f5..e8f2da089 100644 --- a/external/unbound/sldns/keyraw.c +++ b/external/unbound/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 @@ -206,7 +215,6 @@ sldns_key_buf2dsa_raw(unsigned char* key, size_t len) offset += length; Y = BN_bin2bn(key+offset, (int)length, NULL); - offset += length; /* create the key and set its properties */ if(!Q || !P || !G || !Y || !(dsa = DSA_new())) { @@ -216,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; @@ -223,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; } @@ -274,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; } |