/** return true if DNSKEY algorithm id is supported */ int dnskey_algo_id_is_supported(int id) { switch(id) { case LDNS_RSAMD5: /* RFC 6725 deprecates RSAMD5 */ return 0; case LDNS_DSA: case LDNS_DSA_NSEC3: case LDNS_RSASHA1: case LDNS_RSASHA1_NSEC3: #if defined(HAVE_EVP_SHA256) && defined(USE_SHA2) case LDNS_RSASHA256: #endif #if defined(HAVE_EVP_SHA512) && defined(USE_SHA2) case LDNS_RSASHA512: #endif #ifdef USE_ECDSA case LDNS_ECDSAP256SHA256: case LDNS_ECDSAP384SHA384: #endif return 1; #ifdef USE_GOST case LDNS_ECC_GOST: /* we support GOST if it can be loaded */ return ldns_key_EVP_load_gost_id(); #endif default: return 0; } }
void verify_test(void) { unit_show_feature("signature verify"); verifytest_file("testdata/test_signatures.1", "20070818005004"); verifytest_file("testdata/test_signatures.2", "20080414005004"); verifytest_file("testdata/test_signatures.3", "20080416005004"); verifytest_file("testdata/test_signatures.4", "20080416005004"); verifytest_file("testdata/test_signatures.5", "20080416005004"); verifytest_file("testdata/test_signatures.6", "20080416005004"); verifytest_file("testdata/test_signatures.7", "20070829144150"); verifytest_file("testdata/test_signatures.8", "20070829144150"); #if defined(HAVE_EVP_SHA256) && defined(USE_SHA2) verifytest_file("testdata/test_sigs.rsasha256", "20070829144150"); verifytest_file("testdata/test_sigs.sha1_and_256", "20070829144150"); verifytest_file("testdata/test_sigs.rsasha256_draft", "20090101000000"); #endif #if defined(HAVE_EVP_SHA512) && defined(USE_SHA2) verifytest_file("testdata/test_sigs.rsasha512_draft", "20070829144150"); #endif verifytest_file("testdata/test_sigs.hinfo", "20090107100022"); verifytest_file("testdata/test_sigs.revoked", "20080414005004"); #ifdef USE_GOST if(ldns_key_EVP_load_gost_id()) verifytest_file("testdata/test_sigs.gost", "20090807060504"); else printf("Warning: skipped GOST, openssl does not provide gost.\n"); #endif dstest_file("testdata/test_ds.sha1"); nsectest(); nsec3_hash_test("testdata/test_nsec3_hash.1"); }
/** * Main fake event test program. Setup, teardown and report errors. * @param argc: arg count. * @param argv: array of commandline arguments. * @return program failure if test fails. */ int main(int argc, char* argv[]) { int c, res; int pass_argc = 0; char* pass_argv[MAXARG]; char* playback_file = NULL; int init_optind = optind; char* init_optarg = optarg; struct replay_scenario* scen = NULL; /* we do not want the test to depend on the timezone */ (void)putenv("TZ=UTC"); log_init(NULL, 0, NULL); /* determine commandline options for the daemon */ pass_argc = 1; pass_argv[0] = "unbound"; add_opts("-d", &pass_argc, pass_argv); while( (c=getopt(argc, argv, "2egho:p:s")) != -1) { switch(c) { case 's': free(pass_argv[1]); testbound_selftest(); printf("selftest successful\n"); exit(0); case '2': #if (defined(HAVE_EVP_SHA256) || defined(HAVE_NSS)) && defined(USE_SHA2) printf("SHA256 supported\n"); exit(0); #else printf("SHA256 not supported\n"); exit(1); #endif break; case 'e': #if defined(USE_ECDSA) printf("ECDSA supported\n"); exit(0); #else printf("ECDSA not supported\n"); exit(1); #endif break; case 'g': #ifdef USE_GOST if(ldns_key_EVP_load_gost_id()) { printf("GOST supported\n"); exit(0); } else { printf("GOST not supported\n"); exit(1); } #else printf("GOST not supported\n"); exit(1); #endif break; case 'p': playback_file = optarg; break; case 'o': add_opts(optarg, &pass_argc, pass_argv); break; case '?': case 'h': default: testbound_usage(); return 1; } } argc -= optind; argv += optind; if(argc != 0) { testbound_usage(); return 1; } log_info("Start of %s testbound program.", PACKAGE_STRING); if(atexit(&remove_configfile) != 0) fatal_exit("atexit() failed: %s", strerror(errno)); /* setup test environment */ scen = setup_playback(playback_file, &pass_argc, pass_argv); /* init fake event backend */ fake_event_init(scen); pass_argv[pass_argc] = NULL; echo_cmdline(pass_argc, pass_argv); /* reset getopt processing */ optind = init_optind; optarg = init_optarg; /* run the normal daemon */ res = daemon_main(pass_argc, pass_argv); fake_event_cleanup(); for(c=1; c<pass_argc; c++) free(pass_argv[c]); if(res == 0) { log_info("Testbound Exit Success"); #ifdef HAVE_PTHREAD /* dlopen frees its thread state (dlopen of gost engine) */ pthread_exit(NULL); #endif } return res; }