Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /* SPDX-License-Identifier: GPL-2.0-or-later */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * AMCC SoC PPC4xx Crypto Driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Copyright (c) 2008 Applied Micro Circuits Corporation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * All rights reserved. James Hsiao <jhsiao@amcc.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  * This file defines the security context
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  * associate format.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #ifndef __CRYPTO4XX_SA_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #define __CRYPTO4XX_SA_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #define AES_IV_SIZE				16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18)  * Contents of Dynamic Security Association (SA) with all possible fields
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) union dynamic_sa_contents {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 	struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 		u32 arc4_state_ptr:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 		u32 arc4_ij_ptr:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 		u32 state_ptr:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 		u32 iv3:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 		u32 iv2:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 		u32 iv1:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 		u32 iv0:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 		u32 seq_num_mask3:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 		u32 seq_num_mask2:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 		u32 seq_num_mask1:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 		u32 seq_num_mask0:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 		u32 seq_num1:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 		u32 seq_num0:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 		u32 spi:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 		u32 outer_size:5;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 		u32 inner_size:5;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 		u32 key_size:4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 		u32 cmd_size:4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	} bf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 	u32 w;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) } __attribute__((packed));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) #define DIR_OUTBOUND				0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) #define DIR_INBOUND				1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) #define SA_OP_GROUP_BASIC			0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) #define SA_OPCODE_ENCRYPT			0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) #define SA_OPCODE_DECRYPT			0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) #define SA_OPCODE_ENCRYPT_HASH			1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) #define SA_OPCODE_HASH_DECRYPT			1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) #define SA_OPCODE_HASH				3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) #define SA_CIPHER_ALG_DES			0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) #define SA_CIPHER_ALG_3DES			1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) #define SA_CIPHER_ALG_ARC4			2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) #define SA_CIPHER_ALG_AES			3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) #define SA_CIPHER_ALG_KASUMI			4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) #define SA_CIPHER_ALG_NULL			15
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) #define SA_HASH_ALG_MD5				0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) #define SA_HASH_ALG_SHA1			1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) #define SA_HASH_ALG_GHASH			12
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) #define SA_HASH_ALG_CBC_MAC			14
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) #define SA_HASH_ALG_NULL			15
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) #define SA_HASH_ALG_SHA1_DIGEST_SIZE		20
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) #define SA_LOAD_HASH_FROM_SA			0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) #define SA_LOAD_HASH_FROM_STATE			2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) #define SA_NOT_LOAD_HASH			3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) #define SA_LOAD_IV_FROM_SA			0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) #define SA_LOAD_IV_FROM_INPUT			1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) #define SA_LOAD_IV_FROM_STATE			2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) #define SA_LOAD_IV_GEN_IV			3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) #define SA_PAD_TYPE_CONSTANT			2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) #define SA_PAD_TYPE_ZERO			3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) #define SA_PAD_TYPE_TLS				5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) #define SA_PAD_TYPE_DTLS			5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) #define SA_NOT_SAVE_HASH			0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) #define SA_SAVE_HASH				1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) #define SA_NOT_SAVE_IV				0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) #define SA_SAVE_IV				1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) #define SA_HEADER_PROC				1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) #define SA_NO_HEADER_PROC			0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) union sa_command_0 {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 		u32 scatter:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 		u32 gather:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 		u32 save_hash_state:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 		u32 save_iv:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 		u32 load_hash_state:2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 		u32 load_iv:2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 		u32 digest_len:4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 		u32 hdr_proc:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 		u32 extend_pad:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 		u32 stream_cipher_pad:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 		u32 rsv:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 		u32 hash_alg:4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 		u32 cipher_alg:4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 		u32 pad_type:2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 		u32 op_group:2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 		u32 dir:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 		u32 opcode:3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	} bf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	u32 w;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) } __attribute__((packed));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) #define CRYPTO_MODE_ECB				0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) #define CRYPTO_MODE_CBC				1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) #define CRYPTO_MODE_OFB				2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) #define CRYPTO_MODE_CFB				3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) #define CRYPTO_MODE_CTR				4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) #define CRYPTO_FEEDBACK_MODE_NO_FB		0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) #define CRYPTO_FEEDBACK_MODE_64BIT_OFB		0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) #define CRYPTO_FEEDBACK_MODE_8BIT_CFB		1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) #define CRYPTO_FEEDBACK_MODE_1BIT_CFB		2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) #define CRYPTO_FEEDBACK_MODE_128BIT_CFB		3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) #define SA_AES_KEY_LEN_128			2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) #define SA_AES_KEY_LEN_192			3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) #define SA_AES_KEY_LEN_256			4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) #define SA_REV2					1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126)  * The follow defines bits sa_command_1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127)  * In Basic hash mode  this bit define simple hash or hmac.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)  * In IPsec mode, this bit define muting control.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) #define SA_HASH_MODE_HASH			0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) #define SA_HASH_MODE_HMAC			1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) #define SA_MC_ENABLE				0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) #define SA_MC_DISABLE				1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) #define SA_NOT_COPY_HDR				0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) #define SA_COPY_HDR				1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) #define SA_NOT_COPY_PAD				0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) #define SA_COPY_PAD				1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) #define SA_NOT_COPY_PAYLOAD			0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) #define SA_COPY_PAYLOAD				1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) #define SA_EXTENDED_SN_OFF			0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) #define SA_EXTENDED_SN_ON			1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) #define SA_SEQ_MASK_OFF				0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) #define SA_SEQ_MASK_ON				1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) union sa_command_1 {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 	struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 		u32 crypto_mode31:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 		u32 save_arc4_state:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 		u32 arc4_stateful:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 		u32 key_len:5;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 		u32 hash_crypto_offset:8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 		u32 sa_rev:2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 		u32 byte_offset:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 		u32 hmac_muting:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 		u32 feedback_mode:2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 		u32 crypto_mode9_8:2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 		u32 extended_seq_num:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 		u32 seq_num_mask:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 		u32 mutable_bit_proc:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 		u32 ip_version:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 		u32 copy_pad:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 		u32 copy_payload:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 		u32 copy_hdr:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 		u32 rsv1:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 	} bf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 	u32 w;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) } __attribute__((packed));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) struct dynamic_sa_ctl {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	union dynamic_sa_contents sa_contents;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	union sa_command_0 sa_command_0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 	union sa_command_1 sa_command_1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) } __attribute__((packed));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176)  * State Record for Security Association (SA)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) struct  sa_state_record {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 	__le32 save_iv[4];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 	__le32 save_hash_byte_cnt[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 	union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 		u32 save_digest[16]; /* for MD5/SHA */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 		__le32 save_digest_le32[16]; /* GHASH / CBC */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) } __attribute__((packed));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188)  * Security Association (SA) for AES128
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) struct dynamic_sa_aes128 {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 	struct dynamic_sa_ctl	ctrl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 	__le32 key[4];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 	__le32 iv[4]; /* for CBC, OFC, and CFB mode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 	u32 state_ptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 	u32 reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) } __attribute__((packed));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) #define SA_AES128_LEN		(sizeof(struct dynamic_sa_aes128)/4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) #define SA_AES128_CONTENTS	0x3e000042
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203)  * Security Association (SA) for AES192
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) struct dynamic_sa_aes192 {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 	struct dynamic_sa_ctl ctrl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 	__le32 key[6];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 	__le32 iv[4]; /* for CBC, OFC, and CFB mode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 	u32 state_ptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 	u32 reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) } __attribute__((packed));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) #define SA_AES192_LEN		(sizeof(struct dynamic_sa_aes192)/4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) #define SA_AES192_CONTENTS	0x3e000062
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217)  * Security Association (SA) for AES256
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) struct dynamic_sa_aes256 {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 	struct dynamic_sa_ctl ctrl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 	__le32 key[8];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 	__le32 iv[4]; /* for CBC, OFC, and CFB mode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 	u32 state_ptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 	u32 reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) } __attribute__((packed));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) #define SA_AES256_LEN		(sizeof(struct dynamic_sa_aes256)/4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) #define SA_AES256_CONTENTS	0x3e000082
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) #define SA_AES_CONTENTS		0x3e000002
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232)  * Security Association (SA) for AES128 CCM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) struct dynamic_sa_aes128_ccm {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 	struct dynamic_sa_ctl ctrl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 	__le32 key[4];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 	__le32 iv[4];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 	u32 state_ptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 	u32 reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) #define SA_AES128_CCM_LEN	(sizeof(struct dynamic_sa_aes128_ccm)/4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) #define SA_AES128_CCM_CONTENTS	0x3e000042
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) #define SA_AES_CCM_CONTENTS	0x3e000002
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246)  * Security Association (SA) for AES128_GCM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) struct dynamic_sa_aes128_gcm {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 	struct dynamic_sa_ctl ctrl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 	__le32 key[4];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 	__le32 inner_digest[4];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 	__le32 iv[4];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 	u32 state_ptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 	u32 reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) #define SA_AES128_GCM_LEN	(sizeof(struct dynamic_sa_aes128_gcm)/4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) #define SA_AES128_GCM_CONTENTS	0x3e000442
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) #define SA_AES_GCM_CONTENTS	0x3e000402
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262)  * Security Association (SA) for HASH160: HMAC-SHA1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) struct dynamic_sa_hash160 {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 	struct dynamic_sa_ctl ctrl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 	__le32 inner_digest[5];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 	__le32 outer_digest[5];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 	u32 state_ptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 	u32 reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) } __attribute__((packed));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) #define SA_HASH160_LEN		(sizeof(struct dynamic_sa_hash160)/4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) #define SA_HASH160_CONTENTS     0x2000a502
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) static inline u32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) get_dynamic_sa_offset_state_ptr_field(struct dynamic_sa_ctl *cts)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 	u32 offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 	offset = cts->sa_contents.bf.key_size
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 		+ cts->sa_contents.bf.inner_size
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 		+ cts->sa_contents.bf.outer_size
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 		+ cts->sa_contents.bf.spi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 		+ cts->sa_contents.bf.seq_num0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 		+ cts->sa_contents.bf.seq_num1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 		+ cts->sa_contents.bf.seq_num_mask0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 		+ cts->sa_contents.bf.seq_num_mask1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 		+ cts->sa_contents.bf.seq_num_mask2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 		+ cts->sa_contents.bf.seq_num_mask3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 		+ cts->sa_contents.bf.iv0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 		+ cts->sa_contents.bf.iv1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 		+ cts->sa_contents.bf.iv2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 		+ cts->sa_contents.bf.iv3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 	return sizeof(struct dynamic_sa_ctl) + offset * 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) static inline __le32 *get_dynamic_sa_key_field(struct dynamic_sa_ctl *cts)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 	return (__le32 *) ((unsigned long)cts + sizeof(struct dynamic_sa_ctl));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) static inline __le32 *get_dynamic_sa_inner_digest(struct dynamic_sa_ctl *cts)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 	return (__le32 *) ((unsigned long)cts +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 		sizeof(struct dynamic_sa_ctl) +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 		cts->sa_contents.bf.key_size * 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) #endif