Added safety options for Windows
As done for Linux, compilation options "SAFE_DATA" and "SAFE_PARAM"
are added to be used in the ZUC algoritm (will be expanded to other
algorithms in the future).
#
-# Copyright (c) 2017-2018, Intel Corporation
+# Copyright (c) 2017-2019, Intel Corporation
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# DEBUG=n - this option will produce library not fit for debugging (default)
# SHARED=y - this option will produce shared library (DLL) (default)
# SHARED=n - this option will produce static library (lib)
+# SAFE_DATA=y - this option will clear memory and registers containing
+# sensitive information (e.g. keys, IVs)
+# SAFE_PARAM=y - this option will add extra input parameter checks
!if !defined(SHARED)
SHARED = y
@@ -63,6 +66,14 @@ DAFLAGS =
DLFLAGS = /RELEASE
!endif
+!if "$(SAFE_DATA)" == "y"
+DCFLAGS = $(DCFLAGS) /DSAFE_DATA
+!endif
+
+!if "$(SAFE_PARAM)" == "y"
+DCFLAGS = $(DCFLAGS) /DSAFE_PARAM
+!endif
+
CC = cl
CFLAGS_ALL = $(EXTRA_CFLAGS) /I. /Iinclude /Ino-aesni \
/nologo /Y- /W3 /WX- /Gm- /fp:precise /EHsc
@@ -79,6 +90,15 @@ LINKFLAGS = $(DLFLAGS) /nologo /machine:X64
AS = nasm
AFLAGS = $(DAFLAGS) -fwin64 -Xvc -DWIN_ABI -Iinclude/ -I./ -Iavx/ -Iavx2/ -Iavx512/ -Isse/
+# warning messages
+
+SAFE_PARAM_MSG1=SAFE_PARAM option not set.
+SAFE_PARAM_MSG2=Input parameters will not be checked.
+SAFE_DATA_MSG1=SAFE_DATA option not set.
+SAFE_DATA_MSG2=Stack and registers containing sensitive information, \
+ such keys or IV will not be cleared \
+ at the end of function calls.
+
lib_objs1 = \
$(OBJ_DIR)\aes128_cbc_dec_by4_sse.obj \
$(OBJ_DIR)\aes128_cbc_dec_by4_sse_no_aesni.obj \
@@ -305,6 +325,12 @@ $(LIBNAME): $(all_objs)
!else
$(LIB_TOOL) $(LIBFLAGS) /out:$@ $(all_objs)
!endif
+!if "$(SAFE_PARAM)" != "y"
+ @echo NOTE: $(SAFE_PARAM_MSG1) $(SAFE_PARAM_MSG2)
+!endif
+!if "$(SAFE_DATA)" != "y"
+ @echo NOTE: $(SAFE_DATA_MSG1) $(SAFE_DATA_MSG2)
+!endif
$(all_objs): $(OBJ_DIR)
