0001
0002
0003
0004
0005
0006 #include <linux/linkage.h>
0007 #include <asm/assembler.h>
0008
0009 .arch armv8-a+crypto
0010
0011 SYM_FUNC_START(__aes_ce_encrypt)
0012 sub w3, w3, #2
0013 ld1 {v0.16b}, [x2]
0014 ld1 {v1.4s}, [x0], #16
0015 cmp w3, #10
0016 bmi 0f
0017 bne 3f
0018 mov v3.16b, v1.16b
0019 b 2f
0020 0: mov v2.16b, v1.16b
0021 ld1 {v3.4s}, [x0], #16
0022 1: aese v0.16b, v2.16b
0023 aesmc v0.16b, v0.16b
0024 2: ld1 {v1.4s}, [x0], #16
0025 aese v0.16b, v3.16b
0026 aesmc v0.16b, v0.16b
0027 3: ld1 {v2.4s}, [x0], #16
0028 subs w3, w3, #3
0029 aese v0.16b, v1.16b
0030 aesmc v0.16b, v0.16b
0031 ld1 {v3.4s}, [x0], #16
0032 bpl 1b
0033 aese v0.16b, v2.16b
0034 eor v0.16b, v0.16b, v3.16b
0035 st1 {v0.16b}, [x1]
0036 ret
0037 SYM_FUNC_END(__aes_ce_encrypt)
0038
0039 SYM_FUNC_START(__aes_ce_decrypt)
0040 sub w3, w3, #2
0041 ld1 {v0.16b}, [x2]
0042 ld1 {v1.4s}, [x0], #16
0043 cmp w3, #10
0044 bmi 0f
0045 bne 3f
0046 mov v3.16b, v1.16b
0047 b 2f
0048 0: mov v2.16b, v1.16b
0049 ld1 {v3.4s}, [x0], #16
0050 1: aesd v0.16b, v2.16b
0051 aesimc v0.16b, v0.16b
0052 2: ld1 {v1.4s}, [x0], #16
0053 aesd v0.16b, v3.16b
0054 aesimc v0.16b, v0.16b
0055 3: ld1 {v2.4s}, [x0], #16
0056 subs w3, w3, #3
0057 aesd v0.16b, v1.16b
0058 aesimc v0.16b, v0.16b
0059 ld1 {v3.4s}, [x0], #16
0060 bpl 1b
0061 aesd v0.16b, v2.16b
0062 eor v0.16b, v0.16b, v3.16b
0063 st1 {v0.16b}, [x1]
0064 ret
0065 SYM_FUNC_END(__aes_ce_decrypt)
0066
0067
0068
0069
0070
0071 SYM_FUNC_START(__aes_ce_sub)
0072 dup v1.4s, w0
0073 movi v0.16b, #0
0074 aese v0.16b, v1.16b
0075 umov w0, v0.s[0]
0076 ret
0077 SYM_FUNC_END(__aes_ce_sub)
0078
0079 SYM_FUNC_START(__aes_ce_invert)
0080 ld1 {v0.4s}, [x1]
0081 aesimc v1.16b, v0.16b
0082 st1 {v1.4s}, [x0]
0083 ret
0084 SYM_FUNC_END(__aes_ce_invert)