Thomas Gleixner | d2912cb | 2019-06-04 10:11:33 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 2 | /* |
| 3 | * linux/arch/arm64/crypto/aes-modes.S - chaining mode wrappers for AES |
| 4 | * |
Ard Biesheuvel | 4860620 | 2017-02-03 14:49:37 +0000 | [diff] [blame] | 5 | * Copyright (C) 2013 - 2017 Linaro Ltd <ard.biesheuvel@linaro.org> |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | /* included by aes-ce.S and aes-neon.S */ |
| 9 | |
| 10 | .text |
| 11 | .align 4 |
| 12 | |
Ard Biesheuvel | e217413 | 2019-06-24 19:38:30 +0200 | [diff] [blame] | 13 | #ifndef MAX_STRIDE |
| 14 | #define MAX_STRIDE 4 |
| 15 | #endif |
| 16 | |
Ard Biesheuvel | 7367bfe | 2019-06-24 19:38:31 +0200 | [diff] [blame] | 17 | #if MAX_STRIDE == 4 |
| 18 | #define ST4(x...) x |
| 19 | #define ST5(x...) |
| 20 | #else |
| 21 | #define ST4(x...) |
| 22 | #define ST5(x...) x |
| 23 | #endif |
| 24 | |
Mark Brown | 0e89640 | 2019-12-13 15:49:10 +0000 | [diff] [blame] | 25 | SYM_FUNC_START_LOCAL(aes_encrypt_block4x) |
Ard Biesheuvel | 6e7de6a | 2018-09-10 16:41:13 +0200 | [diff] [blame] | 26 | encrypt_block4x v0, v1, v2, v3, w3, x2, x8, w7 |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 27 | ret |
Mark Brown | 0e89640 | 2019-12-13 15:49:10 +0000 | [diff] [blame] | 28 | SYM_FUNC_END(aes_encrypt_block4x) |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 29 | |
Mark Brown | 0e89640 | 2019-12-13 15:49:10 +0000 | [diff] [blame] | 30 | SYM_FUNC_START_LOCAL(aes_decrypt_block4x) |
Ard Biesheuvel | 6e7de6a | 2018-09-10 16:41:13 +0200 | [diff] [blame] | 31 | decrypt_block4x v0, v1, v2, v3, w3, x2, x8, w7 |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 32 | ret |
Mark Brown | 0e89640 | 2019-12-13 15:49:10 +0000 | [diff] [blame] | 33 | SYM_FUNC_END(aes_decrypt_block4x) |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 34 | |
Ard Biesheuvel | e217413 | 2019-06-24 19:38:30 +0200 | [diff] [blame] | 35 | #if MAX_STRIDE == 5 |
Mark Brown | 0e89640 | 2019-12-13 15:49:10 +0000 | [diff] [blame] | 36 | SYM_FUNC_START_LOCAL(aes_encrypt_block5x) |
Ard Biesheuvel | e217413 | 2019-06-24 19:38:30 +0200 | [diff] [blame] | 37 | encrypt_block5x v0, v1, v2, v3, v4, w3, x2, x8, w7 |
| 38 | ret |
Mark Brown | 0e89640 | 2019-12-13 15:49:10 +0000 | [diff] [blame] | 39 | SYM_FUNC_END(aes_encrypt_block5x) |
Ard Biesheuvel | e217413 | 2019-06-24 19:38:30 +0200 | [diff] [blame] | 40 | |
Mark Brown | 0e89640 | 2019-12-13 15:49:10 +0000 | [diff] [blame] | 41 | SYM_FUNC_START_LOCAL(aes_decrypt_block5x) |
Ard Biesheuvel | e217413 | 2019-06-24 19:38:30 +0200 | [diff] [blame] | 42 | decrypt_block5x v0, v1, v2, v3, v4, w3, x2, x8, w7 |
| 43 | ret |
Mark Brown | 0e89640 | 2019-12-13 15:49:10 +0000 | [diff] [blame] | 44 | SYM_FUNC_END(aes_decrypt_block5x) |
Ard Biesheuvel | e217413 | 2019-06-24 19:38:30 +0200 | [diff] [blame] | 45 | #endif |
| 46 | |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 47 | /* |
| 48 | * aes_ecb_encrypt(u8 out[], u8 const in[], u8 const rk[], int rounds, |
Ard Biesheuvel | 6833817 | 2018-03-10 15:21:48 +0000 | [diff] [blame] | 49 | * int blocks) |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 50 | * aes_ecb_decrypt(u8 out[], u8 const in[], u8 const rk[], int rounds, |
Ard Biesheuvel | 6833817 | 2018-03-10 15:21:48 +0000 | [diff] [blame] | 51 | * int blocks) |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 52 | */ |
| 53 | |
Mark Brown | b8e5054 | 2020-02-18 19:58:26 +0000 | [diff] [blame] | 54 | AES_FUNC_START(aes_ecb_encrypt) |
Ard Biesheuvel | 6e7de6a | 2018-09-10 16:41:13 +0200 | [diff] [blame] | 55 | stp x29, x30, [sp, #-16]! |
| 56 | mov x29, sp |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 57 | |
Ard Biesheuvel | 6e7de6a | 2018-09-10 16:41:13 +0200 | [diff] [blame] | 58 | enc_prepare w3, x2, x5 |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 59 | |
| 60 | .LecbencloopNx: |
Ard Biesheuvel | 7367bfe | 2019-06-24 19:38:31 +0200 | [diff] [blame] | 61 | subs w4, w4, #MAX_STRIDE |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 62 | bmi .Lecbenc1x |
Ard Biesheuvel | 6e7de6a | 2018-09-10 16:41:13 +0200 | [diff] [blame] | 63 | ld1 {v0.16b-v3.16b}, [x1], #64 /* get 4 pt blocks */ |
Ard Biesheuvel | 7367bfe | 2019-06-24 19:38:31 +0200 | [diff] [blame] | 64 | ST4( bl aes_encrypt_block4x ) |
| 65 | ST5( ld1 {v4.16b}, [x1], #16 ) |
| 66 | ST5( bl aes_encrypt_block5x ) |
Ard Biesheuvel | 6e7de6a | 2018-09-10 16:41:13 +0200 | [diff] [blame] | 67 | st1 {v0.16b-v3.16b}, [x0], #64 |
Ard Biesheuvel | 7367bfe | 2019-06-24 19:38:31 +0200 | [diff] [blame] | 68 | ST5( st1 {v4.16b}, [x0], #16 ) |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 69 | b .LecbencloopNx |
| 70 | .Lecbenc1x: |
Ard Biesheuvel | 7367bfe | 2019-06-24 19:38:31 +0200 | [diff] [blame] | 71 | adds w4, w4, #MAX_STRIDE |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 72 | beq .Lecbencout |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 73 | .Lecbencloop: |
Ard Biesheuvel | 6e7de6a | 2018-09-10 16:41:13 +0200 | [diff] [blame] | 74 | ld1 {v0.16b}, [x1], #16 /* get next pt block */ |
| 75 | encrypt_block v0, w3, x2, x5, w6 |
| 76 | st1 {v0.16b}, [x0], #16 |
| 77 | subs w4, w4, #1 |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 78 | bne .Lecbencloop |
| 79 | .Lecbencout: |
Ard Biesheuvel | 6e7de6a | 2018-09-10 16:41:13 +0200 | [diff] [blame] | 80 | ldp x29, x30, [sp], #16 |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 81 | ret |
Mark Brown | b8e5054 | 2020-02-18 19:58:26 +0000 | [diff] [blame] | 82 | AES_FUNC_END(aes_ecb_encrypt) |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 83 | |
| 84 | |
Mark Brown | b8e5054 | 2020-02-18 19:58:26 +0000 | [diff] [blame] | 85 | AES_FUNC_START(aes_ecb_decrypt) |
Ard Biesheuvel | 6e7de6a | 2018-09-10 16:41:13 +0200 | [diff] [blame] | 86 | stp x29, x30, [sp, #-16]! |
| 87 | mov x29, sp |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 88 | |
Ard Biesheuvel | 6e7de6a | 2018-09-10 16:41:13 +0200 | [diff] [blame] | 89 | dec_prepare w3, x2, x5 |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 90 | |
| 91 | .LecbdecloopNx: |
Ard Biesheuvel | 7367bfe | 2019-06-24 19:38:31 +0200 | [diff] [blame] | 92 | subs w4, w4, #MAX_STRIDE |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 93 | bmi .Lecbdec1x |
Ard Biesheuvel | 6e7de6a | 2018-09-10 16:41:13 +0200 | [diff] [blame] | 94 | ld1 {v0.16b-v3.16b}, [x1], #64 /* get 4 ct blocks */ |
Ard Biesheuvel | 7367bfe | 2019-06-24 19:38:31 +0200 | [diff] [blame] | 95 | ST4( bl aes_decrypt_block4x ) |
| 96 | ST5( ld1 {v4.16b}, [x1], #16 ) |
| 97 | ST5( bl aes_decrypt_block5x ) |
Ard Biesheuvel | 6e7de6a | 2018-09-10 16:41:13 +0200 | [diff] [blame] | 98 | st1 {v0.16b-v3.16b}, [x0], #64 |
Ard Biesheuvel | 7367bfe | 2019-06-24 19:38:31 +0200 | [diff] [blame] | 99 | ST5( st1 {v4.16b}, [x0], #16 ) |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 100 | b .LecbdecloopNx |
| 101 | .Lecbdec1x: |
Ard Biesheuvel | 7367bfe | 2019-06-24 19:38:31 +0200 | [diff] [blame] | 102 | adds w4, w4, #MAX_STRIDE |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 103 | beq .Lecbdecout |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 104 | .Lecbdecloop: |
Ard Biesheuvel | 6e7de6a | 2018-09-10 16:41:13 +0200 | [diff] [blame] | 105 | ld1 {v0.16b}, [x1], #16 /* get next ct block */ |
| 106 | decrypt_block v0, w3, x2, x5, w6 |
| 107 | st1 {v0.16b}, [x0], #16 |
| 108 | subs w4, w4, #1 |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 109 | bne .Lecbdecloop |
| 110 | .Lecbdecout: |
Ard Biesheuvel | 6e7de6a | 2018-09-10 16:41:13 +0200 | [diff] [blame] | 111 | ldp x29, x30, [sp], #16 |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 112 | ret |
Mark Brown | b8e5054 | 2020-02-18 19:58:26 +0000 | [diff] [blame] | 113 | AES_FUNC_END(aes_ecb_decrypt) |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 114 | |
| 115 | |
| 116 | /* |
| 117 | * aes_cbc_encrypt(u8 out[], u8 const in[], u8 const rk[], int rounds, |
Ard Biesheuvel | 6833817 | 2018-03-10 15:21:48 +0000 | [diff] [blame] | 118 | * int blocks, u8 iv[]) |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 119 | * aes_cbc_decrypt(u8 out[], u8 const in[], u8 const rk[], int rounds, |
Ard Biesheuvel | 6833817 | 2018-03-10 15:21:48 +0000 | [diff] [blame] | 120 | * int blocks, u8 iv[]) |
Ard Biesheuvel | 735177c | 2019-08-19 17:17:36 +0300 | [diff] [blame] | 121 | * aes_essiv_cbc_encrypt(u8 out[], u8 const in[], u32 const rk1[], |
| 122 | * int rounds, int blocks, u8 iv[], |
| 123 | * u32 const rk2[]); |
| 124 | * aes_essiv_cbc_decrypt(u8 out[], u8 const in[], u32 const rk1[], |
| 125 | * int rounds, int blocks, u8 iv[], |
| 126 | * u32 const rk2[]); |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 127 | */ |
| 128 | |
Mark Brown | b8e5054 | 2020-02-18 19:58:26 +0000 | [diff] [blame] | 129 | AES_FUNC_START(aes_essiv_cbc_encrypt) |
Ard Biesheuvel | 735177c | 2019-08-19 17:17:36 +0300 | [diff] [blame] | 130 | ld1 {v4.16b}, [x5] /* get iv */ |
| 131 | |
| 132 | mov w8, #14 /* AES-256: 14 rounds */ |
| 133 | enc_prepare w8, x6, x7 |
| 134 | encrypt_block v4, w8, x6, x7, w9 |
| 135 | enc_switch_key w3, x2, x6 |
| 136 | b .Lcbcencloop4x |
| 137 | |
Mark Brown | b8e5054 | 2020-02-18 19:58:26 +0000 | [diff] [blame] | 138 | AES_FUNC_START(aes_cbc_encrypt) |
Ard Biesheuvel | 6e7de6a | 2018-09-10 16:41:13 +0200 | [diff] [blame] | 139 | ld1 {v4.16b}, [x5] /* get iv */ |
| 140 | enc_prepare w3, x2, x6 |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 141 | |
Ard Biesheuvel | a8f8a69 | 2018-03-10 15:21:52 +0000 | [diff] [blame] | 142 | .Lcbcencloop4x: |
Ard Biesheuvel | 6e7de6a | 2018-09-10 16:41:13 +0200 | [diff] [blame] | 143 | subs w4, w4, #4 |
Ard Biesheuvel | a8f8a69 | 2018-03-10 15:21:52 +0000 | [diff] [blame] | 144 | bmi .Lcbcenc1x |
Ard Biesheuvel | 6e7de6a | 2018-09-10 16:41:13 +0200 | [diff] [blame] | 145 | ld1 {v0.16b-v3.16b}, [x1], #64 /* get 4 pt blocks */ |
Ard Biesheuvel | a8f8a69 | 2018-03-10 15:21:52 +0000 | [diff] [blame] | 146 | eor v0.16b, v0.16b, v4.16b /* ..and xor with iv */ |
Ard Biesheuvel | 6e7de6a | 2018-09-10 16:41:13 +0200 | [diff] [blame] | 147 | encrypt_block v0, w3, x2, x6, w7 |
Ard Biesheuvel | a8f8a69 | 2018-03-10 15:21:52 +0000 | [diff] [blame] | 148 | eor v1.16b, v1.16b, v0.16b |
Ard Biesheuvel | 6e7de6a | 2018-09-10 16:41:13 +0200 | [diff] [blame] | 149 | encrypt_block v1, w3, x2, x6, w7 |
Ard Biesheuvel | a8f8a69 | 2018-03-10 15:21:52 +0000 | [diff] [blame] | 150 | eor v2.16b, v2.16b, v1.16b |
Ard Biesheuvel | 6e7de6a | 2018-09-10 16:41:13 +0200 | [diff] [blame] | 151 | encrypt_block v2, w3, x2, x6, w7 |
Ard Biesheuvel | a8f8a69 | 2018-03-10 15:21:52 +0000 | [diff] [blame] | 152 | eor v3.16b, v3.16b, v2.16b |
Ard Biesheuvel | 6e7de6a | 2018-09-10 16:41:13 +0200 | [diff] [blame] | 153 | encrypt_block v3, w3, x2, x6, w7 |
| 154 | st1 {v0.16b-v3.16b}, [x0], #64 |
Ard Biesheuvel | a8f8a69 | 2018-03-10 15:21:52 +0000 | [diff] [blame] | 155 | mov v4.16b, v3.16b |
| 156 | b .Lcbcencloop4x |
| 157 | .Lcbcenc1x: |
Ard Biesheuvel | 6e7de6a | 2018-09-10 16:41:13 +0200 | [diff] [blame] | 158 | adds w4, w4, #4 |
Ard Biesheuvel | a8f8a69 | 2018-03-10 15:21:52 +0000 | [diff] [blame] | 159 | beq .Lcbcencout |
| 160 | .Lcbcencloop: |
Ard Biesheuvel | 6e7de6a | 2018-09-10 16:41:13 +0200 | [diff] [blame] | 161 | ld1 {v0.16b}, [x1], #16 /* get next pt block */ |
Ard Biesheuvel | a8f8a69 | 2018-03-10 15:21:52 +0000 | [diff] [blame] | 162 | eor v4.16b, v4.16b, v0.16b /* ..and xor with iv */ |
Ard Biesheuvel | 6e7de6a | 2018-09-10 16:41:13 +0200 | [diff] [blame] | 163 | encrypt_block v4, w3, x2, x6, w7 |
| 164 | st1 {v4.16b}, [x0], #16 |
| 165 | subs w4, w4, #1 |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 166 | bne .Lcbcencloop |
Ard Biesheuvel | a8f8a69 | 2018-03-10 15:21:52 +0000 | [diff] [blame] | 167 | .Lcbcencout: |
Ard Biesheuvel | 6e7de6a | 2018-09-10 16:41:13 +0200 | [diff] [blame] | 168 | st1 {v4.16b}, [x5] /* return iv */ |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 169 | ret |
Mark Brown | b8e5054 | 2020-02-18 19:58:26 +0000 | [diff] [blame] | 170 | AES_FUNC_END(aes_cbc_encrypt) |
| 171 | AES_FUNC_END(aes_essiv_cbc_encrypt) |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 172 | |
Mark Brown | b8e5054 | 2020-02-18 19:58:26 +0000 | [diff] [blame] | 173 | AES_FUNC_START(aes_essiv_cbc_decrypt) |
Ard Biesheuvel | 735177c | 2019-08-19 17:17:36 +0300 | [diff] [blame] | 174 | stp x29, x30, [sp, #-16]! |
| 175 | mov x29, sp |
| 176 | |
| 177 | ld1 {cbciv.16b}, [x5] /* get iv */ |
| 178 | |
| 179 | mov w8, #14 /* AES-256: 14 rounds */ |
| 180 | enc_prepare w8, x6, x7 |
| 181 | encrypt_block cbciv, w8, x6, x7, w9 |
| 182 | b .Lessivcbcdecstart |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 183 | |
Mark Brown | b8e5054 | 2020-02-18 19:58:26 +0000 | [diff] [blame] | 184 | AES_FUNC_START(aes_cbc_decrypt) |
Ard Biesheuvel | 6e7de6a | 2018-09-10 16:41:13 +0200 | [diff] [blame] | 185 | stp x29, x30, [sp, #-16]! |
| 186 | mov x29, sp |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 187 | |
Ard Biesheuvel | 7367bfe | 2019-06-24 19:38:31 +0200 | [diff] [blame] | 188 | ld1 {cbciv.16b}, [x5] /* get iv */ |
Ard Biesheuvel | 735177c | 2019-08-19 17:17:36 +0300 | [diff] [blame] | 189 | .Lessivcbcdecstart: |
Ard Biesheuvel | 6e7de6a | 2018-09-10 16:41:13 +0200 | [diff] [blame] | 190 | dec_prepare w3, x2, x6 |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 191 | |
| 192 | .LcbcdecloopNx: |
Ard Biesheuvel | 7367bfe | 2019-06-24 19:38:31 +0200 | [diff] [blame] | 193 | subs w4, w4, #MAX_STRIDE |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 194 | bmi .Lcbcdec1x |
Ard Biesheuvel | 6e7de6a | 2018-09-10 16:41:13 +0200 | [diff] [blame] | 195 | ld1 {v0.16b-v3.16b}, [x1], #64 /* get 4 ct blocks */ |
Ard Biesheuvel | 7367bfe | 2019-06-24 19:38:31 +0200 | [diff] [blame] | 196 | #if MAX_STRIDE == 5 |
| 197 | ld1 {v4.16b}, [x1], #16 /* get 1 ct block */ |
| 198 | mov v5.16b, v0.16b |
| 199 | mov v6.16b, v1.16b |
| 200 | mov v7.16b, v2.16b |
| 201 | bl aes_decrypt_block5x |
| 202 | sub x1, x1, #32 |
| 203 | eor v0.16b, v0.16b, cbciv.16b |
| 204 | eor v1.16b, v1.16b, v5.16b |
| 205 | ld1 {v5.16b}, [x1], #16 /* reload 1 ct block */ |
| 206 | ld1 {cbciv.16b}, [x1], #16 /* reload 1 ct block */ |
| 207 | eor v2.16b, v2.16b, v6.16b |
| 208 | eor v3.16b, v3.16b, v7.16b |
| 209 | eor v4.16b, v4.16b, v5.16b |
| 210 | #else |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 211 | mov v4.16b, v0.16b |
| 212 | mov v5.16b, v1.16b |
| 213 | mov v6.16b, v2.16b |
Ard Biesheuvel | 55868b4 | 2018-03-10 15:21:51 +0000 | [diff] [blame] | 214 | bl aes_decrypt_block4x |
Ard Biesheuvel | 6e7de6a | 2018-09-10 16:41:13 +0200 | [diff] [blame] | 215 | sub x1, x1, #16 |
Ard Biesheuvel | 7367bfe | 2019-06-24 19:38:31 +0200 | [diff] [blame] | 216 | eor v0.16b, v0.16b, cbciv.16b |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 217 | eor v1.16b, v1.16b, v4.16b |
Ard Biesheuvel | 7367bfe | 2019-06-24 19:38:31 +0200 | [diff] [blame] | 218 | ld1 {cbciv.16b}, [x1], #16 /* reload 1 ct block */ |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 219 | eor v2.16b, v2.16b, v5.16b |
| 220 | eor v3.16b, v3.16b, v6.16b |
Ard Biesheuvel | 7367bfe | 2019-06-24 19:38:31 +0200 | [diff] [blame] | 221 | #endif |
Ard Biesheuvel | 6e7de6a | 2018-09-10 16:41:13 +0200 | [diff] [blame] | 222 | st1 {v0.16b-v3.16b}, [x0], #64 |
Ard Biesheuvel | 7367bfe | 2019-06-24 19:38:31 +0200 | [diff] [blame] | 223 | ST5( st1 {v4.16b}, [x0], #16 ) |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 224 | b .LcbcdecloopNx |
| 225 | .Lcbcdec1x: |
Ard Biesheuvel | 7367bfe | 2019-06-24 19:38:31 +0200 | [diff] [blame] | 226 | adds w4, w4, #MAX_STRIDE |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 227 | beq .Lcbcdecout |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 228 | .Lcbcdecloop: |
Ard Biesheuvel | 6e7de6a | 2018-09-10 16:41:13 +0200 | [diff] [blame] | 229 | ld1 {v1.16b}, [x1], #16 /* get next ct block */ |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 230 | mov v0.16b, v1.16b /* ...and copy to v0 */ |
Ard Biesheuvel | 6e7de6a | 2018-09-10 16:41:13 +0200 | [diff] [blame] | 231 | decrypt_block v0, w3, x2, x6, w7 |
Ard Biesheuvel | 7367bfe | 2019-06-24 19:38:31 +0200 | [diff] [blame] | 232 | eor v0.16b, v0.16b, cbciv.16b /* xor with iv => pt */ |
| 233 | mov cbciv.16b, v1.16b /* ct is next iv */ |
Ard Biesheuvel | 6e7de6a | 2018-09-10 16:41:13 +0200 | [diff] [blame] | 234 | st1 {v0.16b}, [x0], #16 |
| 235 | subs w4, w4, #1 |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 236 | bne .Lcbcdecloop |
| 237 | .Lcbcdecout: |
Ard Biesheuvel | 7367bfe | 2019-06-24 19:38:31 +0200 | [diff] [blame] | 238 | st1 {cbciv.16b}, [x5] /* return iv */ |
Ard Biesheuvel | 6e7de6a | 2018-09-10 16:41:13 +0200 | [diff] [blame] | 239 | ldp x29, x30, [sp], #16 |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 240 | ret |
Mark Brown | b8e5054 | 2020-02-18 19:58:26 +0000 | [diff] [blame] | 241 | AES_FUNC_END(aes_cbc_decrypt) |
| 242 | AES_FUNC_END(aes_essiv_cbc_decrypt) |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 243 | |
| 244 | |
| 245 | /* |
Ard Biesheuvel | dd597fb | 2018-09-10 16:41:14 +0200 | [diff] [blame] | 246 | * aes_cbc_cts_encrypt(u8 out[], u8 const in[], u32 const rk[], |
| 247 | * int rounds, int bytes, u8 const iv[]) |
| 248 | * aes_cbc_cts_decrypt(u8 out[], u8 const in[], u32 const rk[], |
| 249 | * int rounds, int bytes, u8 const iv[]) |
| 250 | */ |
| 251 | |
Mark Brown | b8e5054 | 2020-02-18 19:58:26 +0000 | [diff] [blame] | 252 | AES_FUNC_START(aes_cbc_cts_encrypt) |
Ard Biesheuvel | dd597fb | 2018-09-10 16:41:14 +0200 | [diff] [blame] | 253 | adr_l x8, .Lcts_permute_table |
| 254 | sub x4, x4, #16 |
| 255 | add x9, x8, #32 |
| 256 | add x8, x8, x4 |
| 257 | sub x9, x9, x4 |
| 258 | ld1 {v3.16b}, [x8] |
| 259 | ld1 {v4.16b}, [x9] |
| 260 | |
| 261 | ld1 {v0.16b}, [x1], x4 /* overlapping loads */ |
| 262 | ld1 {v1.16b}, [x1] |
| 263 | |
| 264 | ld1 {v5.16b}, [x5] /* get iv */ |
| 265 | enc_prepare w3, x2, x6 |
| 266 | |
| 267 | eor v0.16b, v0.16b, v5.16b /* xor with iv */ |
| 268 | tbl v1.16b, {v1.16b}, v4.16b |
| 269 | encrypt_block v0, w3, x2, x6, w7 |
| 270 | |
| 271 | eor v1.16b, v1.16b, v0.16b |
| 272 | tbl v0.16b, {v0.16b}, v3.16b |
| 273 | encrypt_block v1, w3, x2, x6, w7 |
| 274 | |
| 275 | add x4, x0, x4 |
| 276 | st1 {v0.16b}, [x4] /* overlapping stores */ |
| 277 | st1 {v1.16b}, [x0] |
| 278 | ret |
Mark Brown | b8e5054 | 2020-02-18 19:58:26 +0000 | [diff] [blame] | 279 | AES_FUNC_END(aes_cbc_cts_encrypt) |
Ard Biesheuvel | dd597fb | 2018-09-10 16:41:14 +0200 | [diff] [blame] | 280 | |
Mark Brown | b8e5054 | 2020-02-18 19:58:26 +0000 | [diff] [blame] | 281 | AES_FUNC_START(aes_cbc_cts_decrypt) |
Ard Biesheuvel | dd597fb | 2018-09-10 16:41:14 +0200 | [diff] [blame] | 282 | adr_l x8, .Lcts_permute_table |
| 283 | sub x4, x4, #16 |
| 284 | add x9, x8, #32 |
| 285 | add x8, x8, x4 |
| 286 | sub x9, x9, x4 |
| 287 | ld1 {v3.16b}, [x8] |
| 288 | ld1 {v4.16b}, [x9] |
| 289 | |
| 290 | ld1 {v0.16b}, [x1], x4 /* overlapping loads */ |
| 291 | ld1 {v1.16b}, [x1] |
| 292 | |
| 293 | ld1 {v5.16b}, [x5] /* get iv */ |
| 294 | dec_prepare w3, x2, x6 |
| 295 | |
Ard Biesheuvel | dd597fb | 2018-09-10 16:41:14 +0200 | [diff] [blame] | 296 | decrypt_block v0, w3, x2, x6, w7 |
Ard Biesheuvel | 0cfd507 | 2019-09-03 09:43:31 -0700 | [diff] [blame] | 297 | tbl v2.16b, {v0.16b}, v3.16b |
| 298 | eor v2.16b, v2.16b, v1.16b |
Ard Biesheuvel | dd597fb | 2018-09-10 16:41:14 +0200 | [diff] [blame] | 299 | |
| 300 | tbx v0.16b, {v1.16b}, v4.16b |
Ard Biesheuvel | dd597fb | 2018-09-10 16:41:14 +0200 | [diff] [blame] | 301 | decrypt_block v0, w3, x2, x6, w7 |
| 302 | eor v0.16b, v0.16b, v5.16b /* xor with iv */ |
| 303 | |
| 304 | add x4, x0, x4 |
| 305 | st1 {v2.16b}, [x4] /* overlapping stores */ |
| 306 | st1 {v0.16b}, [x0] |
| 307 | ret |
Mark Brown | b8e5054 | 2020-02-18 19:58:26 +0000 | [diff] [blame] | 308 | AES_FUNC_END(aes_cbc_cts_decrypt) |
Ard Biesheuvel | dd597fb | 2018-09-10 16:41:14 +0200 | [diff] [blame] | 309 | |
| 310 | .section ".rodata", "a" |
| 311 | .align 6 |
| 312 | .Lcts_permute_table: |
| 313 | .byte 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff |
| 314 | .byte 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff |
| 315 | .byte 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7 |
| 316 | .byte 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf |
| 317 | .byte 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff |
| 318 | .byte 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff |
| 319 | .previous |
| 320 | |
| 321 | |
| 322 | /* |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 323 | * aes_ctr_encrypt(u8 out[], u8 const in[], u8 const rk[], int rounds, |
Ard Biesheuvel | 6833817 | 2018-03-10 15:21:48 +0000 | [diff] [blame] | 324 | * int blocks, u8 ctr[]) |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 325 | */ |
| 326 | |
Mark Brown | b8e5054 | 2020-02-18 19:58:26 +0000 | [diff] [blame] | 327 | AES_FUNC_START(aes_ctr_encrypt) |
Ard Biesheuvel | 6e7de6a | 2018-09-10 16:41:13 +0200 | [diff] [blame] | 328 | stp x29, x30, [sp, #-16]! |
| 329 | mov x29, sp |
Ard Biesheuvel | 6833817 | 2018-03-10 15:21:48 +0000 | [diff] [blame] | 330 | |
Ard Biesheuvel | 6e7de6a | 2018-09-10 16:41:13 +0200 | [diff] [blame] | 331 | enc_prepare w3, x2, x6 |
Ard Biesheuvel | 7367bfe | 2019-06-24 19:38:31 +0200 | [diff] [blame] | 332 | ld1 {vctr.16b}, [x5] |
Ard Biesheuvel | 11e3b72 | 2017-01-17 13:46:29 +0000 | [diff] [blame] | 333 | |
Ard Biesheuvel | 7367bfe | 2019-06-24 19:38:31 +0200 | [diff] [blame] | 334 | umov x6, vctr.d[1] /* keep swabbed ctr in reg */ |
Ard Biesheuvel | 6833817 | 2018-03-10 15:21:48 +0000 | [diff] [blame] | 335 | rev x6, x6 |
Ard Biesheuvel | 6e7de6a | 2018-09-10 16:41:13 +0200 | [diff] [blame] | 336 | cmn w6, w4 /* 32 bit overflow? */ |
| 337 | bcs .Lctrloop |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 338 | .LctrloopNx: |
Ard Biesheuvel | 7367bfe | 2019-06-24 19:38:31 +0200 | [diff] [blame] | 339 | subs w4, w4, #MAX_STRIDE |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 340 | bmi .Lctr1x |
Ard Biesheuvel | ed6ed11 | 2018-08-23 17:48:45 +0100 | [diff] [blame] | 341 | add w7, w6, #1 |
Ard Biesheuvel | 7367bfe | 2019-06-24 19:38:31 +0200 | [diff] [blame] | 342 | mov v0.16b, vctr.16b |
Ard Biesheuvel | ed6ed11 | 2018-08-23 17:48:45 +0100 | [diff] [blame] | 343 | add w8, w6, #2 |
Ard Biesheuvel | 7367bfe | 2019-06-24 19:38:31 +0200 | [diff] [blame] | 344 | mov v1.16b, vctr.16b |
Ard Biesheuvel | ed6ed11 | 2018-08-23 17:48:45 +0100 | [diff] [blame] | 345 | add w9, w6, #3 |
Ard Biesheuvel | 7367bfe | 2019-06-24 19:38:31 +0200 | [diff] [blame] | 346 | mov v2.16b, vctr.16b |
| 347 | add w9, w6, #3 |
Ard Biesheuvel | ed6ed11 | 2018-08-23 17:48:45 +0100 | [diff] [blame] | 348 | rev w7, w7 |
Ard Biesheuvel | 7367bfe | 2019-06-24 19:38:31 +0200 | [diff] [blame] | 349 | mov v3.16b, vctr.16b |
Ard Biesheuvel | ed6ed11 | 2018-08-23 17:48:45 +0100 | [diff] [blame] | 350 | rev w8, w8 |
Ard Biesheuvel | 7367bfe | 2019-06-24 19:38:31 +0200 | [diff] [blame] | 351 | ST5( mov v4.16b, vctr.16b ) |
Ard Biesheuvel | ed6ed11 | 2018-08-23 17:48:45 +0100 | [diff] [blame] | 352 | mov v1.s[3], w7 |
| 353 | rev w9, w9 |
Ard Biesheuvel | 7367bfe | 2019-06-24 19:38:31 +0200 | [diff] [blame] | 354 | ST5( add w10, w6, #4 ) |
Ard Biesheuvel | ed6ed11 | 2018-08-23 17:48:45 +0100 | [diff] [blame] | 355 | mov v2.s[3], w8 |
Ard Biesheuvel | 7367bfe | 2019-06-24 19:38:31 +0200 | [diff] [blame] | 356 | ST5( rev w10, w10 ) |
Ard Biesheuvel | ed6ed11 | 2018-08-23 17:48:45 +0100 | [diff] [blame] | 357 | mov v3.s[3], w9 |
Ard Biesheuvel | 7367bfe | 2019-06-24 19:38:31 +0200 | [diff] [blame] | 358 | ST5( mov v4.s[3], w10 ) |
Ard Biesheuvel | 6e7de6a | 2018-09-10 16:41:13 +0200 | [diff] [blame] | 359 | ld1 {v5.16b-v7.16b}, [x1], #48 /* get 3 input blocks */ |
Ard Biesheuvel | 7367bfe | 2019-06-24 19:38:31 +0200 | [diff] [blame] | 360 | ST4( bl aes_encrypt_block4x ) |
| 361 | ST5( bl aes_encrypt_block5x ) |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 362 | eor v0.16b, v5.16b, v0.16b |
Ard Biesheuvel | 7367bfe | 2019-06-24 19:38:31 +0200 | [diff] [blame] | 363 | ST4( ld1 {v5.16b}, [x1], #16 ) |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 364 | eor v1.16b, v6.16b, v1.16b |
Ard Biesheuvel | 7367bfe | 2019-06-24 19:38:31 +0200 | [diff] [blame] | 365 | ST5( ld1 {v5.16b-v6.16b}, [x1], #32 ) |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 366 | eor v2.16b, v7.16b, v2.16b |
| 367 | eor v3.16b, v5.16b, v3.16b |
Ard Biesheuvel | 7367bfe | 2019-06-24 19:38:31 +0200 | [diff] [blame] | 368 | ST5( eor v4.16b, v6.16b, v4.16b ) |
Ard Biesheuvel | 6e7de6a | 2018-09-10 16:41:13 +0200 | [diff] [blame] | 369 | st1 {v0.16b-v3.16b}, [x0], #64 |
Ard Biesheuvel | 7367bfe | 2019-06-24 19:38:31 +0200 | [diff] [blame] | 370 | ST5( st1 {v4.16b}, [x0], #16 ) |
| 371 | add x6, x6, #MAX_STRIDE |
Ard Biesheuvel | 6833817 | 2018-03-10 15:21:48 +0000 | [diff] [blame] | 372 | rev x7, x6 |
Ard Biesheuvel | 7367bfe | 2019-06-24 19:38:31 +0200 | [diff] [blame] | 373 | ins vctr.d[1], x7 |
Ard Biesheuvel | 6e7de6a | 2018-09-10 16:41:13 +0200 | [diff] [blame] | 374 | cbz w4, .Lctrout |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 375 | b .LctrloopNx |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 376 | .Lctr1x: |
Ard Biesheuvel | 7367bfe | 2019-06-24 19:38:31 +0200 | [diff] [blame] | 377 | adds w4, w4, #MAX_STRIDE |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 378 | beq .Lctrout |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 379 | .Lctrloop: |
Ard Biesheuvel | 7367bfe | 2019-06-24 19:38:31 +0200 | [diff] [blame] | 380 | mov v0.16b, vctr.16b |
Ard Biesheuvel | 6e7de6a | 2018-09-10 16:41:13 +0200 | [diff] [blame] | 381 | encrypt_block v0, w3, x2, x8, w7 |
Ard Biesheuvel | 11e3b72 | 2017-01-17 13:46:29 +0000 | [diff] [blame] | 382 | |
Ard Biesheuvel | 6833817 | 2018-03-10 15:21:48 +0000 | [diff] [blame] | 383 | adds x6, x6, #1 /* increment BE ctr */ |
| 384 | rev x7, x6 |
Ard Biesheuvel | 7367bfe | 2019-06-24 19:38:31 +0200 | [diff] [blame] | 385 | ins vctr.d[1], x7 |
Ard Biesheuvel | 11e3b72 | 2017-01-17 13:46:29 +0000 | [diff] [blame] | 386 | bcs .Lctrcarry /* overflow? */ |
| 387 | |
| 388 | .Lctrcarrydone: |
Ard Biesheuvel | 6e7de6a | 2018-09-10 16:41:13 +0200 | [diff] [blame] | 389 | subs w4, w4, #1 |
Ard Biesheuvel | ccc5d51 | 2017-01-28 23:25:34 +0000 | [diff] [blame] | 390 | bmi .Lctrtailblock /* blocks <0 means tail block */ |
Ard Biesheuvel | 6e7de6a | 2018-09-10 16:41:13 +0200 | [diff] [blame] | 391 | ld1 {v3.16b}, [x1], #16 |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 392 | eor v3.16b, v0.16b, v3.16b |
Ard Biesheuvel | 6e7de6a | 2018-09-10 16:41:13 +0200 | [diff] [blame] | 393 | st1 {v3.16b}, [x0], #16 |
Ard Biesheuvel | 11e3b72 | 2017-01-17 13:46:29 +0000 | [diff] [blame] | 394 | bne .Lctrloop |
| 395 | |
| 396 | .Lctrout: |
Ard Biesheuvel | 7367bfe | 2019-06-24 19:38:31 +0200 | [diff] [blame] | 397 | st1 {vctr.16b}, [x5] /* return next CTR value */ |
Ard Biesheuvel | 6e7de6a | 2018-09-10 16:41:13 +0200 | [diff] [blame] | 398 | ldp x29, x30, [sp], #16 |
Ard Biesheuvel | 11e3b72 | 2017-01-17 13:46:29 +0000 | [diff] [blame] | 399 | ret |
| 400 | |
Ard Biesheuvel | ccc5d51 | 2017-01-28 23:25:34 +0000 | [diff] [blame] | 401 | .Lctrtailblock: |
Ard Biesheuvel | 6e7de6a | 2018-09-10 16:41:13 +0200 | [diff] [blame] | 402 | st1 {v0.16b}, [x0] |
Eric Biggers | fa5fd3a | 2019-02-14 00:03:54 -0800 | [diff] [blame] | 403 | b .Lctrout |
Ard Biesheuvel | 11e3b72 | 2017-01-17 13:46:29 +0000 | [diff] [blame] | 404 | |
| 405 | .Lctrcarry: |
Ard Biesheuvel | 7367bfe | 2019-06-24 19:38:31 +0200 | [diff] [blame] | 406 | umov x7, vctr.d[0] /* load upper word of ctr */ |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 407 | rev x7, x7 /* ... to handle the carry */ |
| 408 | add x7, x7, #1 |
| 409 | rev x7, x7 |
Ard Biesheuvel | 7367bfe | 2019-06-24 19:38:31 +0200 | [diff] [blame] | 410 | ins vctr.d[0], x7 |
Ard Biesheuvel | 11e3b72 | 2017-01-17 13:46:29 +0000 | [diff] [blame] | 411 | b .Lctrcarrydone |
Mark Brown | b8e5054 | 2020-02-18 19:58:26 +0000 | [diff] [blame] | 412 | AES_FUNC_END(aes_ctr_encrypt) |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 413 | |
| 414 | |
| 415 | /* |
Ard Biesheuvel | 7cceca8 | 2019-09-03 09:43:33 -0700 | [diff] [blame] | 416 | * aes_xts_encrypt(u8 out[], u8 const in[], u8 const rk1[], int rounds, |
| 417 | * int bytes, u8 const rk2[], u8 iv[], int first) |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 418 | * aes_xts_decrypt(u8 out[], u8 const in[], u8 const rk1[], int rounds, |
Ard Biesheuvel | 7cceca8 | 2019-09-03 09:43:33 -0700 | [diff] [blame] | 419 | * int bytes, u8 const rk2[], u8 iv[], int first) |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 420 | */ |
| 421 | |
Ard Biesheuvel | 2e5d2f3 | 2018-09-10 16:41:15 +0200 | [diff] [blame] | 422 | .macro next_tweak, out, in, tmp |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 423 | sshr \tmp\().2d, \in\().2d, #63 |
Ard Biesheuvel | 2e5d2f3 | 2018-09-10 16:41:15 +0200 | [diff] [blame] | 424 | and \tmp\().16b, \tmp\().16b, xtsmask.16b |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 425 | add \out\().2d, \in\().2d, \in\().2d |
| 426 | ext \tmp\().16b, \tmp\().16b, \tmp\().16b, #8 |
| 427 | eor \out\().16b, \out\().16b, \tmp\().16b |
| 428 | .endm |
| 429 | |
Ard Biesheuvel | 2e5d2f3 | 2018-09-10 16:41:15 +0200 | [diff] [blame] | 430 | .macro xts_load_mask, tmp |
| 431 | movi xtsmask.2s, #0x1 |
| 432 | movi \tmp\().2s, #0x87 |
| 433 | uzp1 xtsmask.4s, xtsmask.4s, \tmp\().4s |
| 434 | .endm |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 435 | |
Mark Brown | b8e5054 | 2020-02-18 19:58:26 +0000 | [diff] [blame] | 436 | AES_FUNC_START(aes_xts_encrypt) |
Ard Biesheuvel | 6e7de6a | 2018-09-10 16:41:13 +0200 | [diff] [blame] | 437 | stp x29, x30, [sp, #-16]! |
| 438 | mov x29, sp |
Ard Biesheuvel | 55868b4 | 2018-03-10 15:21:51 +0000 | [diff] [blame] | 439 | |
Ard Biesheuvel | 6e7de6a | 2018-09-10 16:41:13 +0200 | [diff] [blame] | 440 | ld1 {v4.16b}, [x6] |
Ard Biesheuvel | cc3cc48 | 2018-10-08 13:16:59 +0200 | [diff] [blame] | 441 | xts_load_mask v8 |
Ard Biesheuvel | 6833817 | 2018-03-10 15:21:48 +0000 | [diff] [blame] | 442 | cbz w7, .Lxtsencnotfirst |
| 443 | |
| 444 | enc_prepare w3, x5, x8 |
Ard Biesheuvel | 67cfa5d | 2019-09-03 09:43:34 -0700 | [diff] [blame] | 445 | xts_cts_skip_tw w7, .LxtsencNx |
Ard Biesheuvel | 6833817 | 2018-03-10 15:21:48 +0000 | [diff] [blame] | 446 | encrypt_block v4, w3, x5, x8, w7 /* first tweak */ |
| 447 | enc_switch_key w3, x2, x8 |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 448 | b .LxtsencNx |
| 449 | |
Ard Biesheuvel | 6833817 | 2018-03-10 15:21:48 +0000 | [diff] [blame] | 450 | .Lxtsencnotfirst: |
Ard Biesheuvel | 6e7de6a | 2018-09-10 16:41:13 +0200 | [diff] [blame] | 451 | enc_prepare w3, x2, x8 |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 452 | .LxtsencloopNx: |
Ard Biesheuvel | 2e5d2f3 | 2018-09-10 16:41:15 +0200 | [diff] [blame] | 453 | next_tweak v4, v4, v8 |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 454 | .LxtsencNx: |
Ard Biesheuvel | 7cceca8 | 2019-09-03 09:43:33 -0700 | [diff] [blame] | 455 | subs w4, w4, #64 |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 456 | bmi .Lxtsenc1x |
Ard Biesheuvel | 6e7de6a | 2018-09-10 16:41:13 +0200 | [diff] [blame] | 457 | ld1 {v0.16b-v3.16b}, [x1], #64 /* get 4 pt blocks */ |
Ard Biesheuvel | 2e5d2f3 | 2018-09-10 16:41:15 +0200 | [diff] [blame] | 458 | next_tweak v5, v4, v8 |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 459 | eor v0.16b, v0.16b, v4.16b |
Ard Biesheuvel | 2e5d2f3 | 2018-09-10 16:41:15 +0200 | [diff] [blame] | 460 | next_tweak v6, v5, v8 |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 461 | eor v1.16b, v1.16b, v5.16b |
| 462 | eor v2.16b, v2.16b, v6.16b |
Ard Biesheuvel | 2e5d2f3 | 2018-09-10 16:41:15 +0200 | [diff] [blame] | 463 | next_tweak v7, v6, v8 |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 464 | eor v3.16b, v3.16b, v7.16b |
Ard Biesheuvel | 55868b4 | 2018-03-10 15:21:51 +0000 | [diff] [blame] | 465 | bl aes_encrypt_block4x |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 466 | eor v3.16b, v3.16b, v7.16b |
| 467 | eor v0.16b, v0.16b, v4.16b |
| 468 | eor v1.16b, v1.16b, v5.16b |
| 469 | eor v2.16b, v2.16b, v6.16b |
Ard Biesheuvel | 6e7de6a | 2018-09-10 16:41:13 +0200 | [diff] [blame] | 470 | st1 {v0.16b-v3.16b}, [x0], #64 |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 471 | mov v4.16b, v7.16b |
Ard Biesheuvel | 7cceca8 | 2019-09-03 09:43:33 -0700 | [diff] [blame] | 472 | cbz w4, .Lxtsencret |
Ard Biesheuvel | cc3cc48 | 2018-10-08 13:16:59 +0200 | [diff] [blame] | 473 | xts_reload_mask v8 |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 474 | b .LxtsencloopNx |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 475 | .Lxtsenc1x: |
Ard Biesheuvel | 7cceca8 | 2019-09-03 09:43:33 -0700 | [diff] [blame] | 476 | adds w4, w4, #64 |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 477 | beq .Lxtsencout |
Ard Biesheuvel | 7cceca8 | 2019-09-03 09:43:33 -0700 | [diff] [blame] | 478 | subs w4, w4, #16 |
| 479 | bmi .LxtsencctsNx |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 480 | .Lxtsencloop: |
Ard Biesheuvel | 7cceca8 | 2019-09-03 09:43:33 -0700 | [diff] [blame] | 481 | ld1 {v0.16b}, [x1], #16 |
| 482 | .Lxtsencctsout: |
| 483 | eor v0.16b, v0.16b, v4.16b |
Ard Biesheuvel | 6e7de6a | 2018-09-10 16:41:13 +0200 | [diff] [blame] | 484 | encrypt_block v0, w3, x2, x8, w7 |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 485 | eor v0.16b, v0.16b, v4.16b |
Ard Biesheuvel | 7cceca8 | 2019-09-03 09:43:33 -0700 | [diff] [blame] | 486 | cbz w4, .Lxtsencout |
| 487 | subs w4, w4, #16 |
Ard Biesheuvel | 2e5d2f3 | 2018-09-10 16:41:15 +0200 | [diff] [blame] | 488 | next_tweak v4, v4, v8 |
Ard Biesheuvel | 7cceca8 | 2019-09-03 09:43:33 -0700 | [diff] [blame] | 489 | bmi .Lxtsenccts |
| 490 | st1 {v0.16b}, [x0], #16 |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 491 | b .Lxtsencloop |
| 492 | .Lxtsencout: |
Ard Biesheuvel | 7cceca8 | 2019-09-03 09:43:33 -0700 | [diff] [blame] | 493 | st1 {v0.16b}, [x0] |
| 494 | .Lxtsencret: |
Ard Biesheuvel | 6e7de6a | 2018-09-10 16:41:13 +0200 | [diff] [blame] | 495 | st1 {v4.16b}, [x6] |
| 496 | ldp x29, x30, [sp], #16 |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 497 | ret |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 498 | |
Ard Biesheuvel | 7cceca8 | 2019-09-03 09:43:33 -0700 | [diff] [blame] | 499 | .LxtsencctsNx: |
| 500 | mov v0.16b, v3.16b |
| 501 | sub x0, x0, #16 |
| 502 | .Lxtsenccts: |
| 503 | adr_l x8, .Lcts_permute_table |
| 504 | |
| 505 | add x1, x1, w4, sxtw /* rewind input pointer */ |
| 506 | add w4, w4, #16 /* # bytes in final block */ |
| 507 | add x9, x8, #32 |
| 508 | add x8, x8, x4 |
| 509 | sub x9, x9, x4 |
| 510 | add x4, x0, x4 /* output address of final block */ |
| 511 | |
| 512 | ld1 {v1.16b}, [x1] /* load final block */ |
| 513 | ld1 {v2.16b}, [x8] |
| 514 | ld1 {v3.16b}, [x9] |
| 515 | |
| 516 | tbl v2.16b, {v0.16b}, v2.16b |
| 517 | tbx v0.16b, {v1.16b}, v3.16b |
| 518 | st1 {v2.16b}, [x4] /* overlapping stores */ |
| 519 | mov w4, wzr |
| 520 | b .Lxtsencctsout |
Mark Brown | b8e5054 | 2020-02-18 19:58:26 +0000 | [diff] [blame] | 521 | AES_FUNC_END(aes_xts_encrypt) |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 522 | |
Mark Brown | b8e5054 | 2020-02-18 19:58:26 +0000 | [diff] [blame] | 523 | AES_FUNC_START(aes_xts_decrypt) |
Ard Biesheuvel | 6e7de6a | 2018-09-10 16:41:13 +0200 | [diff] [blame] | 524 | stp x29, x30, [sp, #-16]! |
| 525 | mov x29, sp |
Ard Biesheuvel | 55868b4 | 2018-03-10 15:21:51 +0000 | [diff] [blame] | 526 | |
Ard Biesheuvel | 7cceca8 | 2019-09-03 09:43:33 -0700 | [diff] [blame] | 527 | /* subtract 16 bytes if we are doing CTS */ |
| 528 | sub w8, w4, #0x10 |
| 529 | tst w4, #0xf |
| 530 | csel w4, w4, w8, eq |
| 531 | |
Ard Biesheuvel | 6e7de6a | 2018-09-10 16:41:13 +0200 | [diff] [blame] | 532 | ld1 {v4.16b}, [x6] |
Ard Biesheuvel | cc3cc48 | 2018-10-08 13:16:59 +0200 | [diff] [blame] | 533 | xts_load_mask v8 |
Ard Biesheuvel | 67cfa5d | 2019-09-03 09:43:34 -0700 | [diff] [blame] | 534 | xts_cts_skip_tw w7, .Lxtsdecskiptw |
Ard Biesheuvel | 6833817 | 2018-03-10 15:21:48 +0000 | [diff] [blame] | 535 | cbz w7, .Lxtsdecnotfirst |
| 536 | |
| 537 | enc_prepare w3, x5, x8 |
| 538 | encrypt_block v4, w3, x5, x8, w7 /* first tweak */ |
Ard Biesheuvel | 67cfa5d | 2019-09-03 09:43:34 -0700 | [diff] [blame] | 539 | .Lxtsdecskiptw: |
Ard Biesheuvel | 6833817 | 2018-03-10 15:21:48 +0000 | [diff] [blame] | 540 | dec_prepare w3, x2, x8 |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 541 | b .LxtsdecNx |
| 542 | |
Ard Biesheuvel | 6833817 | 2018-03-10 15:21:48 +0000 | [diff] [blame] | 543 | .Lxtsdecnotfirst: |
Ard Biesheuvel | 6e7de6a | 2018-09-10 16:41:13 +0200 | [diff] [blame] | 544 | dec_prepare w3, x2, x8 |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 545 | .LxtsdecloopNx: |
Ard Biesheuvel | 2e5d2f3 | 2018-09-10 16:41:15 +0200 | [diff] [blame] | 546 | next_tweak v4, v4, v8 |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 547 | .LxtsdecNx: |
Ard Biesheuvel | 7cceca8 | 2019-09-03 09:43:33 -0700 | [diff] [blame] | 548 | subs w4, w4, #64 |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 549 | bmi .Lxtsdec1x |
Ard Biesheuvel | 6e7de6a | 2018-09-10 16:41:13 +0200 | [diff] [blame] | 550 | ld1 {v0.16b-v3.16b}, [x1], #64 /* get 4 ct blocks */ |
Ard Biesheuvel | 2e5d2f3 | 2018-09-10 16:41:15 +0200 | [diff] [blame] | 551 | next_tweak v5, v4, v8 |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 552 | eor v0.16b, v0.16b, v4.16b |
Ard Biesheuvel | 2e5d2f3 | 2018-09-10 16:41:15 +0200 | [diff] [blame] | 553 | next_tweak v6, v5, v8 |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 554 | eor v1.16b, v1.16b, v5.16b |
| 555 | eor v2.16b, v2.16b, v6.16b |
Ard Biesheuvel | 2e5d2f3 | 2018-09-10 16:41:15 +0200 | [diff] [blame] | 556 | next_tweak v7, v6, v8 |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 557 | eor v3.16b, v3.16b, v7.16b |
Ard Biesheuvel | 55868b4 | 2018-03-10 15:21:51 +0000 | [diff] [blame] | 558 | bl aes_decrypt_block4x |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 559 | eor v3.16b, v3.16b, v7.16b |
| 560 | eor v0.16b, v0.16b, v4.16b |
| 561 | eor v1.16b, v1.16b, v5.16b |
| 562 | eor v2.16b, v2.16b, v6.16b |
Ard Biesheuvel | 6e7de6a | 2018-09-10 16:41:13 +0200 | [diff] [blame] | 563 | st1 {v0.16b-v3.16b}, [x0], #64 |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 564 | mov v4.16b, v7.16b |
Ard Biesheuvel | 6e7de6a | 2018-09-10 16:41:13 +0200 | [diff] [blame] | 565 | cbz w4, .Lxtsdecout |
Ard Biesheuvel | cc3cc48 | 2018-10-08 13:16:59 +0200 | [diff] [blame] | 566 | xts_reload_mask v8 |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 567 | b .LxtsdecloopNx |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 568 | .Lxtsdec1x: |
Ard Biesheuvel | 7cceca8 | 2019-09-03 09:43:33 -0700 | [diff] [blame] | 569 | adds w4, w4, #64 |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 570 | beq .Lxtsdecout |
Ard Biesheuvel | 7cceca8 | 2019-09-03 09:43:33 -0700 | [diff] [blame] | 571 | subs w4, w4, #16 |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 572 | .Lxtsdecloop: |
Ard Biesheuvel | 7cceca8 | 2019-09-03 09:43:33 -0700 | [diff] [blame] | 573 | ld1 {v0.16b}, [x1], #16 |
| 574 | bmi .Lxtsdeccts |
| 575 | .Lxtsdecctsout: |
| 576 | eor v0.16b, v0.16b, v4.16b |
Ard Biesheuvel | 6e7de6a | 2018-09-10 16:41:13 +0200 | [diff] [blame] | 577 | decrypt_block v0, w3, x2, x8, w7 |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 578 | eor v0.16b, v0.16b, v4.16b |
Ard Biesheuvel | 6e7de6a | 2018-09-10 16:41:13 +0200 | [diff] [blame] | 579 | st1 {v0.16b}, [x0], #16 |
Ard Biesheuvel | 7cceca8 | 2019-09-03 09:43:33 -0700 | [diff] [blame] | 580 | cbz w4, .Lxtsdecout |
| 581 | subs w4, w4, #16 |
Ard Biesheuvel | 2e5d2f3 | 2018-09-10 16:41:15 +0200 | [diff] [blame] | 582 | next_tweak v4, v4, v8 |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 583 | b .Lxtsdecloop |
| 584 | .Lxtsdecout: |
Ard Biesheuvel | 6e7de6a | 2018-09-10 16:41:13 +0200 | [diff] [blame] | 585 | st1 {v4.16b}, [x6] |
| 586 | ldp x29, x30, [sp], #16 |
Ard Biesheuvel | 49788fe | 2014-03-21 10:19:17 +0100 | [diff] [blame] | 587 | ret |
Ard Biesheuvel | 7cceca8 | 2019-09-03 09:43:33 -0700 | [diff] [blame] | 588 | |
| 589 | .Lxtsdeccts: |
| 590 | adr_l x8, .Lcts_permute_table |
| 591 | |
| 592 | add x1, x1, w4, sxtw /* rewind input pointer */ |
| 593 | add w4, w4, #16 /* # bytes in final block */ |
| 594 | add x9, x8, #32 |
| 595 | add x8, x8, x4 |
| 596 | sub x9, x9, x4 |
| 597 | add x4, x0, x4 /* output address of final block */ |
| 598 | |
| 599 | next_tweak v5, v4, v8 |
| 600 | |
| 601 | ld1 {v1.16b}, [x1] /* load final block */ |
| 602 | ld1 {v2.16b}, [x8] |
| 603 | ld1 {v3.16b}, [x9] |
| 604 | |
| 605 | eor v0.16b, v0.16b, v5.16b |
| 606 | decrypt_block v0, w3, x2, x8, w7 |
| 607 | eor v0.16b, v0.16b, v5.16b |
| 608 | |
| 609 | tbl v2.16b, {v0.16b}, v2.16b |
| 610 | tbx v0.16b, {v1.16b}, v3.16b |
| 611 | |
| 612 | st1 {v2.16b}, [x4] /* overlapping stores */ |
| 613 | mov w4, wzr |
| 614 | b .Lxtsdecctsout |
Mark Brown | b8e5054 | 2020-02-18 19:58:26 +0000 | [diff] [blame] | 615 | AES_FUNC_END(aes_xts_decrypt) |
Ard Biesheuvel | 4860620 | 2017-02-03 14:49:37 +0000 | [diff] [blame] | 616 | |
| 617 | /* |
| 618 | * aes_mac_update(u8 const in[], u32 const rk[], int rounds, |
| 619 | * int blocks, u8 dg[], int enc_before, int enc_after) |
| 620 | */ |
Mark Brown | b8e5054 | 2020-02-18 19:58:26 +0000 | [diff] [blame] | 621 | AES_FUNC_START(aes_mac_update) |
Ard Biesheuvel | 0c8f838 | 2018-04-30 18:18:24 +0200 | [diff] [blame] | 622 | frame_push 6 |
| 623 | |
| 624 | mov x19, x0 |
| 625 | mov x20, x1 |
| 626 | mov x21, x2 |
| 627 | mov x22, x3 |
| 628 | mov x23, x4 |
| 629 | mov x24, x6 |
| 630 | |
| 631 | ld1 {v0.16b}, [x23] /* get dg */ |
Ard Biesheuvel | 4860620 | 2017-02-03 14:49:37 +0000 | [diff] [blame] | 632 | enc_prepare w2, x1, x7 |
Ard Biesheuvel | 870c163 | 2018-03-10 15:21:53 +0000 | [diff] [blame] | 633 | cbz w5, .Lmacloop4x |
Ard Biesheuvel | 4860620 | 2017-02-03 14:49:37 +0000 | [diff] [blame] | 634 | |
Ard Biesheuvel | 870c163 | 2018-03-10 15:21:53 +0000 | [diff] [blame] | 635 | encrypt_block v0, w2, x1, x7, w8 |
| 636 | |
| 637 | .Lmacloop4x: |
Ard Biesheuvel | 0c8f838 | 2018-04-30 18:18:24 +0200 | [diff] [blame] | 638 | subs w22, w22, #4 |
Ard Biesheuvel | 870c163 | 2018-03-10 15:21:53 +0000 | [diff] [blame] | 639 | bmi .Lmac1x |
Ard Biesheuvel | 0c8f838 | 2018-04-30 18:18:24 +0200 | [diff] [blame] | 640 | ld1 {v1.16b-v4.16b}, [x19], #64 /* get next pt block */ |
Ard Biesheuvel | 870c163 | 2018-03-10 15:21:53 +0000 | [diff] [blame] | 641 | eor v0.16b, v0.16b, v1.16b /* ..and xor with dg */ |
Ard Biesheuvel | 0c8f838 | 2018-04-30 18:18:24 +0200 | [diff] [blame] | 642 | encrypt_block v0, w21, x20, x7, w8 |
Ard Biesheuvel | 870c163 | 2018-03-10 15:21:53 +0000 | [diff] [blame] | 643 | eor v0.16b, v0.16b, v2.16b |
Ard Biesheuvel | 0c8f838 | 2018-04-30 18:18:24 +0200 | [diff] [blame] | 644 | encrypt_block v0, w21, x20, x7, w8 |
Ard Biesheuvel | 870c163 | 2018-03-10 15:21:53 +0000 | [diff] [blame] | 645 | eor v0.16b, v0.16b, v3.16b |
Ard Biesheuvel | 0c8f838 | 2018-04-30 18:18:24 +0200 | [diff] [blame] | 646 | encrypt_block v0, w21, x20, x7, w8 |
Ard Biesheuvel | 870c163 | 2018-03-10 15:21:53 +0000 | [diff] [blame] | 647 | eor v0.16b, v0.16b, v4.16b |
Ard Biesheuvel | 0c8f838 | 2018-04-30 18:18:24 +0200 | [diff] [blame] | 648 | cmp w22, wzr |
| 649 | csinv x5, x24, xzr, eq |
Ard Biesheuvel | 870c163 | 2018-03-10 15:21:53 +0000 | [diff] [blame] | 650 | cbz w5, .Lmacout |
Ard Biesheuvel | 0c8f838 | 2018-04-30 18:18:24 +0200 | [diff] [blame] | 651 | encrypt_block v0, w21, x20, x7, w8 |
| 652 | st1 {v0.16b}, [x23] /* return dg */ |
| 653 | cond_yield_neon .Lmacrestart |
Ard Biesheuvel | 870c163 | 2018-03-10 15:21:53 +0000 | [diff] [blame] | 654 | b .Lmacloop4x |
| 655 | .Lmac1x: |
Ard Biesheuvel | 0c8f838 | 2018-04-30 18:18:24 +0200 | [diff] [blame] | 656 | add w22, w22, #4 |
Ard Biesheuvel | 4860620 | 2017-02-03 14:49:37 +0000 | [diff] [blame] | 657 | .Lmacloop: |
Ard Biesheuvel | 0c8f838 | 2018-04-30 18:18:24 +0200 | [diff] [blame] | 658 | cbz w22, .Lmacout |
| 659 | ld1 {v1.16b}, [x19], #16 /* get next pt block */ |
Ard Biesheuvel | 4860620 | 2017-02-03 14:49:37 +0000 | [diff] [blame] | 660 | eor v0.16b, v0.16b, v1.16b /* ..and xor with dg */ |
| 661 | |
Ard Biesheuvel | 0c8f838 | 2018-04-30 18:18:24 +0200 | [diff] [blame] | 662 | subs w22, w22, #1 |
| 663 | csinv x5, x24, xzr, eq |
Ard Biesheuvel | 4860620 | 2017-02-03 14:49:37 +0000 | [diff] [blame] | 664 | cbz w5, .Lmacout |
| 665 | |
Ard Biesheuvel | 0c8f838 | 2018-04-30 18:18:24 +0200 | [diff] [blame] | 666 | .Lmacenc: |
| 667 | encrypt_block v0, w21, x20, x7, w8 |
Ard Biesheuvel | 4860620 | 2017-02-03 14:49:37 +0000 | [diff] [blame] | 668 | b .Lmacloop |
| 669 | |
| 670 | .Lmacout: |
Ard Biesheuvel | 0c8f838 | 2018-04-30 18:18:24 +0200 | [diff] [blame] | 671 | st1 {v0.16b}, [x23] /* return dg */ |
| 672 | frame_pop |
Ard Biesheuvel | 4860620 | 2017-02-03 14:49:37 +0000 | [diff] [blame] | 673 | ret |
Ard Biesheuvel | 0c8f838 | 2018-04-30 18:18:24 +0200 | [diff] [blame] | 674 | |
| 675 | .Lmacrestart: |
| 676 | ld1 {v0.16b}, [x23] /* get dg */ |
| 677 | enc_prepare w21, x20, x0 |
| 678 | b .Lmacloop4x |
Mark Brown | b8e5054 | 2020-02-18 19:58:26 +0000 | [diff] [blame] | 679 | AES_FUNC_END(aes_mac_update) |