1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
|
#
# Copyright (c) 2017-2018, Intel Corporation
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of Intel Corporation nor the names of its contributors
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# Available build options:
# DEBUG=y - this option will produce library fit for debugging
# 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)
!if !defined(SHARED)
SHARED = y
!endif
# Available installation options:
# PREFIX=<path> - path to install the library (c:\program files\ is default)
!if !defined(PREFIX)
PREFIX = c:\Program Files
!endif
INSTDIR = $(PREFIX)\intel-ipsec-mb
LIBBASE = libIPSec_MB
!if "$(SHARED)" == "y"
LIBNAME = $(LIBBASE).dll
!else
LIBNAME = $(LIBBASE).lib
!endif
OBJ_DIR = obj
!ifdef DEBUG
DCFLAGS = /Od /DDEBUG /Z7
DAFLAGS = -gcv8
DLFLAGS = /DEBUG
!else
DCFLAGS = /O2 /Oi
DAFLAGS =
DLFLAGS = /RELEASE
!endif
CC = cl
CFLAGS = $(EXTRA_CFLAGS) $(DCFLAGS) /I. /Iinclude \
/nologo /Y- /W3 /WX- /Gm- /fp:precise /EHsc
LIB_TOOL = lib
LIBFLAGS = /nologo /machine:X64 /nodefaultlib
LINK_TOOL = link
LINKFLAGS = $(DLFLAGS) /nologo /machine:X64
AS = nasm
AFLAGS = $(DAFLAGS) -fwin64 -Xvc -DWIN_ABI -Iinclude/ -I./ -Iavx/ -Iavx2/ -Iavx512/ -Isse/
lib_objs1 = \
$(OBJ_DIR)\aes128_cbc_dec_by4_sse.obj \
$(OBJ_DIR)\aes128_cbc_dec_by8_avx.obj \
$(OBJ_DIR)\aes128_cntr_by4_sse.obj \
$(OBJ_DIR)\aes128_cntr_by8_avx.obj \
$(OBJ_DIR)\aes128_ecbenc_x3.obj \
$(OBJ_DIR)\aes192_cbc_dec_by4_sse.obj \
$(OBJ_DIR)\aes192_cbc_dec_by8_avx.obj \
$(OBJ_DIR)\aes192_cntr_by4_sse.obj \
$(OBJ_DIR)\aes192_cntr_by8_avx.obj \
$(OBJ_DIR)\aes256_cbc_dec_by4_sse.obj \
$(OBJ_DIR)\aes256_cbc_dec_by8_avx.obj \
$(OBJ_DIR)\aes256_cntr_by4_sse.obj \
$(OBJ_DIR)\aes256_cntr_by8_avx.obj \
$(OBJ_DIR)\aes_cfb_128_sse.obj \
$(OBJ_DIR)\aes_cfb_128_avx.obj \
$(OBJ_DIR)\aes128_cbc_mac_x4.obj \
$(OBJ_DIR)\aes128_cbc_mac_x8.obj \
$(OBJ_DIR)\aes_cbc_enc_128_x4.obj \
$(OBJ_DIR)\aes_cbc_enc_128_x8.obj \
$(OBJ_DIR)\aes_cbc_enc_192_x4.obj \
$(OBJ_DIR)\aes_cbc_enc_192_x8.obj \
$(OBJ_DIR)\aes_cbc_enc_256_x4.obj \
$(OBJ_DIR)\aes_cbc_enc_256_x8.obj \
$(OBJ_DIR)\aes_keyexp_128.obj \
$(OBJ_DIR)\aes_keyexp_192.obj \
$(OBJ_DIR)\aes_keyexp_256.obj \
$(OBJ_DIR)\aes_cmac_subkey_gen.obj \
$(OBJ_DIR)\aes_xcbc_mac_128_x4.obj \
$(OBJ_DIR)\aes_xcbc_mac_128_x8.obj \
$(OBJ_DIR)\md5_x4x2_avx.obj \
$(OBJ_DIR)\md5_x4x2_sse.obj \
$(OBJ_DIR)\md5_x8x2_avx2.obj \
$(OBJ_DIR)\save_xmms.obj \
$(OBJ_DIR)\sha1_mult_avx.obj \
$(OBJ_DIR)\sha1_mult_sse.obj \
$(OBJ_DIR)\sha1_ni_x2_sse.obj \
$(OBJ_DIR)\sha1_one_block_avx.obj \
$(OBJ_DIR)\sha1_one_block_sse.obj \
$(OBJ_DIR)\sha1_x8_avx2.obj \
$(OBJ_DIR)\sha1_x16_avx512.obj \
$(OBJ_DIR)\sha224_one_block_avx.obj \
$(OBJ_DIR)\sha224_one_block_sse.obj \
$(OBJ_DIR)\sha256_oct_avx2.obj \
$(OBJ_DIR)\sha256_one_block_avx.obj \
$(OBJ_DIR)\sha256_one_block_sse.obj \
$(OBJ_DIR)\sha256_ni_x2_sse.obj \
$(OBJ_DIR)\sha256_x16_avx512.obj \
$(OBJ_DIR)\sha384_one_block_avx.obj \
$(OBJ_DIR)\sha384_one_block_sse.obj \
$(OBJ_DIR)\sha512_one_block_avx.obj \
$(OBJ_DIR)\sha512_one_block_sse.obj \
$(OBJ_DIR)\sha512_x2_avx.obj \
$(OBJ_DIR)\sha512_x2_sse.obj \
$(OBJ_DIR)\sha512_x4_avx2.obj \
$(OBJ_DIR)\sha512_x8_avx512.obj \
$(OBJ_DIR)\sha_256_mult_avx.obj \
$(OBJ_DIR)\sha_256_mult_sse.obj \
$(OBJ_DIR)\aes_xcbc_expand_key.obj \
$(OBJ_DIR)\md5_one_block.obj \
$(OBJ_DIR)\des_key.obj \
$(OBJ_DIR)\des_basic.obj \
$(OBJ_DIR)\des_x16_avx512.obj
lib_objs2 = \
$(OBJ_DIR)\mb_mgr_aes192_flush_avx.obj \
$(OBJ_DIR)\mb_mgr_aes192_flush_sse.obj \
$(OBJ_DIR)\mb_mgr_aes192_submit_avx.obj \
$(OBJ_DIR)\mb_mgr_aes192_submit_sse.obj \
$(OBJ_DIR)\mb_mgr_aes256_flush_avx.obj \
$(OBJ_DIR)\mb_mgr_aes256_flush_sse.obj \
$(OBJ_DIR)\mb_mgr_aes256_submit_avx.obj \
$(OBJ_DIR)\mb_mgr_aes256_submit_sse.obj \
$(OBJ_DIR)\mb_mgr_aes_flush_avx.obj \
$(OBJ_DIR)\mb_mgr_aes_flush_sse.obj \
$(OBJ_DIR)\mb_mgr_aes_submit_avx.obj \
$(OBJ_DIR)\mb_mgr_aes_submit_sse.obj \
$(OBJ_DIR)\mb_mgr_aes_xcbc_flush_avx.obj \
$(OBJ_DIR)\mb_mgr_aes_xcbc_flush_sse.obj \
$(OBJ_DIR)\mb_mgr_aes_xcbc_submit_avx.obj \
$(OBJ_DIR)\mb_mgr_aes_xcbc_submit_sse.obj \
$(OBJ_DIR)\mb_mgr_hmac_flush_avx.obj \
$(OBJ_DIR)\mb_mgr_hmac_flush_avx2.obj \
$(OBJ_DIR)\mb_mgr_hmac_flush_sse.obj \
$(OBJ_DIR)\mb_mgr_hmac_flush_ni_sse.obj \
$(OBJ_DIR)\mb_mgr_hmac_flush_avx512.obj \
$(OBJ_DIR)\mb_mgr_hmac_md5_flush_avx.obj \
$(OBJ_DIR)\mb_mgr_hmac_md5_flush_avx2.obj \
$(OBJ_DIR)\mb_mgr_hmac_md5_flush_sse.obj \
$(OBJ_DIR)\mb_mgr_hmac_md5_submit_avx.obj \
$(OBJ_DIR)\mb_mgr_hmac_md5_submit_avx2.obj \
$(OBJ_DIR)\mb_mgr_hmac_md5_submit_sse.obj \
$(OBJ_DIR)\mb_mgr_hmac_sha_224_flush_avx.obj \
$(OBJ_DIR)\mb_mgr_hmac_sha_224_flush_avx2.obj \
$(OBJ_DIR)\mb_mgr_hmac_sha_224_flush_avx512.obj \
$(OBJ_DIR)\mb_mgr_hmac_sha_224_flush_sse.obj \
$(OBJ_DIR)\mb_mgr_hmac_sha_224_flush_ni_sse.obj \
$(OBJ_DIR)\mb_mgr_hmac_sha_224_submit_avx.obj \
$(OBJ_DIR)\mb_mgr_hmac_sha_224_submit_avx2.obj \
$(OBJ_DIR)\mb_mgr_hmac_sha_224_submit_avx512.obj \
$(OBJ_DIR)\mb_mgr_hmac_sha_224_submit_sse.obj \
$(OBJ_DIR)\mb_mgr_hmac_sha_224_submit_ni_sse.obj \
$(OBJ_DIR)\mb_mgr_hmac_sha_256_flush_avx.obj \
$(OBJ_DIR)\mb_mgr_hmac_sha_256_flush_avx2.obj \
$(OBJ_DIR)\mb_mgr_hmac_sha_256_flush_avx512.obj \
$(OBJ_DIR)\mb_mgr_hmac_sha_256_flush_sse.obj \
$(OBJ_DIR)\mb_mgr_hmac_sha_256_flush_ni_sse.obj \
$(OBJ_DIR)\mb_mgr_hmac_sha_256_submit_avx.obj \
$(OBJ_DIR)\mb_mgr_hmac_sha_256_submit_avx2.obj \
$(OBJ_DIR)\mb_mgr_hmac_sha_256_submit_avx512.obj \
$(OBJ_DIR)\mb_mgr_hmac_sha_256_submit_sse.obj \
$(OBJ_DIR)\mb_mgr_hmac_sha_256_submit_ni_sse.obj \
$(OBJ_DIR)\mb_mgr_hmac_sha_384_flush_avx.obj \
$(OBJ_DIR)\mb_mgr_hmac_sha_384_flush_avx2.obj \
$(OBJ_DIR)\mb_mgr_hmac_sha_384_flush_avx512.obj \
$(OBJ_DIR)\mb_mgr_hmac_sha_384_flush_sse.obj \
$(OBJ_DIR)\mb_mgr_hmac_sha_384_submit_avx.obj \
$(OBJ_DIR)\mb_mgr_hmac_sha_384_submit_avx2.obj \
$(OBJ_DIR)\mb_mgr_hmac_sha_384_submit_avx512.obj \
$(OBJ_DIR)\mb_mgr_hmac_sha_384_submit_sse.obj \
$(OBJ_DIR)\mb_mgr_hmac_sha_512_flush_avx.obj \
$(OBJ_DIR)\mb_mgr_hmac_sha_512_flush_avx2.obj \
$(OBJ_DIR)\mb_mgr_hmac_sha_512_flush_avx512.obj \
$(OBJ_DIR)\mb_mgr_hmac_sha_512_flush_sse.obj \
$(OBJ_DIR)\mb_mgr_hmac_sha_512_submit_avx.obj \
$(OBJ_DIR)\mb_mgr_hmac_sha_512_submit_avx2.obj \
$(OBJ_DIR)\mb_mgr_hmac_sha_512_submit_avx512.obj \
$(OBJ_DIR)\mb_mgr_hmac_sha_512_submit_sse.obj \
$(OBJ_DIR)\mb_mgr_hmac_submit_avx.obj \
$(OBJ_DIR)\mb_mgr_hmac_submit_avx2.obj \
$(OBJ_DIR)\mb_mgr_hmac_submit_sse.obj \
$(OBJ_DIR)\mb_mgr_hmac_submit_ni_sse.obj \
$(OBJ_DIR)\mb_mgr_hmac_submit_avx512.obj \
$(OBJ_DIR)\mb_mgr_avx.obj \
$(OBJ_DIR)\mb_mgr_avx2.obj \
$(OBJ_DIR)\mb_mgr_avx512.obj \
$(OBJ_DIR)\mb_mgr_des_avx512.obj \
$(OBJ_DIR)\mb_mgr_sse.obj \
$(OBJ_DIR)\alloc.obj
gcm_objs = \
$(OBJ_DIR)\gcm128_sse.obj \
$(OBJ_DIR)\gcm128_avx_gen2.obj \
$(OBJ_DIR)\gcm128_avx_gen4.obj \
$(OBJ_DIR)\gcm192_sse.obj \
$(OBJ_DIR)\gcm192_avx_gen2.obj \
$(OBJ_DIR)\gcm192_avx_gen4.obj \
$(OBJ_DIR)\gcm256_sse.obj \
$(OBJ_DIR)\gcm256_avx_gen2.obj \
$(OBJ_DIR)\gcm256_avx_gen4.obj
!ifdef NO_GCM
all_objs = $(lib_objs1) $(lib_objs2)
CFLAGS = $(CFLAGS) -DNO_GCM
!else
all_objs = $(lib_objs1) $(lib_objs2) $(gcm_objs)
!endif
all: $(LIBNAME)
$(LIBNAME): $(all_objs)
!if "$(SHARED)" == "y"
$(LINK_TOOL) $(LINKFLAGS) /DLL /DEF:libIPSec_MB.def /OUT:$@ $(all_objs)
!else
$(LIB_TOOL) $(LIBFLAGS) /out:$@ $(all_objs)
!endif
$(all_objs): $(OBJ_DIR)
{.\}.c{$(OBJ_DIR)}.obj:
$(CC) /Fo$@ /c $(CFLAGS) $<
{.\}.asm{$(OBJ_DIR)}.obj:
$(AS) -o $@ $(AFLAGS) $<
{sse\}.c{$(OBJ_DIR)}.obj:
$(CC) /Fo$@ /c $(CFLAGS) $<
{sse\}.asm{$(OBJ_DIR)}.obj:
$(AS) -o $@ $(AFLAGS) $<
{avx\}.c{$(OBJ_DIR)}.obj:
$(CC) /Fo$@ /c $(CFLAGS) $<
{avx\}.asm{$(OBJ_DIR)}.obj:
$(AS) -o $@ $(AFLAGS) $<
{avx2\}.c{$(OBJ_DIR)}.obj:
$(CC) /Fo$@ /c $(CFLAGS) $<
{avx2\}.asm{$(OBJ_DIR)}.obj:
$(AS) -o $@ $(AFLAGS) $<
{avx512\}.c{$(OBJ_DIR)}.obj:
$(CC) /Fo$@ /c $(CFLAGS) $<
{avx512\}.asm{$(OBJ_DIR)}.obj:
$(AS) -o $@ $(AFLAGS) $<
{include\}.asm{$(OBJ_DIR)}.obj:
$(AS) -o $@ $(AFLAGS) $<
$(OBJ_DIR):
mkdir $(OBJ_DIR)
clean:
-del /q $(lib_objs1)
-del /q $(lib_objs2)
-del /q $(gcm_objs)
-del /q $(LIBNAME).*
install:
-md "$(INSTDIR)"
-copy /Y /V /A $(LIBBASE).def "$(INSTDIR)"
-copy /Y /V /B $(LIBBASE).exp "$(INSTDIR)"
-copy /Y /V /B $(LIBBASE).lib "$(INSTDIR)"
-copy /Y /V /A intel-ipsec-mb.h "$(INSTDIR)"
!if "$(SHARED)" == "y"
-copy /Y /V /B $(LIBBASE).dll "$(INSTDIR)"
-copy /Y /V /B $(LIBBASE).dll "%windir%\system32"
!endif
uninstall:
!if "$(SHARED)" == "y"
-del /Q "%windir%\system32\$(LIBBASE).dll"
-del /Q "$(INSTDIR)\$(LIBBASE).dll"
!endif
-del /Q "$(INSTDIR)\$(LIBBASE).def"
-del /Q "$(INSTDIR)\$(LIBBASE).exp"
-del /Q "$(INSTDIR)\$(LIBBASE).lib"
-del /Q "$(INSTDIR)\intel-ipsec-mb.h"
-rd "$(INSTDIR)"
|