mirror of
https://github.com/emmansun/gmsm.git
synced 2025-04-26 20:26:19 +08:00
sm4: format asm code
This commit is contained in:
parent
ff434b7bd7
commit
acffd83cc9
@ -16,19 +16,19 @@
|
|||||||
|
|
||||||
#include "aesni_amd64.h"
|
#include "aesni_amd64.h"
|
||||||
|
|
||||||
#define SM4_TAO_L2(x, y) \
|
#define SM4_TAO_L2(x, y, tmp1, tmp2) \
|
||||||
SM4_SBOX(x, y, XTMP6); \
|
SM4_SBOX(x, y, tmp1); \
|
||||||
; \ //#################### 4 parallel L2 linear transforms ##################//
|
; \ //#################### 4 parallel L2 linear transforms ##################//
|
||||||
MOVOU x, y; \
|
MOVOU x, y; \
|
||||||
MOVOU x, XTMP6; \
|
MOVOU x, tmp1; \
|
||||||
PSLLL $13, XTMP6; \
|
PSLLL $13, tmp1; \
|
||||||
PSRLL $19, y; \
|
PSRLL $19, y; \
|
||||||
POR XTMP6, y; \ //y = X roll 13
|
POR tmp1, y; \ //y = X roll 13
|
||||||
PSLLL $10, XTMP6; \
|
PSLLL $10, tmp1; \
|
||||||
MOVOU x, XTMP7; \
|
MOVOU x, tmp2; \
|
||||||
PSRLL $9, XTMP7; \
|
PSRLL $9, tmp2; \
|
||||||
POR XTMP6, XTMP7; \ //XTMP7 = x roll 23
|
POR tmp1, tmp2; \ //tmp2 = x roll 23
|
||||||
PXOR XTMP7, y; \
|
PXOR tmp2, y; \
|
||||||
PXOR y, x
|
PXOR y, x
|
||||||
|
|
||||||
#define SM4_ROUND(index, x, y, t0, t1, t2, t3) \
|
#define SM4_ROUND(index, x, y, t0, t1, t2, t3) \
|
||||||
@ -53,7 +53,7 @@
|
|||||||
PXOR t1, x; \
|
PXOR t1, x; \
|
||||||
PXOR t2, x; \
|
PXOR t2, x; \
|
||||||
PXOR t3, x; \
|
PXOR t3, x; \
|
||||||
SM4_TAO_L2(x, y); \
|
SM4_TAO_L2(x, y, XTMP6, XTMP7); \
|
||||||
PXOR x, t0; \
|
PXOR x, t0; \
|
||||||
PEXTRD $0, t0, R8; \
|
PEXTRD $0, t0, R8; \
|
||||||
MOVL R8, (index * 4)(DX)(CX*1); \
|
MOVL R8, (index * 4)(DX)(CX*1); \
|
||||||
|
@ -268,6 +268,7 @@ encryptBlocksLoop:
|
|||||||
sm4niblocks:
|
sm4niblocks:
|
||||||
VLD1.P 64(R8), [V0.S4, V1.S4, V2.S4, V3.S4]
|
VLD1.P 64(R8), [V0.S4, V1.S4, V2.S4, V3.S4]
|
||||||
VLD1.P 64(R8), [V4.S4, V5.S4, V6.S4, V7.S4]
|
VLD1.P 64(R8), [V4.S4, V5.S4, V6.S4, V7.S4]
|
||||||
|
|
||||||
sm4niblockloop:
|
sm4niblockloop:
|
||||||
SM4E_ROUND()
|
SM4E_ROUND()
|
||||||
SUB $16, R12, R12 // message length - 16bytes, then compare with 16bytes
|
SUB $16, R12, R12 // message length - 16bytes, then compare with 16bytes
|
||||||
|
@ -99,7 +99,6 @@ loopSrc:
|
|||||||
VMOV t0.S[2], t2.S[0]
|
VMOV t0.S[2], t2.S[0]
|
||||||
VMOV t0.S[3], t3.S[0]
|
VMOV t0.S[3], t3.S[0]
|
||||||
|
|
||||||
|
|
||||||
EOR R2, R2
|
EOR R2, R2
|
||||||
MOVD rkSave, R0
|
MOVD rkSave, R0
|
||||||
|
|
||||||
@ -122,6 +121,7 @@ encryptBlockLoop:
|
|||||||
VMOV t3.B16, IV.B16
|
VMOV t3.B16, IV.B16
|
||||||
|
|
||||||
B loopSrc
|
B loopSrc
|
||||||
|
|
||||||
done_sm4:
|
done_sm4:
|
||||||
VST1 [IV.B16], (R5)
|
VST1 [IV.B16], (R5)
|
||||||
RET
|
RET
|
||||||
|
Loading…
x
Reference in New Issue
Block a user