~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/arm64/crypto/aes-ce.S

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: GPL-2.0-only */
  2 /*
  3  * linux/arch/arm64/crypto/aes-ce.S - AES cipher for ARMv8 with
  4  *                                    Crypto Extensions
  5  *
  6  * Copyright (C) 2013 - 2017 Linaro Ltd <ard.biesheuvel@linaro.org>
  7  */
  8 
  9 #include <linux/linkage.h>
 10 #include <asm/assembler.h>
 11 
 12 #define AES_FUNC_START(func)            SYM_FUNC_START(ce_ ## func)
 13 #define AES_FUNC_END(func)              SYM_FUNC_END(ce_ ## func)
 14 
 15         .arch           armv8-a+crypto
 16 
 17         xtsmask         .req    v16
 18         cbciv           .req    v16
 19         vctr            .req    v16
 20 
 21         .macro          xts_reload_mask, tmp
 22         .endm
 23 
 24         .macro          xts_cts_skip_tw, reg, lbl
 25         .endm
 26 
 27         /* preload all round keys */
 28         .macro          load_round_keys, rk, nr, tmp
 29         add             \tmp, \rk, \nr, sxtw #4
 30         sub             \tmp, \tmp, #160
 31         ld1             {v17.4s-v20.4s}, [\rk]
 32         ld1             {v21.4s-v24.4s}, [\tmp], #64
 33         ld1             {v25.4s-v28.4s}, [\tmp], #64
 34         ld1             {v29.4s-v31.4s}, [\tmp]
 35         .endm
 36 
 37         /* prepare for encryption with key in rk[] */
 38         .macro          enc_prepare, rounds, rk, temp
 39         load_round_keys \rk, \rounds, \temp
 40         .endm
 41 
 42         /* prepare for encryption (again) but with new key in rk[] */
 43         .macro          enc_switch_key, rounds, rk, temp
 44         load_round_keys \rk, \rounds, \temp
 45         .endm
 46 
 47         /* prepare for decryption with key in rk[] */
 48         .macro          dec_prepare, rounds, rk, temp
 49         load_round_keys \rk, \rounds, \temp
 50         .endm
 51 
 52         .macro          do_enc_Nx, de, mc, k, i0, i1, i2, i3, i4
 53         aes\de          \i0\().16b, \k\().16b
 54         aes\mc          \i0\().16b, \i0\().16b
 55         .ifnb           \i1
 56         aes\de          \i1\().16b, \k\().16b
 57         aes\mc          \i1\().16b, \i1\().16b
 58         .ifnb           \i3
 59         aes\de          \i2\().16b, \k\().16b
 60         aes\mc          \i2\().16b, \i2\().16b
 61         aes\de          \i3\().16b, \k\().16b
 62         aes\mc          \i3\().16b, \i3\().16b
 63         .ifnb           \i4
 64         aes\de          \i4\().16b, \k\().16b
 65         aes\mc          \i4\().16b, \i4\().16b
 66         .endif
 67         .endif
 68         .endif
 69         .endm
 70 
 71         /* up to 5 interleaved encryption rounds with the same round key */
 72         .macro          round_Nx, enc, k, i0, i1, i2, i3, i4
 73         .ifc            \enc, e
 74         do_enc_Nx       e, mc, \k, \i0, \i1, \i2, \i3, \i4
 75         .else
 76         do_enc_Nx       d, imc, \k, \i0, \i1, \i2, \i3, \i4
 77         .endif
 78         .endm
 79 
 80         /* up to 5 interleaved final rounds */
 81         .macro          fin_round_Nx, de, k, k2, i0, i1, i2, i3, i4
 82         aes\de          \i0\().16b, \k\().16b
 83         .ifnb           \i1
 84         aes\de          \i1\().16b, \k\().16b
 85         .ifnb           \i3
 86         aes\de          \i2\().16b, \k\().16b
 87         aes\de          \i3\().16b, \k\().16b
 88         .ifnb           \i4
 89         aes\de          \i4\().16b, \k\().16b
 90         .endif
 91         .endif
 92         .endif
 93         eor             \i0\().16b, \i0\().16b, \k2\().16b
 94         .ifnb           \i1
 95         eor             \i1\().16b, \i1\().16b, \k2\().16b
 96         .ifnb           \i3
 97         eor             \i2\().16b, \i2\().16b, \k2\().16b
 98         eor             \i3\().16b, \i3\().16b, \k2\().16b
 99         .ifnb           \i4
100         eor             \i4\().16b, \i4\().16b, \k2\().16b
101         .endif
102         .endif
103         .endif
104         .endm
105 
106         /* up to 5 interleaved blocks */
107         .macro          do_block_Nx, enc, rounds, i0, i1, i2, i3, i4
108         tbz             \rounds, #2, .L\@       /* 128 bits */
109         round_Nx        \enc, v17, \i0, \i1, \i2, \i3, \i4
110         round_Nx        \enc, v18, \i0, \i1, \i2, \i3, \i4
111         tbz             \rounds, #1, .L\@       /* 192 bits */
112         round_Nx        \enc, v19, \i0, \i1, \i2, \i3, \i4
113         round_Nx        \enc, v20, \i0, \i1, \i2, \i3, \i4
114 .L\@:   .irp            key, v21, v22, v23, v24, v25, v26, v27, v28, v29
115         round_Nx        \enc, \key, \i0, \i1, \i2, \i3, \i4
116         .endr
117         fin_round_Nx    \enc, v30, v31, \i0, \i1, \i2, \i3, \i4
118         .endm
119 
120         .macro          encrypt_block, in, rounds, t0, t1, t2
121         do_block_Nx     e, \rounds, \in
122         .endm
123 
124         .macro          encrypt_block4x, i0, i1, i2, i3, rounds, t0, t1, t2
125         do_block_Nx     e, \rounds, \i0, \i1, \i2, \i3
126         .endm
127 
128         .macro          encrypt_block5x, i0, i1, i2, i3, i4, rounds, t0, t1, t2
129         do_block_Nx     e, \rounds, \i0, \i1, \i2, \i3, \i4
130         .endm
131 
132         .macro          decrypt_block, in, rounds, t0, t1, t2
133         do_block_Nx     d, \rounds, \in
134         .endm
135 
136         .macro          decrypt_block4x, i0, i1, i2, i3, rounds, t0, t1, t2
137         do_block_Nx     d, \rounds, \i0, \i1, \i2, \i3
138         .endm
139 
140         .macro          decrypt_block5x, i0, i1, i2, i3, i4, rounds, t0, t1, t2
141         do_block_Nx     d, \rounds, \i0, \i1, \i2, \i3, \i4
142         .endm
143 
144 #define MAX_STRIDE      5
145 
146 #include "aes-modes.S"

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php