diff --git a/common/randombytes.c b/common/randombytes.c index 4e0af552..fcb44922 100644 --- a/common/randombytes.c +++ b/common/randombytes.c @@ -33,8 +33,8 @@ THE SOFTWARE. #if defined(_WIN32) /* Windows */ -#include /* CryptAcquireContext, CryptGenRandom */ #include +#include /* CryptAcquireContext, CryptGenRandom */ #endif /* defined(_WIN32) */ #if defined(__linux__) diff --git a/scripts_windows/build_all.bat b/scripts_windows/build_all.bat index 5b3b3bb2..39393ce1 100644 --- a/scripts_windows/build_all.bat +++ b/scripts_windows/build_all.bat @@ -1,19 +1,44 @@ @ECHO OFF -SETLOCAL +SETLOCAL EnableDelayedExpansion SET EL=0 REM CALL "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat" REM IF ERRORLEVEL 1 SET EL=1 +:: Build the library files for individual implementations FOR /D %%K IN (crypto_kem\* crypto_sign\*) DO ( FOR /D %%L IN (%%K\*) DO ( - cd %%L + CD %%L nmake /f Makefile.Microsoft_nmake clean IF ERRORLEVEL 1 SET EL=2 nmake /f Makefile.Microsoft_nmake IF ERRORLEVEL 1 SET EL=3 - cd ..\..\.. + CD ..\..\.. ) ) +:: Build and run the functional tests and test vector programs for each implementation +FOR %%T IN (kem sign) DO ( + CD crypto_%%T + FOR /D %%K IN (*) DO ( + SET schemeuppercase=%%K + FOR %%B IN (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) DO SET "schemeuppercase=!schemeuppercase:%%B=%%B!" + SET "schemeuppercase=!schemeuppercase:-=!" + CD %%K + FOR /D %%L IN (*) DO ( + CD ..\..\test + nmake /f Makefile.Microsoft_nmake /E TYPE=%%T SCHEME=%%K SCHEME_UPPERCASE=!schemeuppercase! IMPLEMENTATION=%%L clean + IF ERRORLEVEL 1 SET EL=4 + nmake /f Makefile.Microsoft_nmake /E TYPE=%%T SCHEME=%%K SCHEME_UPPERCASE=!schemeuppercase! IMPLEMENTATION=%%L + IF ERRORLEVEL 1 SET EL=5 + CD .. + bin\functest_%%K_%%L + IF ERRORLEVEL 1 SET EL=6 + CD crypto_%%T\%%K + ) + CD .. + ) + CD .. +) + EXIT /b %EL% diff --git a/test/Makefile.Microsoft_nmake b/test/Makefile.Microsoft_nmake new file mode 100644 index 00000000..bf86a0cc --- /dev/null +++ b/test/Makefile.Microsoft_nmake @@ -0,0 +1,41 @@ +# This Makefile can be used with Microsoft Visual Studio's nmake using the command: +# nmake /f Makefile.Microsoft_nmake + +# override as desired +TYPE=kem +SCHEME=kyber768 +SCHEME_UPPERCASE=KYBER768 +IMPLEMENTATION=clean + +SCHEME_DIR=..\crypto_$(TYPE)\$(SCHEME)\$(IMPLEMENTATION) + +COMMON_DIR=..\common +COMMON_OBJECTS=$(COMMON_DIR)\fips202.obj $(COMMON_DIR)\sha2.obj +COMMON_OBJECTS_NOPATH=fips202.obj sha2.obj + +DEST_DIR=..\bin + +CFLAGS=/I $(COMMON_DIR) /W1 /WX # FIXME: Should be /W4 but many compiler warnings in common files + +all: $(DEST_DIR)\functest_$(SCHEME)_$(IMPLEMENTATION).EXE $(DEST_DIR)\testvectors_$(SCHEME)_$(IMPLEMENTATION).EXE + +rebuild-scheme: + cd $(SCHEME_DIR) + nmake /f Makefile.Microsoft_nmake clean + nmake /f Makefile.Microsoft_nmake + cd ..\..\..\test + +$(DEST_DIR)\functest_$(SCHEME)_$(IMPLEMENTATION).EXE: rebuild-scheme $(COMMON_OBJECTS) $(COMMON_DIR)\randombytes.obj + -MKDIR $(DEST_DIR) + $(CC) /c crypto_$(TYPE)\functest.c $(CFLAGS) /I $(SCHEME_DIR) /DPQCLEAN_NAMESPACE=PQCLEAN_$(SCHEME_UPPERCASE) + LINK.EXE /OUT:$@ functest.obj $(COMMON_OBJECTS_NOPATH) randombytes.obj $(SCHEME_DIR)\lib$(SCHEME)_$(IMPLEMENTATION).lib Advapi32.lib + +$(DEST_DIR)\testvectors_$(SCHEME)_$(IMPLEMENTATION).EXE: rebuild-scheme $(COMMON_OBJECTS) $(COMMON_DIR)\notrandombytes.obj + -MKDIR $(DEST_DIR) + $(CC) /c crypto_$(TYPE)\testvectors.c $(CFLAGS) /I $(SCHEME_DIR) /DPQCLEAN_NAMESPACE=PQCLEAN_$(SCHEME_UPPERCASE) + LINK.EXE /OUT:$@ testvectors.obj $(COMMON_OBJECTS_NOPATH) notrandombytes.obj $(SCHEME_DIR)\lib$(SCHEME)_$(IMPLEMENTATION).lib + +clean: + -DEL functest.obj testvectors.obj + -DEL $(COMMON_OBJECTS_NOPATH) randombytes.obj notrandombytes.obj + -DEL $(DEST_DIR)\functest_$(SCHEME)_$(IMPLEMENTATION).EXE