From 2f9f6f1fac6047afe93c4a9e89b8ed2fe3fefdde Mon Sep 17 00:00:00 2001 From: Michal Nowak Date: Mon, 9 Nov 2020 11:49:05 +0100 Subject: [PATCH] Revert "Drop bigkey" This reverts commit ef6703351a726eb9a8d8305075f1ee0f5be83516. It is believed that the bigkey test is still useful. --- bin/tests/system/conf.sh.common | 1 + bin/tests/system/conf.sh.in | 1 + bin/tests/system/conf.sh.win32 | 1 + bin/tests/system/rsabigexponent/.gitignore | 1 + bin/tests/system/rsabigexponent/bigkey.c | 160 ++++++++++++++++++ .../system/win32/bigkey.vcxproj.filters.in | 22 +++ bin/tests/system/win32/bigkey.vcxproj.in | 127 ++++++++++++++ bin/tests/system/win32/bigkey.vcxproj.user | 3 + bin/win32/BINDInstall/BINDInstall.vcxproj.in | 3 + util/copyrights | 4 + win32utils/Configure | 2 + win32utils/bind9.sln.in | 2 + 12 files changed, 327 insertions(+) create mode 100644 bin/tests/system/rsabigexponent/.gitignore create mode 100644 bin/tests/system/rsabigexponent/bigkey.c create mode 100644 bin/tests/system/win32/bigkey.vcxproj.filters.in create mode 100644 bin/tests/system/win32/bigkey.vcxproj.in create mode 100644 bin/tests/system/win32/bigkey.vcxproj.user diff --git a/bin/tests/system/conf.sh.common b/bin/tests/system/conf.sh.common index 2bef317956..e24533a2e8 100644 --- a/bin/tests/system/conf.sh.common +++ b/bin/tests/system/conf.sh.common @@ -694,6 +694,7 @@ copy_setports() { # Export command paths # export ARPANAME +export BIGKEY export CDS export CHECKZONE export CYGWIN diff --git a/bin/tests/system/conf.sh.in b/bin/tests/system/conf.sh.in index c337794c05..9300647551 100644 --- a/bin/tests/system/conf.sh.in +++ b/bin/tests/system/conf.sh.in @@ -62,6 +62,7 @@ TSIGKEYGEN=$TOP_BUILDDIR/bin/confgen/tsig-keygen VERIFY=$TOP_BUILDDIR/bin/dnssec/dnssec-verify WIRETEST=$TOP_BUILDDIR/bin/tests/wire_test +BIGKEY=$TOP_BUILDDIR/bin/tests/system/rsabigexponent/bigkey GENCHECK=$TOP_BUILDDIR/bin/tests/system/rndc/gencheck KEYCREATE=$TOP_BUILDDIR/bin/tests/system/tkey/keycreate KEYDELETE=$TOP_BUILDDIR/bin/tests/system/tkey/keydelete diff --git a/bin/tests/system/conf.sh.win32 b/bin/tests/system/conf.sh.win32 index 73bf605a00..37e4379c84 100644 --- a/bin/tests/system/conf.sh.win32 +++ b/bin/tests/system/conf.sh.win32 @@ -65,6 +65,7 @@ VERIFY=$TOP_BUILDDIR/Build/$VSCONF/dnssec-verify@EXEEXT@ # to port WIRETEST=$TOP_BUILDDIR/Build/$VSCONF/wire_test@EXEEXT@ WIRETEST= +BIGKEY=$TOP_BUILDDIR/Build/$VSCONF/bigkey@EXEEXT@ GENCHECK=$TOP_BUILDDIR/Build/$VSCONF/gencheck@EXEEXT@ KEYCREATE=$TOP_BUILDDIR/Build/$VSCONF/keycreate@EXEEXT@ KEYDELETE=$TOP_BUILDDIR/Build/$VSCONF/keydelete@EXEEXT@ diff --git a/bin/tests/system/rsabigexponent/.gitignore b/bin/tests/system/rsabigexponent/.gitignore new file mode 100644 index 0000000000..5330b04a8e --- /dev/null +++ b/bin/tests/system/rsabigexponent/.gitignore @@ -0,0 +1 @@ +bigkey diff --git a/bin/tests/system/rsabigexponent/bigkey.c b/bin/tests/system/rsabigexponent/bigkey.c new file mode 100644 index 0000000000..5a143119bf --- /dev/null +++ b/bin/tests/system/rsabigexponent/bigkey.c @@ -0,0 +1,160 @@ +/* + * Copyright (C) Internet Systems Consortium, Inc. ("ISC") + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, you can obtain one at https://mozilla.org/MPL/2.0/. + * + * See the COPYRIGHT file distributed with this work for additional + * information regarding copyright ownership. + */ + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#define DST_KEY_INTERNAL + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +dst_key_t *key; +dns_fixedname_t fname; +dns_name_t *name; +unsigned int bits = 1024U; +isc_mem_t *mctx; +isc_log_t *log_; +isc_logconfig_t *logconfig; +int level = ISC_LOG_WARNING; +isc_logdestination_t destination; +char filename[255]; +isc_result_t result; +isc_buffer_t buf; +RSA *rsa; +BIGNUM *e; +EVP_PKEY *pkey; + +#define CHECK(op, msg) \ + do { \ + result = (op); \ + if (result != ISC_R_SUCCESS) { \ + fprintf(stderr, \ + "fatal error: %s returns %s at file %s line " \ + "%d\n", \ + msg, isc_result_totext(result), __FILE__, \ + __LINE__); \ + exit(1); \ + } \ + } while (0) + +int +main(int argc, char **argv) { + UNUSED(argc); + UNUSED(argv); + +#if !USE_PKCS11 + + rsa = RSA_new(); + e = BN_new(); + pkey = EVP_PKEY_new(); + + if ((rsa == NULL) || (e == NULL) || (pkey == NULL) || + !EVP_PKEY_set1_RSA(pkey, rsa)) + { + fprintf(stderr, "fatal error: basic OpenSSL failure\n"); + exit(1); + } + + /* e = 0x1000000000001 */ + BN_set_bit(e, 0); + BN_set_bit(e, 48); + + if (RSA_generate_key_ex(rsa, bits, e, NULL)) { + BN_free(e); + RSA_free(rsa); + } else { + fprintf(stderr, + "fatal error: RSA_generate_key_ex() fails " + "at file %s line %d\n", + __FILE__, __LINE__); + exit(1); + } + + dns_result_register(); + + isc_mem_create(&mctx); + CHECK(dst_lib_init(mctx, NULL), "dst_lib_init()"); + isc_log_create(mctx, &log_, &logconfig); + isc_log_setcontext(log_); + dns_log_init(log_); + dns_log_setcontext(log_); + isc_log_settag(logconfig, "bigkey"); + + destination.file.stream = stderr; + destination.file.name = NULL; + destination.file.versions = ISC_LOG_ROLLNEVER; + destination.file.maximum_size = 0; + isc_log_createchannel(logconfig, "stderr", ISC_LOG_TOFILEDESC, level, + &destination, + ISC_LOG_PRINTTAG | ISC_LOG_PRINTLEVEL); + + CHECK(isc_log_usechannel(logconfig, "stderr", NULL, NULL), "isc_log_" + "usechannel(" + ")"); + name = dns_fixedname_initname(&fname); + isc_buffer_constinit(&buf, "example.", strlen("example.")); + isc_buffer_add(&buf, strlen("example.")); + CHECK(dns_name_fromtext(name, &buf, dns_rootname, 0, NULL), "dns_name_" + "fromtext(" + "\"example." + "\")"); + + CHECK(dst_key_buildinternal(name, DNS_KEYALG_RSASHA1, bits, + DNS_KEYOWNER_ZONE, DNS_KEYPROTO_DNSSEC, + dns_rdataclass_in, pkey, mctx, &key), + "dst_key_buildinternal(...)"); + + CHECK(dst_key_tofile(key, DST_TYPE_PRIVATE | DST_TYPE_PUBLIC, NULL), + "dst_key_tofile()"); + isc_buffer_init(&buf, filename, sizeof(filename) - 1); + isc_buffer_clear(&buf); + CHECK(dst_key_buildfilename(key, 0, NULL, &buf), "dst_key_" + "buildfilename()"); + printf("%s\n", filename); + dst_key_free(&key); + + isc_log_destroy(&log_); + isc_log_setcontext(NULL); + dns_log_setcontext(NULL); + dst_lib_destroy(); + isc_mem_destroy(&mctx); + return (0); +#else /* !USE_PKCS11 */ + return (1); +#endif /* !USE_PKC11 */ +} + +/*! \file */ diff --git a/bin/tests/system/win32/bigkey.vcxproj.filters.in b/bin/tests/system/win32/bigkey.vcxproj.filters.in new file mode 100644 index 0000000000..1b592a604e --- /dev/null +++ b/bin/tests/system/win32/bigkey.vcxproj.filters.in @@ -0,0 +1,22 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + \ No newline at end of file diff --git a/bin/tests/system/win32/bigkey.vcxproj.in b/bin/tests/system/win32/bigkey.vcxproj.in new file mode 100644 index 0000000000..990cb39f57 --- /dev/null +++ b/bin/tests/system/win32/bigkey.vcxproj.in @@ -0,0 +1,127 @@ + + + + + Debug + @PLATFORM@ + + + Release + @PLATFORM@ + + + + {61F9D673-EB5C-47A5-8907-24E034C75EF8} + Win32Proj + bigkey + @WINDOWS_TARGET_PLATFORM_VERSION@ + + + + Application + true + MultiByte + @PLATFORM_TOOLSET@ + + + Application + false + true + MultiByte + @PLATFORM_TOOLSET@ + + + + + + + + + + + + + true + ..\..\..\..\Build\$(Configuration)\ + .\$(Configuration)\ + None + + + false + ..\..\..\..\Build\$(Configuration)\ + .\$(Configuration)\ + None + + + + + + Level4 + false + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + .\$(Configuration)\$(TargetName).pch + .\$(Configuration)\ + .\$(Configuration)\ + $(OutDir)$(TargetName).pdb + true + ..\..\..\..\config.h + .\;..\..\..\..\;@LIBXML2_INC@@OPENSSL_INC@..\..\..\..\lib\isc\win32;..\..\..\..\lib\isc\win32\include;..\..\..\..\lib\isc\include;..\..\..\..\lib\dns\include;%(AdditionalIncludeDirectories) + CompileAsC + + + Console + true + ..\..\..\..\Build\$(Configuration)\$(TargetName)$(TargetExt) + ..\..\..\..\lib\isc\win32\$(Configuration);..\..\..\..\lib\dns\win32\$(Configuration);%(AdditionalLibraryDirectories) + @OPENSSL_LIB@@LIBXML2_LIB@libisc.lib;libdns.lib;ws2_32.lib;%(AdditionalDependencies) + + + + + Level1 + true + + + MaxSpeed + true + @INTRINSIC@ + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + OnlyExplicitInline + false + true + .\$(Configuration)\$(TargetName).pch + .\$(Configuration)\ + .\$(Configuration)\ + $(OutDir)$(TargetName).pdb + ..\..\..\..\config.h + .\;..\..\..\..\;@LIBXML2_INC@@OPENSSL_INC@..\..\..\..\lib\isc\win32;..\..\..\..\lib\isc\win32\include;..\..\..\..\lib\isc\include;..\..\..\..\lib\dns\include;%(AdditionalIncludeDirectories) + CompileAsC + + + Console + false + true + true + ..\..\..\..\Build\$(Configuration)\$(TargetName)$(TargetExt) + Default + ..\..\..\..\lib\isc\win32\$(Configuration);..\..\..\..\lib\dns\win32\$(Configuration);%(AdditionalLibraryDirectories) + @OPENSSL_LIB@@LIBXML2_LIB@libisc.lib;libdns.lib;ws2_32.lib;%(AdditionalDependencies) + + + + + + + + {3840E563-D180-4761-AA9C-E6155F02EAFF} + + + {5FEBFD4E-CCB0-48B9-B733-E15EEB85C16A} + + + + + + diff --git a/bin/tests/system/win32/bigkey.vcxproj.user b/bin/tests/system/win32/bigkey.vcxproj.user new file mode 100644 index 0000000000..ace9a86acb --- /dev/null +++ b/bin/tests/system/win32/bigkey.vcxproj.user @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/bin/win32/BINDInstall/BINDInstall.vcxproj.in b/bin/win32/BINDInstall/BINDInstall.vcxproj.in index a8be6ec126..92de623ada 100644 --- a/bin/win32/BINDInstall/BINDInstall.vcxproj.in +++ b/bin/win32/BINDInstall/BINDInstall.vcxproj.in @@ -237,6 +237,9 @@ {39721F26-8B80-4AA9-9826-2AEF7322C3D5} @IF STESTS + + {61F9D673-EB5C-47A5-8907-24E034C75EF8} + {63A921F6-1200-4723-828A-98960127B73D} diff --git a/util/copyrights b/util/copyrights index ff4ddad111..5b5de94f1c 100644 --- a/util/copyrights +++ b/util/copyrights @@ -756,6 +756,7 @@ ./bin/tests/system/rrsetorder/dig.out.random.good9 X 2006,2018,2019,2020 ./bin/tests/system/rrsetorder/setup.sh SH 2018,2019,2020 ./bin/tests/system/rrsetorder/tests.sh SH 2006,2007,2008,2011,2012,2014,2015,2016,2017,2018,2019,2020 +./bin/tests/system/rsabigexponent/bigkey.c C 2012,2014,2015,2016,2017,2018,2019,2020 ./bin/tests/system/rsabigexponent/clean.sh SH 2012,2014,2016,2018,2019,2020 ./bin/tests/system/rsabigexponent/ns1/sign.sh SH 2012,2014,2016,2018,2019,2020 ./bin/tests/system/rsabigexponent/ns2/Xexample.+005+05896.key X 2012,2018,2019,2020 @@ -918,6 +919,9 @@ ./bin/tests/system/wildcard/ns1/sign.sh SH 2012,2013,2014,2016,2018,2019,2020 ./bin/tests/system/wildcard/setup.sh SH 2012,2014,2016,2017,2018,2019,2020 ./bin/tests/system/wildcard/tests.sh SH 2012,2013,2016,2018,2019,2020 +./bin/tests/system/win32/bigkey.vcxproj.filters.in X 2016,2018,2019,2020 +./bin/tests/system/win32/bigkey.vcxproj.in X 2016,2017,2018,2019,2020 +./bin/tests/system/win32/bigkey.vcxproj.user X 2016,2018,2019,2020 ./bin/tests/system/win32/feature-test.vcxproj.filters.in X 2016,2018,2019,2020 ./bin/tests/system/win32/feature-test.vcxproj.in X 2016,2017,2018,2019,2020 ./bin/tests/system/win32/feature-test.vcxproj.user X 2016,2018,2019,2020 diff --git a/win32utils/Configure b/win32utils/Configure index e8ec8a3684..1d896311be 100644 --- a/win32utils/Configure +++ b/win32utils/Configure @@ -98,6 +98,8 @@ my @projectlist = ("../bin/check/win32/checkconf.vcxproj", "../bin/tools/win32/nsec3hash.vcxproj.filters", "../bin/tools/win32/rrchecker.vcxproj", "../bin/tools/win32/rrchecker.vcxproj.filters", + "../bin/tests/system/win32/bigkey.vcxproj", + "../bin/tests/system/win32/bigkey.vcxproj.filters", "../bin/tests/system/win32/feature-test.vcxproj", "../bin/tests/system/win32/feature-test.vcxproj.filters", "../bin/tests/system/win32/gencheck.vcxproj", diff --git a/win32utils/bind9.sln.in b/win32utils/bind9.sln.in index acbb80f613..fe004aece3 100644 --- a/win32utils/bind9.sln.in +++ b/win32utils/bind9.sln.in @@ -109,6 +109,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "makejournal", "..\bin\tests EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gencheck", "..\bin\tests\system\win32\gencheck.vcxproj", "{764DBE24-C8B3-46E8-BE73-196431353A5D}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bigkey", "..\bin\tests\system\win32\bigkey.vcxproj", "{61F9D673-EB5C-47A5-8907-24E034C75EF8}" +EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pipequeries", "..\bin\tests\system\win32\pipequeries.vcxproj", "{E1478F40-786C-4738-8E99-E7A71DD98661}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "keycreate", "..\bin\tests\system\win32\keycreate.vcxproj", "{4F9A0F6F-366D-4483-B131-793832840508}"