- Fix #1272: assertion failure testcode/unitverify.c:202.

This commit is contained in:
W.C.A. Wijngaards 2025-04-25 11:12:28 +02:00
parent e794234ac8
commit c88fa02c18
4 changed files with 139 additions and 0 deletions

View file

@ -1,3 +1,6 @@
25 April 2025: Wouter
- Fix #1272: assertion failure testcode/unitverify.c:202.
16 April 2025: Wouter 16 April 2025: Wouter
- Increase default to `num-queries-per-thread: 2048`, when unbound is - Increase default to `num-queries-per-thread: 2048`, when unbound is
compiled with libevent. It makes saturation of the task queue more compiled with libevent. It makes saturation of the task queue more

View file

@ -293,6 +293,12 @@ setup_config(FILE* in, int* lineno, int* pass_argc, char* pass_argv[])
fclose(cfg); fclose(cfg);
return; return;
} }
if(strncmp(parse, "fake-sha1: yes", 14) == 0) {
/* Allow the use of SHA1 signatures for the test,
* in case that OpenSSL disallows use of RSASHA1
* with rh-allow-sha1-signatures disabled. */
setenv("OPENSSL_ENABLE_SHA1_SIGNATURES", "1", 0);
}
fputs(line, cfg); fputs(line, cfg);
} }
fatal_exit("No CONFIG_END in input file"); fatal_exit("No CONFIG_END in input file");

View file

@ -61,6 +61,12 @@
#include "sldns/str2wire.h" #include "sldns/str2wire.h"
#include "sldns/wire2str.h" #include "sldns/wire2str.h"
#ifdef HAVE_SSL
#ifdef HAVE_OPENSSL_ERR_H
#include <openssl/err.h>
#endif
#endif
/** verbose signature test */ /** verbose signature test */
static int vsig = 0; static int vsig = 0;
@ -509,10 +515,133 @@ nsec3_hash_test(const char* fname)
#define SRCDIRSTR xstr(SRCDIR) #define SRCDIRSTR xstr(SRCDIR)
#if defined(HAVE_SSL) && defined(USE_SHA1)
/* Detect if openssl is configured to disable RSASHA1 signatures,
* with the rh-allow-sha1-signatures disabled. */
static int
rh_allow_sha1_signatures_disabled(void)
{
EVP_MD_CTX* ctx;
EVP_PKEY* evp_key;
/* This key is rdata from nlnetlabs.nl DNSKEY from 20250424005001,
* with id=50602 (ksk), size=2048b.
* A 2048 bit key is taken to avoid key too small errors. */
unsigned char key[]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D, 0xA5, 0xF5, 0xEB, 0xB9, 0xFE, 0x8F, 0xA1,
0xE4, 0xBF, 0xA4, 0xA4, 0x34, 0x5C, 0x6A, 0x95,
0xB6, 0x42, 0x22, 0xF6, 0xD6, 0x10, 0x9C, 0x9B,
0x0A, 0x56, 0xE7, 0x42, 0xE5, 0x7F, 0x1F, 0x4E,
0xBE, 0x4F, 0x8C, 0xED, 0x30, 0x63, 0xA7, 0x88,
0x93, 0xED, 0x37, 0x3C, 0x80, 0xBC, 0xD1, 0x66,
0xBD, 0xB8, 0x2E, 0x65, 0xC4, 0xC8, 0x00, 0x5B,
0xE7, 0x85, 0x96, 0xDD, 0xAA, 0x05, 0xE6, 0x4F,
0x03, 0x64, 0xFA, 0x2D, 0xF6, 0x88, 0x14, 0x8F,
0x15, 0x4D, 0xFD, 0xD3
};
size_t keylen = 260;
#ifdef HAVE_EVP_MD_CTX_NEW
ctx = EVP_MD_CTX_new();
#else
ctx = (EVP_MD_CTX*)malloc(sizeof(*ctx));
if(ctx) EVP_MD_CTX_init(ctx);
#endif
if(!ctx) return 0;
evp_key = sldns_key_rsa2pkey_raw(key, keylen);
if(!evp_key) {
#ifdef HAVE_EVP_MD_CTX_NEW
EVP_MD_CTX_destroy(ctx);
#else
EVP_MD_CTX_cleanup(ctx);
free(ctx);
#endif
return 0;
}
#ifndef HAVE_EVP_DIGESTVERIFY
(void)evp_key; /* not used */
if(EVP_DigestInit(ctx, EVP_sha1()) == 0)
#else
if(EVP_DigestVerifyInit(ctx, NULL, EVP_sha1(), NULL, evp_key) == 0)
#endif
{
unsigned long e = ERR_get_error();
#ifdef EVP_R_INVALID_DIGEST
if (ERR_GET_LIB(e) == ERR_LIB_EVP &&
ERR_GET_REASON(e) == EVP_R_INVALID_DIGEST) {
/* rh-allow-sha1-signatures makes use of sha1 invalid. */
if(vsig)
printf("Detected that rh-allow-sha1-signatures is off, and disables SHA1 signatures\n");
#ifdef HAVE_EVP_MD_CTX_NEW
EVP_MD_CTX_destroy(ctx);
#else
EVP_MD_CTX_cleanup(ctx);
free(ctx);
#endif
EVP_PKEY_free(evp_key);
return 1;
}
#endif /* EVP_R_INVALID_DIGEST */
/* The signature verify failed for another reason. */
log_crypto_err_code("EVP_DigestVerifyInit", e);
#ifdef HAVE_EVP_MD_CTX_NEW
EVP_MD_CTX_destroy(ctx);
#else
EVP_MD_CTX_cleanup(ctx);
free(ctx);
#endif
EVP_PKEY_free(evp_key);
return 0;
}
#ifdef HAVE_EVP_MD_CTX_NEW
EVP_MD_CTX_destroy(ctx);
#else
EVP_MD_CTX_cleanup(ctx);
free(ctx);
#endif
EVP_PKEY_free(evp_key);
return 0;
}
#endif /* HAVE_SSL && USE_SHA1 */
void void
verify_test(void) verify_test(void)
{ {
unit_show_feature("signature verify"); unit_show_feature("signature verify");
#if defined(HAVE_SSL) && defined(USE_SHA1)
if(rh_allow_sha1_signatures_disabled()) {
/* Allow the use of SHA1 signatures for the test,
* in case that OpenSSL disallows use of RSASHA1
* with rh-allow-sha1-signatures disabled. */
setenv("OPENSSL_ENABLE_SHA1_SIGNATURES", "1", 0);
}
#endif
#ifdef USE_SHA1 #ifdef USE_SHA1
verifytest_file(SRCDIRSTR "/testdata/test_signatures.1", "20070818005004"); verifytest_file(SRCDIRSTR "/testdata/test_signatures.1", "20070818005004");
#endif #endif

View file

@ -11,6 +11,7 @@ server:
# Use a fixed and faked date for DNSSEC validation to avoid run-time # Use a fixed and faked date for DNSSEC validation to avoid run-time
# re-signing test signatures. # re-signing test signatures.
val-override-date: "20161001003725" val-override-date: "20161001003725"
fake-sha1: yes
define-tag: "cname cname2 nx servfail sec ambiguous" define-tag: "cname cname2 nx servfail sec ambiguous"
access-control-tag: 127.0.0.1/32 "cname cname2 nx servfail sec" access-control-tag: 127.0.0.1/32 "cname cname2 nx servfail sec"