Skip to content

Commit 109568e

Browse files
yhuang-intelherbertx
authored andcommitted
crypto: aes - Move key_length in struct crypto_aes_ctx to be the last field
The Intel AES-NI AES acceleration instructions need key_enc, key_dec in struct crypto_aes_ctx to be 16 byte aligned, it make this easier to move key_length to be the last one. Signed-off-by: Huang Ying <ying.huang@intel.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent 8eb2dfa commit 109568e

3 files changed

Lines changed: 10 additions & 6 deletions

File tree

‎arch/x86/crypto/aes-i586-asm_32.S‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@
4646
#define in_blk 16
4747

4848
/* offsets in crypto_tfm structure */
49-
#define klen (crypto_tfm_ctx_offset + 0)
50-
#define ekey (crypto_tfm_ctx_offset + 4)
51-
#define dkey (crypto_tfm_ctx_offset + 244)
49+
#define klen (crypto_tfm_ctx_offset + 480)
50+
#define ekey (crypto_tfm_ctx_offset + 0)
51+
#define dkey (crypto_tfm_ctx_offset + 240)
5252

5353
// register mapping for encrypt and decrypt subroutines
5454

‎arch/x86/crypto/aes-x86_64-asm_64.S‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,13 @@
5656
.align 8; \
5757
FUNC: movq r1,r2; \
5858
movq r3,r4; \
59-
leaq BASE+KEY+48+4(r8),r9; \
59+
leaq BASE+KEY+48(r8),r9; \
6060
movq r10,r11; \
6161
movl (r7),r5 ## E; \
6262
movl 4(r7),r1 ## E; \
6363
movl 8(r7),r6 ## E; \
6464
movl 12(r7),r7 ## E; \
65-
movl BASE+0(r8),r10 ## E; \
65+
movl BASE+480(r8),r10 ## E; \
6666
xorl -48(r9),r5 ## E; \
6767
xorl -44(r9),r1 ## E; \
6868
xorl -40(r9),r6 ## E; \

‎include/crypto/aes.h‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,14 @@
1717
#define AES_MAX_KEYLENGTH (15 * 16)
1818
#define AES_MAX_KEYLENGTH_U32 (AES_MAX_KEYLENGTH / sizeof(u32))
1919

20+
/*
21+
* Please ensure that the first two fields are 16-byte aligned
22+
* relative to the start of the structure, i.e., don't move them!
23+
*/
2024
struct crypto_aes_ctx {
21-
u32 key_length;
2225
u32 key_enc[AES_MAX_KEYLENGTH_U32];
2326
u32 key_dec[AES_MAX_KEYLENGTH_U32];
27+
u32 key_length;
2428
};
2529

2630
extern const u32 crypto_ft_tab[4][256];

0 commit comments

Comments
 (0)