00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <config.h>
00022
00023 #include <atf-c.h>
00024
00025 #include <unistd.h>
00026
00027 #include <dns/db.h>
00028 #include <dns/nsec3.h>
00029
00030 #include "dnstest.h"
00031
00032 #if defined(OPENSSL) || defined(PKCS11CRYPTO)
00033
00034
00035
00036
00037 static void
00038 iteration_test(const char* file, unsigned int expected) {
00039 isc_result_t result;
00040 dns_db_t *db = NULL;
00041 unsigned int iterations;
00042
00043 result = dns_test_begin(NULL, ISC_FALSE);
00044 ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
00045
00046 result = dns_test_loaddb(&db, dns_dbtype_zone, "test", file);
00047 ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
00048
00049 result = dns_nsec3_maxiterations(db, NULL, mctx, &iterations);
00050 ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
00051
00052 ATF_REQUIRE_EQ(iterations, expected);
00053
00054 dns_db_detach(&db);
00055
00056 dns_test_end();
00057 }
00058
00059
00060
00061
00062
00063 ATF_TC(max_iterations);
00064 ATF_TC_HEAD(max_iterations, tc) {
00065 atf_tc_set_md_var(tc, "descr", "check that appropriate max iterations "
00066 " is returned for different key size mixes");
00067 }
00068 ATF_TC_BODY(max_iterations, tc) {
00069
00070 UNUSED(tc);
00071
00072 iteration_test("testdata/nsec3/1024.db", 150);
00073 iteration_test("testdata/nsec3/2048.db", 500);
00074 iteration_test("testdata/nsec3/4096.db", 2500);
00075 iteration_test("testdata/nsec3/min-1024.db", 150);
00076 iteration_test("testdata/nsec3/min-2048.db", 500);
00077 }
00078 #else
00079 ATF_TC(untested);
00080 ATF_TC_HEAD(untested, tc) {
00081 atf_tc_set_md_var(tc, "descr", "skipping nsec3 test");
00082 }
00083 ATF_TC_BODY(untested, tc) {
00084 UNUSED(tc);
00085 atf_tc_skip("DNSSEC not available");
00086 }
00087 #endif
00088
00089
00090
00091
00092 ATF_TP_ADD_TCS(tp) {
00093 #if defined(OPENSSL) || defined(PKCS11CRYPTO)
00094 ATF_TP_ADD_TC(tp, max_iterations);
00095 #else
00096 ATF_TP_ADD_TC(tp, untested);
00097 #endif
00098
00099 return (atf_no_error());
00100 }
00101