3 # Configure -- python version
5 # this script builds Visual Studio files
7 from __future__ import print_function
17 filelist = ["config.h",
19 "convarch\\convarch.vcxproj.filters",
20 "convarch\\convarch.vcxproj",
21 "cryptotest\\cryptotest.vcxproj",
22 "datamgrtest\\datamgrtest.vcxproj",
24 "handlemgrtest\\handlemgrtest.vcxproj",
25 "keyconv\\keyconv.vcxproj.filters",
26 "keyconv\\keyconv.vcxproj",
27 "objstoretest\\objstoretest.vcxproj",
28 "p11test\\p11test.vcxproj",
29 "sessionmgrtest\\sessionmgrtest.vcxproj",
30 "slotmgrtest\\slotmgrtest.vcxproj",
31 "softhsm2\\softhsm2.vcxproj",
32 "util\\util.vcxproj.filters",
50 varnames = ["CUINCPATH",
69 condnames = ["AESGCM",
80 # enable-xxx/disable-xxx arguments
82 enablelist = ["64bit",
91 # with-xxx/without-xxx arguments
103 commandlist = ["help", "clean"] # verbose, keep
107 usage = ["Usage: python Configure.py help",
108 " python Configure.py options*",
109 " python Configure.py clean"]
113 myhelp = ["'python Configure.py' configures SoftHSMv2 build files.\n"] +\
115 "\nGeneral Commands:",
116 " help print this help",
117 " clean clean up generated files",
118 " <none> print a summary of the configuration",
119 "\nOptional Features:",
120 " enable-verbose print messages [default=no]",
121 " enable-keep keep test files after config [default=no]",
122 " enable-64bit enable 64-bit compiling [default=no]",
123 " enable-debug enable build of Debug config [default=yes]",
124 " enable-ecc enable support for ECC [default=yes]",
125 " enable-gost enable support for GOST [default=yes]",
126 " enable-static-runtime enable build with static CRT (/MT) [default=no]",
127 " enable-non-paged-memory enable non-paged memory [default=yes]",
128 "\nOptional Packages:",
129 " with-crypto-backend select the crypto backend [openssl|botan]",
130 " with-botan=PATH speficy prefix of path of Botan (Release)",
131 " with-debug-botan=PATH speficy prefix of path of Botan (Debug)",
132 " with-openssl=PATH speficy prefix of path of OpenSSL (Release)",
133 " with-debug-openssl=PATH speficy prefix of path of OpenSSL (Debug)",
134 " with-cppunit=PATH specify prefix of path of CppUnit",
135 " with-toolset=VALUE set Visual Studio platform toolset version (eg v110 for vs2012)",
138 # variables for parsing
150 enable_static_runtime = False
151 enable_non_paged = True
153 crypto_backend = "openssl"
154 botan_path = "..\\..\\btn"
155 debug_botan_path = None
156 openssl_path = "..\\..\\ssl"
157 debug_openssl_path = None
159 cppunit_path = "..\\..\\cu"
162 def dodetectplatform(visualstudio):
163 # detect platform tool set >= VS2010
166 if "Microsoft Visual Studio 10.0" in visualstudio:
168 elif "Microsoft Visual Studio 11.0" in visualstudio:
170 elif "Microsoft Visual Studio 12.0" in visualstudio:
172 elif "Microsoft Visual Studio 14.0" in visualstudio:
175 print("PlatformToolset for \""+visualstudio+"\" not supported")
178 def dodetectvisualstudio():
179 """detect visual studio version"""
180 if os.environ.get('VSINSTALLDIR'):
181 dodetectplatform(os.environ.get('VSINSTALLDIR'))
184 """parse arguments"""
191 global debug_botan_path
192 global debug_openssl_path
194 if arg.lower() == "verbose":
197 if arg.lower() == "keep":
200 if arg.lower() == "help":
203 di = re.match(r'disable-(.*)', arg, re.I)
206 myenable(di.group(1), False)
208 en = re.match(r'enable-(.*)', arg, re.I)
211 myenable(en.group(1), True)
213 wo = re.match(r'without-(.*)', arg, re.I)
216 mywith(wo.group(1), False)
218 wv = re.match(r'with-(.*)=(.*)', arg, re.I)
221 if wv.group(2).lower() == "no":
222 mywith(wv.group(1), False)
224 mywith(wv.group(1), True, wv.group(2))
226 wi = re.match(r'with-(.*)', arg, re.I)
229 mywith(wi.group(1), True)
231 if arg.lower() == "clean":
240 if debug_botan_path is None:
241 debug_botan_path = botan_path + "_d"
242 if debug_openssl_path is None:
243 debug_openssl_path = openssl_path + "_d"
246 """append seen arguments to configargs"""
248 # escape backslashes, spaces and double quotes
252 if (x == "\\") or (x == " ") or (x == "\""):
256 configargs += " " + escaped
260 def myenable(key, val):
261 """parse enable/disable"""
266 global enable_static_runtime
267 global enable_non_paged
272 if key.lower() == "64bit":
276 if key.lower() == "debug":
280 if key.lower() == "ecc":
284 if key.lower() == "gost":
288 if key.lower() == "static-runtime":
290 enable_static_runtime = True
292 if key.lower() == "non-paged-memory":
294 enable_non_paged = False
296 if key.lower() == "keep":
300 if key.lower() == "verbose":
306 unknown_value = "disable-" + key
308 unknown_value = "enable-" + key
310 def mywith(key, val, detail=None):
311 """parse with/without"""
312 global crypto_backend
314 global debug_botan_path
316 global debug_openssl_path
323 if key.lower() == "crypto-backend":
324 if val and (detail.lower() == "openssl"):
325 crypto_backend = "openssl"
327 if val and (detail.lower() == "botan"):
328 crypto_backend = "botan"
331 unknown_value = "with-crypto-backend=" + detail
333 if key.lower() == "botan":
336 unknown_value = "without-botan doesn't make sense"
338 if detail.lower() != "yes":
341 if key.lower() == "debug-botan":
344 unknown_value = "without-debug-botan doesn't make sense"
346 if detail.lower() != "yes":
347 debug_botan_path = detail
349 if key.lower() == "openssl":
352 unknown_value = "without-openssl doesn't make sense"
354 if detail.lower() != "yes":
355 openssl_path = detail
357 if key.lower() == "debug-openssl":
360 unknown_value = "without-debug-openssl doesn't make sense"
362 if detail.lower() != "yes":
363 debug_openssl_path = detail
365 if key.lower() == "cppunit":
369 if detail.lower() != "yes":
370 cppunit_path = detail
372 if key.lower() == "toolset":
377 toolset=detail.lower()
381 unknown_value = "without-" + key
383 unknown_value = "with-" + key
392 """clean test files"""
393 for basename in testlist:
394 filename = "test" + basename + ".c"
395 if os.path.isfile(filename):
397 filename = "test" + basename + ".cpp"
398 if os.path.isfile(filename):
400 filename = "test" + basename + ".obj"
401 if os.path.isfile(filename):
403 filename = "test" + basename + ".exe"
404 if os.path.isfile(filename):
406 if os.path.isfile("botan.dll"):
407 os.unlink("botan.dll")
408 if os.path.isfile("libeay32.dll"):
409 os.unlink("libeay32.dll")
410 if os.path.isfile("libeaycompat32.dll"):
411 os.unlink("libeaycompat32.dll")
412 if os.path.isfile("libcrypto-1_1.dll"):
413 os.unlink("libcrypto-1_1.dll")
414 if os.path.isfile("libcrypto-1_1-x64.dll"):
415 os.unlink("libcrypto-1_1-x64.dll")
420 for filename in filelist:
421 if os.path.isfile(filename):
427 print("can't parse " + unknown_value + "", file=sys.stderr)
433 global debug_botan_path
435 global debug_openssl_path
438 # configure the platform
440 varvals["PLATFORM"] = "Win32"
442 varvals["PLATFORM"] = "x64"
443 varvals["PLATFORMDIR"] = "x64\\"
445 # configure the runtime library
446 if enable_static_runtime:
447 varvals["RUNTIMELIBRARY"] = "MultiThreaded"
449 varvals["RUNTIMELIBRARY"] = "MultiThreadedDLL"
451 # configure ECC and GOST
453 condvals["ECC"] = True
455 condvals["GOST"] = True
457 # configure the crypto
458 if crypto_backend == "botan":
459 condvals["BOTAN"] = True
460 varvals["LIBNAME"] = "botan.lib"
461 botan_path = os.path.abspath(botan_path)
462 botan_inc = os.path.join(botan_path, "include")
464 if os.path.exists(os.path.join(botan_inc, "botan-2\\botan\\init.h")):
465 varvals["INCLUDEPATH"] = os.path.join(botan_inc, "botan-2")
466 elif os.path.exists(os.path.join(botan_inc, "botan-1.11\\botan\\init.h")):
467 varvals["INCLUDEPATH"] = os.path.join(botan_inc, "botan-1.11")
468 elif os.path.exists(os.path.join(botan_inc, "botan\\init.h")):
469 varvals["INCLUDEPATH"] = botan_inc
471 print("can't find Botan includes", file=sys.stderr)
473 if os.path.exists(os.path.join(botan_path, "lib\\botan.lib")):
474 varvals["LIBPATH"] = os.path.join(botan_path, "lib")
475 botan_dll = os.path.join(botan_path, "lib\\botan.dll")
476 elif os.path.exists(os.path.join(botan_path, "botan.lib")):
477 varvals["LIBPATH"] = botan_path
478 botan_dll = os.path.join(botan_path, "botan.dll")
480 print("can't find Botan library", file=sys.stderr)
482 varvals["DLLPATH"] = botan_dll
484 debug_botan_path = os.path.abspath(debug_botan_path)
485 debug_botan_inc = os.path.join(debug_botan_path, "include")
487 if os.path.exists(os.path.join(debug_botan_inc, "botan-2\\botan\\init.h")):
488 varvals["DEBUGINCPATH"] = os.path.join(debug_botan_inc, "botan-2")
489 elif os.path.exists(os.path.join(debug_botan_inc, "botan-1.11\\botan\\init.h")):
490 varvals["DEBUGINCPATH"] = os.path.join(debug_botan_inc, "botan-1.11")
491 elif os.path.exists(os.path.join(debug_botan_inc, "botan\\init.h")):
492 varvals["DEBUGINCPATH"] = debug_botan_inc
494 print("can't find debug Botan includes", file=sys.stderr)
496 if os.path.exists(os.path.join(debug_botan_path, "lib\\botan.lib")):
497 varvals["DEBUGLIBPATH"] = os.path.join(debug_botan_path, "lib")
498 debug_botan_dll = os.path.join(debug_botan_path, "lib\\botan.dll")
499 if os.path.exists(os.path.join(debug_botan_path, "botan.lib")):
500 varvals["DEBUGLIBPATH"] = debug_botan_path
501 debug_botan_dll = os.path.join(debug_botan_path, "botan.dll")
503 print("can't find debug Botan library", file=sys.stderr)
505 varvals["DEBUGDLLPATH"] = debug_botan_dll
507 varvals["DEBUGDLLPATH"] = varvals["DLLPATH"]
508 varvals["DEBUGINCPATH"] = varvals["INCLUDEPATH"]
509 varvals["DEBUGLIBPATH"] = varvals["LIBPATH"]
513 print("checking Botan version")
514 botan_version_major = 0
515 botan_version_minor = 0
517 if os.path.exists(botan_dll):
518 subprocess.call(["copy", botan_dll, "."], shell=True)
520 system_libs = ["user32.lib", "advapi32.lib"]
521 inc = varvals["INCLUDEPATH"]
522 lib = os.path.join(varvals["LIBPATH"], "botan.lib")
523 testfile = open("testbotan.cpp", "w")
525 #include <botan/version.h>\n\
527 #if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(2,0,0)\n\
529 #elif BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,11,0)\n\
531 #elif BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,10,0)\n\
538 command = ["cl", "/nologo", "/MD", "/I", inc, "testbotan.cpp", lib]
539 command.extend(system_libs)
540 subprocess.check_output(command, stderr=subprocess.STDOUT)
541 if not os.path.exists(".\\testbotan.exe"):
542 print("can't create .\\testbotan.exe", file=sys.stderr)
544 ret = subprocess.call(".\\testbotan.exe")
546 print("Botan version too old", file=sys.stderr)
549 botan_version_major = 1
550 botan_version_minor = 10
552 botan_version_major = 1
553 botan_version_minor = 11
554 print("Botan version 1.11 not yet supported", file=sys.stderr)
557 botan_version_major = 2
558 botan_version_minor = 0
559 print("Botan version 2.0 not yet supported", file=sys.stderr)
562 print("Botan test failed", file=sys.stderr)
568 print("checking Botan ECC support")
569 testfile = open("testecc.cpp", "w")
571 #include <botan/init.h>\n\
572 #include <botan/ec_group.h>\n\
573 #include <botan/oids.h>\n\
574 #include <botan/version.h>\n\
576 Botan::LibraryInitializer::initialize();\n\
577 const std::string name("secp256r1");\n\
578 const Botan::OID oid(Botan::OIDS::lookup(name));\n\
579 const Botan::EC_Group ecg(oid);\n\
581 #if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,11,0)\n\
582 const std::vector<Botan::byte> der =\n\
583 ecg.DER_encode(Botan::EC_DOMPAR_ENC_OID);\n\
585 const Botan::SecureVector<Botan::byte> der =\n\
586 ecg.DER_encode(Botan::EC_DOMPAR_ENC_OID);\n\
594 command = ["cl", "/nologo", "/MD", "/I", inc, "testecc.cpp", lib]
595 command.extend(system_libs)
596 subprocess.check_output(command, stderr=subprocess.STDOUT)
597 if not os.path.exists(".\\testecc.exe"):
598 print("can't create .\\testecc.exe", file=sys.stderr)
600 if subprocess.call(".\\testecc.exe") != 0:
601 print("can't find P256: upgrade to Botan >= 1.10.6", file=sys.stderr)
607 print("checking Botan GOST support")
608 testfile = open("testgost.cpp", "w")
610 #include <botan/init.h>\n\
611 #include <botan/gost_3410.h>\n\
612 #include <botan/oids.h>\n\
613 #include <botan/version.h>\n\
615 Botan::LibraryInitializer::initialize();\n\
616 const std::string name("gost_256A");\n\
617 const Botan::OID oid(Botan::OIDS::lookup(name));\n\
618 const Botan::EC_Group ecg(oid);\n\
620 #if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,11,0)\n\
621 const std::vector<Botan::byte> der =\n\
622 ecg.DER_encode(Botan::EC_DOMPAR_ENC_OID);\n\
624 const Botan::SecureVector<Botan::byte> der =\n\
625 ecg.DER_encode(Botan::EC_DOMPAR_ENC_OID);\n\
633 command = ["cl", "/nologo", "/MD", "/I", inc, "testgost.cpp", lib]
634 command.extend(system_libs)
635 subprocess.check_output(command, stderr=subprocess.STDOUT)
636 if not os.path.exists(".\\testgost.exe"):
637 print("can't create .\\testgost.exe", file=sys.stderr)
639 if subprocess.call(".\\testgost.exe") != 0:
640 print("can't find GOST: upgrade to Botan >= 1.10.6", file=sys.stderr)
643 # no check for Botan RFC3394 support
644 condvals["RFC3394"] = True
646 # Botan RFC5649 support
648 print("checking Botan RFC5649 support")
649 testfile = open("testrfc5649.cpp", "w")
651 #include <botan/botan.h>\n\
652 #include <botan/rfc3394.h>\n\
653 #include <botan/version.h>\n\
654 using namespace Botan;\n\
656 #if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,11,0)\n\
657 secure_vector<byte> key(10);\n\
658 SymmetricKey kek("AABB");\n\
659 secure_vector<byte> x = rfc5649_keywrap(key, kek);\n\
661 SecureVector<byte> key(10);\n\
662 SymmetricKey kek("AABB");\n\
663 Algorithm_Factory& af = global_state().algorithm_factory();\n\
664 SecureVector<byte> x = rfc5649_keywrap(key, kek, af);\n\
669 command = ["cl", "/nologo", "/MD", "/EHsc","/I", inc, "testrfc5649.cpp", lib]
670 command.extend(system_libs)
671 subprocess.call(command)
672 if os.path.exists(".\\testrfc5649.exe"):
674 print("Found AES key wrap with pad")
675 condvals["RFC5649"] = True
678 print("can't compile Botan AES key wrap with pad")
680 # Botan GNU MP support
681 if botan_version_major == 1 and botan_version_minor == 10:
683 print("checking Botan GNU MP support")
684 testfile = open("testgnump.cpp", "w")
686 #include <botan/build.h>\n\
688 #ifndef BOTAN_HAS_ENGINE_GNU_MP\n\
689 #error "No GNU MP support";\n\
693 command = ["cl", "/nologo", "/MD", "/I", inc, "testgnump.cpp", lib]
694 command.extend(system_libs)
695 subprocess.call(command)
696 if os.path.exists(".\\testgnump.exe"):
698 print("Botan GNU MP is supported")
701 print("Botan GNU MP is not supported")
703 # Botan raw PSS support
705 print("checking Botan raw PSS support")
706 testfile = open("testrawpss.cpp", "w")
708 #include <botan/botan.h>\n\
709 #include <botan/version.h>\n\
711 #if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(2,3,0)\n\
717 command = ["cl", "/nologo", "/MD", "/I", inc, "testrawpss.cpp", lib]
718 command.extend(system_libs)
719 subprocess.check_output(command, stderr=subprocess.STDOUT)
720 if not os.path.exists(".\\testrawpss.exe"):
722 print("can't create .\\testrawpss.exe", file=sys.stderr)
724 if subprocess.call(".\\testrawpss.exe") != 0:
726 print("can't find raw PSS: upgrade to Botan >= 2.3.0", file=sys.stderr)
728 condvals["RAWPSS"] = True
732 condvals["OPENSSL"] = True
733 varvals["EXTRALIBS"] = "crypt32.lib;ws2_32.lib;"
734 openssl_path = os.path.abspath(openssl_path)
735 openssl_inc = os.path.join(openssl_path, "include")
736 if not os.path.exists(os.path.join(openssl_inc, "openssl\\ssl.h")):
737 print("can't find OpenSSL headers", file=sys.stderr)
739 varvals["INCLUDEPATH"] = openssl_inc
740 openssl_lib = os.path.join(openssl_path, "lib")
741 openssl_lib_name = ""
743 if os.path.exists(os.path.join(openssl_lib, "libeay32.lib")):
744 openssl_lib_name = "libeay32.lib"
745 openssl_lib_dll = "bin\\libeay32.dll"
746 elif os.path.exists(os.path.join(openssl_lib, "libeaycompat32.lib")):
747 openssl_lib_name = "libeaycompat32.lib"
748 openssl_lib_dll = "bin\\libeaycompat32.dll"
749 elif os.path.exists(os.path.join(openssl_lib, "libcrypto.lib")):
750 openssl_lib_name = "libcrypto.lib"
752 openssl_lib_dll = "bin\\libcrypto-1_1.dll"
754 openssl_lib_dll = "bin\\libcrypto-1_1-x64.dll"
757 print("can't find OpenSSL library", file=sys.stderr)
759 openssl_dll = os.path.join(openssl_path,openssl_lib_dll)
760 varvals["LIBPATH"] = openssl_lib
761 varvals["LIBNAME"] = openssl_lib_name
762 varvals["DLLPATH"] = openssl_dll
764 debug_openssl_path = os.path.abspath(debug_openssl_path)
765 varvals["DEBUGDLLPATH"] = \
766 os.path.join(debug_openssl_path, openssl_lib_dll)
767 debug_openssl_inc = os.path.join(debug_openssl_path, "include")
768 if not os.path.exists(os.path.join(debug_openssl_inc,
770 print("can't find debug OpenSSL headers", file=sys.stderr)
772 varvals["DEBUGINCPATH"] = debug_openssl_inc
773 debug_openssl_lib = os.path.join(debug_openssl_path, "lib")
774 if not os.path.exists(os.path.join(debug_openssl_lib,
776 print("can't find debug OpenSSL library", file=sys.stderr)
778 varvals["DEBUGLIBPATH"] = debug_openssl_lib
780 varvals["DEBUGDLLPATH"] = varvals["DLLPATH"]
781 varvals["DEBUGINCPATH"] = varvals["INCLUDEPATH"]
782 varvals["DEBUGLIBPATH"] = varvals["LIBPATH"]
786 print("checking OpenSSL")
788 if os.path.exists(openssl_dll):
789 subprocess.call(["copy", openssl_dll, "."], shell=True)
791 system_libs = ["user32.lib", "advapi32.lib", "gdi32.lib", "crypt32.lib", "ws2_32.lib"]
793 lib = os.path.join(openssl_lib, openssl_lib_name)
794 testfile = open("testossl.c", "w")
796 #include <openssl/err.h>\n\
798 ERR_clear_error();\n\
802 command = ["cl", "/nologo", "/MD", "/I", inc, "testossl.c", lib]
803 command.extend(system_libs)
804 subprocess.check_output(command, stderr=subprocess.STDOUT)
805 if not os.path.exists(".\\testossl.exe"):
806 print("can't create .\\testossl.exe", file=sys.stderr)
808 if subprocess.call(".\\testossl.exe") != 0:
809 print("OpenSSL test failed", file=sys.stderr)
814 print("checking OpenSSL version")
815 testfile = open("testosslv.c", "w")
817 #include <openssl/ssl.h>\n\
818 #include <openssl/opensslv.h>\n\
820 #ifndef OPENSSL_VERSION_NUMBER\n\
823 #if OPENSSL_VERSION_NUMBER >= 0x010000000L\n\
830 command = ["cl", "/nologo", "/MD", "/I", inc, "testosslv.c", lib]
831 command.extend(system_libs)
832 subprocess.check_output(command, stderr=subprocess.STDOUT)
833 if not os.path.exists(".\\testosslv.exe"):
834 print("can't create .\\testosslv.exe", file=sys.stderr)
836 if subprocess.call(".\\testosslv.exe") != 0:
837 print("OpenSLL version too old (1.0.0 or later required)", file=sys.stderr)
840 # OpenSSL ECC support
843 print("checking OpenSSL ECC support")
844 testfile = open("testecc.c", "w")
846 #include <openssl/ecdsa.h>\n\
847 #include <openssl/objects.h>\n\
849 EC_KEY *ec256, *ec384, *ec521;\n\
850 ec256 = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1);\n\
851 ec384 = EC_KEY_new_by_curve_name(NID_secp384r1);\n\
852 ec521 = EC_KEY_new_by_curve_name(NID_secp521r1);\n\
853 if (ec256 == NULL || ec384 == NULL || ec521 == NULL)\n\
858 command = ["cl", "/nologo", "/MD", "/I", inc, "testecc.c", lib]
859 command.extend(system_libs)
860 subprocess.check_output(command, stderr=subprocess.STDOUT)
861 if not os.path.exists(".\\testecc.exe"):
862 print("can't create .\\testecc.exe", file=sys.stderr)
864 if subprocess.call(".\\testecc.exe") != 0:
865 print("can't find P256, P384, or P521: no ECC support", file=sys.stderr)
868 # OpenSSL GOST support
871 print("checking OpenSSL GOST support")
872 testfile = open("testgost.c", "w")
874 #include <openssl/conf.h>\n\
875 #include <openssl/engine.h>\n\
876 #include <openssl/crypto.h>\n\
877 #include <openssl/opensslv.h>\n\
880 const EVP_MD* EVP_GOST_34_11;\n\
881 OpenSSL_add_all_algorithms();\n\
882 #if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)\n\
883 ENGINE_load_builtin_engines();\n\
885 OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_ALL_BUILTIN | OPENSSL_INIT_LOAD_CONFIG, NULL);\n\
887 eg = ENGINE_by_id("gost");\n\
890 if (ENGINE_init(eg) <= 0)\n\
892 EVP_GOST_34_11 = ENGINE_get_digest(eg, NID_id_GostR3411_94);\n\
893 if (EVP_GOST_34_11 == NULL)\n\
895 if (ENGINE_register_pkey_asn1_meths(eg) <= 0)\n\
897 if (ENGINE_ctrl_cmd_string(eg, "CRYPT_PARAMS",\n\
898 "id-Gost28147-89-CryptoPro-A-ParamSet", 0) <= 0)\n\
903 command = ["cl", "/nologo", "/MD", "/I", inc, "testgost.c", lib]
904 command.extend(system_libs)
905 subprocess.check_output(command, stderr=subprocess.STDOUT)
906 if not os.path.exists(".\\testgost.exe"):
907 print("can't create .\\testgost.exe", file=sys.stderr)
909 if subprocess.call(".\\testgost.exe") != 0:
910 print("can't find GOST: no GOST support", file=sys.stderr)
913 # OpenSSL EVP interface for AES key wrapping (aka RFC 3394)
915 print("checking OpenSSL EVP interface for AES key wrapping")
916 testfile = open("testrfc3394.c", "w")
918 #include <openssl/evp.h>\n\
920 EVP_aes_128_wrap();\n\
924 command = ["cl", "/nologo", "/MD", "/I", inc, "testrfc3394.c", lib]
925 command.extend(system_libs)
926 subprocess.call(command)
927 if os.path.exists(".\\testrfc3394.exe"):
929 print("RFC 3394 is supported")
930 condvals["RFC3394"] = True
933 print("can't compile OpenSSL RFC 3394")
935 # OpenSSL EVP interface for AES key wrap with pad (aka RFC 5649)
937 print("checking OpenSSL EVP interface for AES key wrapping with pad")
938 testfile = open("testrfc5649.c", "w")
940 #include <openssl/evp.h>\n\
942 EVP_aes_128_wrap_pad();\n\
946 command = ["cl", "/nologo", "/MD", "/I", inc, "testrfc5649.c", lib]
947 command.extend(system_libs)
948 subprocess.call(command)
949 if os.path.exists(".\\testrfc5649.exe"):
951 print("RFC 5649 is supported")
952 condvals["RFC5649"] = True
955 print("can't compile OpenSSL RFC 5649")
957 # no check for OpenSSL raw PSS support
958 condvals["RAWPSS"] = True
959 # no check for OpenSSL AES GCM
960 condvals["AESGCM"] = True
964 condvals["TESTS"] = True
965 cppunit_path = os.path.abspath(cppunit_path)
966 cppunit_inc = os.path.join(cppunit_path, "include")
967 if not os.path.exists(os.path.join(cppunit_inc, "cppunit\\Test.h")):
968 print("can't find CppUnit headers", file=sys.stderr)
970 varvals["CUINCPATH"] = cppunit_inc
971 cppunit_lib = os.path.join(cppunit_path, "lib")
972 if not os.path.exists(os.path.join(cppunit_lib, "cppunit.lib")):
973 cppunit_lib = cppunit_path
974 if not os.path.exists(os.path.join(cppunit_lib, "cppunit.lib")):
975 print("can't find CppUnit library", file=sys.stderr)
978 if not os.path.exists(os.path.join(cppunit_lib, "cppunitd.lib")):
979 print("can't find debug CppUnit library", file=sys.stderr)
981 varvals["CULIBPATH"] = cppunit_lib
985 condvals["NONPAGE"] = True
989 if re.search(r' ', path):
990 return '"' + path + '"'
994 def setupfile(filename):
995 """setup files with condition stacks and variable expansions"""
1000 filein = open(filename + ".in", "r")
1001 fileout = open(filename, "w")
1004 line = line.rstrip("\r\n")
1005 cif = re.match(r'@IF (.*)', line)
1008 passes.append(passing)
1010 if condvals.get(cond):
1016 celse = re.match(r'@ELSE (.*)', line)
1018 if cond != celse.group(1):
1019 raise SyntaxError("@ELSE " + celse.group(1) +
1020 " mismatch in " + filename)
1021 if condvals.get(cond):
1025 passing = passes[-1]
1029 cend = re.match(r'@END (.*)', line)
1031 if cond != cend.group(1):
1032 raise SyntaxError("@END " + cend.group(1) +
1033 " mismatch in " + filename)
1036 passing = passes.pop()
1043 vm = re.match(r'([^@]*)@([^@ ]*)@(.*)', line)
1045 if vm.group(2) in varnames:
1046 if varvals.get(vm.group(2)):
1047 val = kw(varvals[vm.group(2)])
1050 line = vm.group(1) + val + vm.group(3)
1053 raise SyntaxError("unknown control @" + vm.group(2) +
1056 print(line, file=fileout)
1058 print("Setting up " + filename)
1065 # no arguments -> usage
1080 dodetectvisualstudio()
1082 print("Build skipped. To build, this file needs to run from VS command prompt.")
1085 varvals["PLATFORMTOOLSET"] = toolset
1087 # status before config
1090 print("keep: enabled")
1092 print("keep: disabled")
1094 print("64bit: enabled")
1096 print("64bit: disabled")
1098 print("debug: enabled")
1100 print("debug: disabled")
1102 print("ecc: enabled")
1104 print("ecc: disabled")
1106 print("gost: enabled")
1108 print("gost: disabled")
1109 if enable_non_paged:
1110 print("non-paged-memory: enabled")
1112 print("non-paged-memory: disabled")
1113 print("crypto-backend: " + crypto_backend)
1114 if crypto_backend == "botan":
1115 print("botan-path: " + botan_path)
1117 print("debug-botan-path: " + debug_botan_path)
1119 print("openssl-path: " + openssl_path)
1121 print("debug-openssl-path: " + debug_openssl_path)
1123 print("cppunit-path: " + cppunit_path)
1124 print("toolset: "+toolset)
1129 # status after config
1131 print("Configuration Status")
1132 print("\tconditions:")
1133 for name in condnames:
1134 if condvals.get(name):
1135 print("\t\t" + name + " is true")
1137 print("\t\t" + name + " is false")
1138 print("\tsubstitutions:")
1139 for name in varnames:
1140 if varvals.get(name):
1141 print("\t\t" + name + '-> "' + varvals[name] + '"')
1144 for filename in filelist:
1151 print("Configured.")
1156 # Notes: Unix configure.ac options
1157 # --enable-64bit supported
1158 # --enable-ecc supported
1159 # --enable-gost supported
1160 # --enable-non-paged-memory supported
1161 # --enable-visibility (enforced by DLLs)
1162 # --with-crypto-backend supported
1163 # --with-botan supported (Release and Debug)
1164 # --with-openssl supported (Release and Debug)
1165 # --with-migrate (useless as SoftHSMv1 is not supported)
1166 # --with-objectstore-backend-db (TODO)
1167 # --with-sqlite3 (useless until objectstore backend can be chosen)