1 /* SPDX-License-Identifier: GPL-2.0-or-later * 1 2 /* 3 * AEGIS common definitions 4 * 5 * Copyright (c) 2018 Ondrej Mosnacek <omosnac 6 * Copyright (c) 2018 Red Hat, Inc. All rights 7 */ 8 9 #ifndef _CRYPTO_AEGIS_H 10 #define _CRYPTO_AEGIS_H 11 12 #include <crypto/aes.h> 13 #include <linux/bitops.h> 14 #include <linux/types.h> 15 16 #define AEGIS_BLOCK_SIZE 16 17 18 union aegis_block { 19 __le64 words64[AEGIS_BLOCK_SIZE / size 20 __le32 words32[AEGIS_BLOCK_SIZE / size 21 u8 bytes[AEGIS_BLOCK_SIZE]; 22 }; 23 24 struct aegis_state; 25 26 extern int aegis128_have_aes_insn; 27 28 #define AEGIS_BLOCK_ALIGN (__alignof__(union a 29 #define AEGIS_ALIGNED(p) IS_ALIGNED((uintptr_t 30 31 bool crypto_aegis128_have_simd(void); 32 void crypto_aegis128_update_simd(struct aegis_ 33 void crypto_aegis128_init_simd(struct aegis_st 34 const union aeg 35 const u8 *iv); 36 void crypto_aegis128_encrypt_chunk_simd(struct 37 const 38 void crypto_aegis128_decrypt_chunk_simd(struct 39 const 40 int crypto_aegis128_final_simd(struct aegis_st 41 union aegis_blo 42 unsigned int as 43 unsigned int cr 44 unsigned int au 45 46 static __always_inline void crypto_aegis_block 47 48 { 49 dst->words64[0] ^= src->words64[0]; 50 dst->words64[1] ^= src->words64[1]; 51 } 52 53 static __always_inline void crypto_aegis_block 54 55 { 56 dst->words64[0] &= src->words64[0]; 57 dst->words64[1] &= src->words64[1]; 58 } 59 60 static __always_inline void crypto_aegis_aesen 61 62 63 { 64 const u8 *s = src->bytes; 65 const u32 *t = crypto_ft_tab[0]; 66 u32 d0, d1, d2, d3; 67 68 d0 = t[s[ 0]] ^ rol32(t[s[ 5]], 8) ^ r 69 d1 = t[s[ 4]] ^ rol32(t[s[ 9]], 8) ^ r 70 d2 = t[s[ 8]] ^ rol32(t[s[13]], 8) ^ r 71 d3 = t[s[12]] ^ rol32(t[s[ 1]], 8) ^ r 72 73 dst->words32[0] = cpu_to_le32(d0) ^ ke 74 dst->words32[1] = cpu_to_le32(d1) ^ ke 75 dst->words32[2] = cpu_to_le32(d2) ^ ke 76 dst->words32[3] = cpu_to_le32(d3) ^ ke 77 } 78 79 #endif /* _CRYPTO_AEGIS_H */ 80
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.