From 60c76d0c647c5de5e8d0c4a52314e0b91d35816b Mon Sep 17 00:00:00 2001 From: van Hauser Date: Wed, 29 Jan 2020 12:24:46 +0100 Subject: [PATCH] BN_zero fix --- hydra-mod.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/hydra-mod.c b/hydra-mod.c index 9e7d862..f9b1358 100644 --- a/hydra-mod.c +++ b/hydra-mod.c @@ -466,24 +466,25 @@ int32_t internal__hydra_connect(char *host, int32_t port, int32_t type, int32_t #if defined(LIBOPENSSL) && !defined(LIBRESSL_VERSION_NUMBER) RSA *ssl_temp_rsa_cb(SSL * ssl, int32_t export, int32_t keylength) { - int32_t ok = 0; + int32_t nok = 0; #if !defined(LIBRESSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER >= 0x10100000L BIGNUM *n; - n = BN_new(); + if ((n = BN_new()) == NULL) + nok = 1; RSA_get0_key(rsa, (const struct bignum_st **)&n, NULL, NULL); - ok = BN_zero(n); + BN_zero(n); #else if (rsa->n == 0) - ok = 1; + nok = 1; #endif - if(ok == 0 && RSA_size(rsa)!=(keylength/8)){ // n is not zero + if (nok == 0 && RSA_size(rsa)!=(keylength/8)){ // n is not zero #if !defined(LIBRESSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER >= 0x10100000L BN_free(n); #endif RSA_free(rsa); rsa = NULL; } - if (ok != 0) { // n is zero + if (nok != 0) { // n is zero #if defined(NO_RSA_LEGACY) || OPENSSL_VERSION_NUMBER >= 0x10100000L RSA *rsa = RSA_new(); BIGNUM *f4 = BN_new();