;;
; Routine to do AES key expansion
-%include "os.asm"
+%include "include/os.asm"
%define NO_AESNI_RENAME
-%include "aesni_emu.inc"
+%include "include/aesni_emu.inc"
+%include "include/clear_regs.asm"
; Uses the f() function of the aeskeygenassist result
%macro key_expansion_256_sse 0
;
MKGLOBAL(aes_keyexp_256_sse,function,)
aes_keyexp_256_sse:
+
+%ifdef SAFE_PARAM
+ cmp KEY, 0
+ jz aes_keyexp_256_sse_return
+ cmp EXP_ENC_KEYS, 0
+ jz aes_keyexp_256_sse_return
+ cmp EXP_DEC_KEYS, 0
+ jz aes_keyexp_256_sse_return
+%endif
+
movdqu xmm1, [KEY] ; loading the AES key
movdqa [EXP_ENC_KEYS + 16*0], xmm1
movdqa [EXP_DEC_KEYS + 16*14], xmm1 ; Storing key in memory
movdqa [EXP_ENC_KEYS + 16*14], xmm1
movdqa [EXP_DEC_KEYS + 16*0], xmm1
- ret
+%ifdef SAFE_DATA
+ clear_scratch_gps_asm
+ clear_scratch_xmms_sse_asm
+%endif
+
+aes_keyexp_256_sse_return:
+ ret
MKGLOBAL(aes_keyexp_256_sse_no_aesni,function,)
aes_keyexp_256_sse_no_aesni:
+
+%ifdef SAFE_PARAM
+ cmp KEY, 0
+ jz aes_keyexp_256_sse_no_aesni_return
+ cmp EXP_ENC_KEYS, 0
+ jz aes_keyexp_256_sse_no_aesni_return
+ cmp EXP_DEC_KEYS, 0
+ jz aes_keyexp_256_sse_no_aesni_return
+%endif
+
movdqu xmm1, [KEY] ; loading the AES key
movdqa [EXP_ENC_KEYS + 16*0], xmm1
movdqa [EXP_DEC_KEYS + 16*14], xmm1 ; Storing key in memory
movdqa [EXP_ENC_KEYS + 16*14], xmm1
movdqa [EXP_DEC_KEYS + 16*0], xmm1
+%ifdef SAFE_DATA
+ clear_scratch_gps_asm
+ clear_scratch_xmms_sse_asm
+%endif
+
+aes_keyexp_256_sse_no_aesni_return:
ret
MKGLOBAL(aes_keyexp_256_avx,function,)
aes_keyexp_256_avx:
aes_keyexp_256_avx2:
aes_keyexp_256_avx512:
+
+%ifdef SAFE_PARAM
+ cmp KEY, 0
+ jz aes_keyexp_256_avx_return
+ cmp EXP_ENC_KEYS, 0
+ jz aes_keyexp_256_avx_return
+ cmp EXP_DEC_KEYS, 0
+ jz aes_keyexp_256_avx_return
+%endif
+
vmovdqu xmm1, [KEY] ; loading the AES key
vmovdqa [EXP_ENC_KEYS + 16*0], xmm1
vmovdqa [EXP_DEC_KEYS + 16*14], xmm1 ; Storing key in memory
vmovdqa [EXP_ENC_KEYS + 16*14], xmm1
vmovdqa [EXP_DEC_KEYS + 16*0], xmm1
+%ifdef SAFE_DATA
+ clear_scratch_gps_asm
+ clear_scratch_xmms_avx_asm
+%endif
+
+aes_keyexp_256_avx_return:
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
MKGLOBAL(aes_keyexp_256_enc_sse,function,)
aes_keyexp_256_enc_sse:
+
+%ifdef SAFE_PARAM
+ cmp KEY, 0
+ jz aes_keyexp_256_enc_sse_return
+ cmp EXP_ENC_KEYS, 0
+ jz aes_keyexp_256_enc_sse_return
+%endif
+
movdqu xmm1, [KEY] ; loading the AES key
movdqa [EXP_ENC_KEYS + 16*0], xmm1
key_expansion_256_sse
movdqa [EXP_ENC_KEYS + 16*14], xmm1
+%ifdef SAFE_DATA
+ clear_scratch_gps_asm
+ clear_scratch_xmms_sse_asm
+%endif
+
+aes_keyexp_256_enc_sse_return:
ret
MKGLOBAL(aes_keyexp_256_enc_sse_no_aesni,function,)
aes_keyexp_256_enc_sse_no_aesni:
+
+%ifdef SAFE_PARAM
+ cmp KEY, 0
+ jz aes_keyexp_256_enc_sse_no_aesni_return
+ cmp EXP_ENC_KEYS, 0
+ jz aes_keyexp_256_enc_sse_no_aesni_return
+%endif
+
movdqu xmm1, [KEY] ; loading the AES key
movdqa [EXP_ENC_KEYS + 16*0], xmm1
key_expansion_256_sse
movdqa [EXP_ENC_KEYS + 16*14], xmm1
+%ifdef SAFE_DATA
+ clear_scratch_gps_asm
+ clear_scratch_xmms_sse_asm
+%endif
+
+aes_keyexp_256_enc_sse_no_aesni_return:
ret
MKGLOBAL(aes_keyexp_256_enc_avx,function,)
aes_keyexp_256_enc_avx:
aes_keyexp_256_enc_avx2:
aes_keyexp_256_enc_avx512:
+
+%ifdef SAFE_PARAM
+ cmp KEY, 0
+ jz aes_keyexp_256_enc_avx_return
+ cmp EXP_ENC_KEYS, 0
+ jz aes_keyexp_256_enc_avx_return
+%endif
+
vmovdqu xmm1, [KEY] ; loading the AES key
vmovdqa [EXP_ENC_KEYS + 16*0], xmm1
key_expansion_256_avx
vmovdqa [EXP_ENC_KEYS + 16*14], xmm1
- ret
+%ifdef SAFE_DATA
+ clear_scratch_gps_asm
+ clear_scratch_xmms_avx_asm
+%endif
+
+aes_keyexp_256_enc_avx_return:
+ ret
%ifdef LINUX
section .note.GNU-stack noalloc noexec nowrite progbits