Skip to content

Commit

Permalink
zuc: eia arm64 redefine constants
Browse files Browse the repository at this point in the history
  • Loading branch information
emmansun authored Oct 22, 2024
1 parent 556e93e commit 9ef8077
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 41 deletions.
28 changes: 7 additions & 21 deletions zuc/eia256_asm_arm64.s
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,6 @@

#include "textflag.h"

DATA bit_reverse_table<>+0x00(SB)/8, $0x0e060a020c040800
DATA bit_reverse_table<>+0x08(SB)/8, $0x0f070b030d050901
DATA bit_reverse_table<>+0x10(SB)/8, $0xe060a020c0408000
DATA bit_reverse_table<>+0x18(SB)/8, $0xf070b030d0509010
GLOBL bit_reverse_table<>(SB), RODATA, $32

DATA shuf_mask_dw<>+0x00(SB)/8, $0xffffffff03020100
DATA shuf_mask_dw<>+0x08(SB)/8, $0xffffffff07060504
DATA shuf_mask_dw<>+0x10(SB)/8, $0xffffffff0b0a0908
DATA shuf_mask_dw<>+0x18(SB)/8, $0xffffffff0f0e0d0c
GLOBL shuf_mask_dw<>(SB), RODATA, $32

#define AX R2
#define BX R3
#define CX R4
Expand All @@ -31,19 +19,17 @@ GLOBL shuf_mask_dw<>(SB), RODATA, $32
#define KS_M1 V10
#define KS_M2 V11
#define KS_H V12
#define BIT_REV_TAB_L V20
#define BIT_REV_TAB_H V21
#define BIT_REV_AND_TAB V22
#define BIT_REV_AND_TAB V20
#define BIT_REV_TAB_L V21
#define BIT_REV_TAB_H V22
#define SHUF_MASK_DW0_DW1 V23
#define SHUF_MASK_DW2_DW3 V24

#define LOAD_GLOBAL_DATA() \
MOVD $bit_reverse_table<>(SB), R0 \
VLD1 (R0), [BIT_REV_TAB_L.B16, BIT_REV_TAB_H.B16] \
MOVW $0x0F0F0F0F, R0 \
VDUP R0, BIT_REV_AND_TAB.S4 \
MOVD $shuf_mask_dw<>(SB), R0 \
VLD1 (R0), [SHUF_MASK_DW0_DW1.B16, SHUF_MASK_DW2_DW3.B16]
MOVD $·eia_const<>(SB), R0 \
VLD1 (R0), [BIT_REV_TAB_L.B16, BIT_REV_TAB_H.B16, HUF_MASK_DW0_DW1.B16, SHUF_MASK_DW2_DW3.B16] \
MOVW $0x0F0F0F0F, R0 \
VDUP R0, BIT_REV_AND_TAB.S4

// func eia256RoundTag8(t *uint32, keyStream *uint32, p *byte)
TEXT ·eia256RoundTag8(SB),NOSPLIT,$0
Expand Down
36 changes: 16 additions & 20 deletions zuc/eia_asm_arm64.s
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,15 @@

#include "textflag.h"

DATA bit_reverse_table<>+0x00(SB)/8, $0x0e060a020c040800
DATA bit_reverse_table<>+0x08(SB)/8, $0x0f070b030d050901
DATA bit_reverse_table<>+0x10(SB)/8, $0xe060a020c0408000
DATA bit_reverse_table<>+0x18(SB)/8, $0xf070b030d0509010
GLOBL bit_reverse_table<>(SB), RODATA, $32

DATA shuf_mask_dw<>+0x00(SB)/8, $0xffffffff03020100
DATA shuf_mask_dw<>+0x08(SB)/8, $0xffffffff07060504
DATA shuf_mask_dw<>+0x10(SB)/8, $0xffffffff0b0a0908
DATA shuf_mask_dw<>+0x18(SB)/8, $0xffffffff0f0e0d0c
GLOBL shuf_mask_dw<>(SB), RODATA, $32
DATA ·eia_const<>+0x00(SB)/8, $0x0e060a020c040800 // bit_reverse_table low
DATA ·eia_const<>+0x08(SB)/8, $0x0f070b030d050901
DATA ·eia_const<>+0x10(SB)/8, $0xe060a020c0408000 // bit_reverse_table high
DATA ·eia_const<>+0x18(SB)/8, $0xf070b030d0509010
DATA ·eia_const<>+0x20(SB)/8, $0xffffffff03020100 // SHUF_MASK_DW0_DW1
DATA ·eia_const<>+0x28(SB)/8, $0xffffffff07060504
DATA ·eia_const<>+0x30(SB)/8, $0xffffffff0b0a0908 // SHUF_MASK_DW2_DW3
DATA ·eia_const<>+0x38(SB)/8, $0xffffffff0f0e0d0c
GLOBL ·eia_const<>(SB), RODATA, $64

#define AX R2
#define BX R3
Expand All @@ -31,19 +29,17 @@ GLOBL shuf_mask_dw<>(SB), RODATA, $32
#define KS_M1 V10
#define KS_M2 V11
#define KS_H V12
#define BIT_REV_TAB_L V20
#define BIT_REV_TAB_H V21
#define BIT_REV_AND_TAB V22
#define BIT_REV_AND_TAB V20
#define BIT_REV_TAB_L V21
#define BIT_REV_TAB_H V22
#define SHUF_MASK_DW0_DW1 V23
#define SHUF_MASK_DW2_DW3 V24

#define LOAD_GLOBAL_DATA() \
MOVD $bit_reverse_table<>(SB), R0 \
VLD1 (R0), [BIT_REV_TAB_L.B16, BIT_REV_TAB_H.B16] \
MOVW $0x0F0F0F0F, R0 \
VDUP R0, BIT_REV_AND_TAB.S4 \
MOVD $shuf_mask_dw<>(SB), R0 \
VLD1 (R0), [SHUF_MASK_DW0_DW1.B16, SHUF_MASK_DW2_DW3.B16]
MOVD $·eia_const<>(SB), R0 \
VLD1 (R0), [BIT_REV_TAB_L.B16, BIT_REV_TAB_H.B16, SHUF_MASK_DW0_DW1.B16, SHUF_MASK_DW2_DW3.B16] \
MOVW $0x0F0F0F0F, R0 \
VDUP R0, BIT_REV_AND_TAB.S4

// func eia3Round16B(t *uint32, keyStream *uint32, p *byte, tagSize int)
TEXT ·eia3Round16B(SB),NOSPLIT,$0
Expand Down

0 comments on commit 9ef8077

Please sign in to comment.