Path: blob/master/drivers/crypto/amcc/crypto4xx_sa.h
15111 views
/**1* AMCC SoC PPC4xx Crypto Driver2*3* Copyright (c) 2008 Applied Micro Circuits Corporation.4* All rights reserved. James Hsiao <[email protected]>5*6* This program is free software; you can redistribute it and/or modify7* it under the terms of the GNU General Public License as published by8* the Free Software Foundation; either version 2 of the License, or9* (at your option) any later version.10*11* This program is distributed in the hope that it will be useful,12* but WITHOUT ANY WARRANTY; without even the implied warranty of13* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the14* GNU General Public License for more details.15*16* This file defines the security context17* associate format.18*/1920#ifndef __CRYPTO4XX_SA_H__21#define __CRYPTO4XX_SA_H__2223#define AES_IV_SIZE 162425/**26* Contents of Dynamic Security Association (SA) with all possible fields27*/28union dynamic_sa_contents {29struct {30u32 arc4_state_ptr:1;31u32 arc4_ij_ptr:1;32u32 state_ptr:1;33u32 iv3:1;34u32 iv2:1;35u32 iv1:1;36u32 iv0:1;37u32 seq_num_mask3:1;38u32 seq_num_mask2:1;39u32 seq_num_mask1:1;40u32 seq_num_mask0:1;41u32 seq_num1:1;42u32 seq_num0:1;43u32 spi:1;44u32 outer_size:5;45u32 inner_size:5;46u32 key_size:4;47u32 cmd_size:4;48} bf;49u32 w;50} __attribute__((packed));5152#define DIR_OUTBOUND 053#define DIR_INBOUND 154#define SA_OP_GROUP_BASIC 055#define SA_OPCODE_ENCRYPT 056#define SA_OPCODE_DECRYPT 057#define SA_OPCODE_HASH 358#define SA_CIPHER_ALG_DES 059#define SA_CIPHER_ALG_3DES 160#define SA_CIPHER_ALG_ARC4 261#define SA_CIPHER_ALG_AES 362#define SA_CIPHER_ALG_KASUMI 463#define SA_CIPHER_ALG_NULL 156465#define SA_HASH_ALG_MD5 066#define SA_HASH_ALG_SHA1 167#define SA_HASH_ALG_NULL 1568#define SA_HASH_ALG_SHA1_DIGEST_SIZE 206970#define SA_LOAD_HASH_FROM_SA 071#define SA_LOAD_HASH_FROM_STATE 272#define SA_NOT_LOAD_HASH 373#define SA_LOAD_IV_FROM_SA 074#define SA_LOAD_IV_FROM_INPUT 175#define SA_LOAD_IV_FROM_STATE 276#define SA_LOAD_IV_GEN_IV 37778#define SA_PAD_TYPE_CONSTANT 279#define SA_PAD_TYPE_ZERO 380#define SA_PAD_TYPE_TLS 581#define SA_PAD_TYPE_DTLS 582#define SA_NOT_SAVE_HASH 083#define SA_SAVE_HASH 184#define SA_NOT_SAVE_IV 085#define SA_SAVE_IV 186#define SA_HEADER_PROC 187#define SA_NO_HEADER_PROC 08889union sa_command_0 {90struct {91u32 scatter:1;92u32 gather:1;93u32 save_hash_state:1;94u32 save_iv:1;95u32 load_hash_state:2;96u32 load_iv:2;97u32 digest_len:4;98u32 hdr_proc:1;99u32 extend_pad:1;100u32 stream_cipher_pad:1;101u32 rsv:1;102u32 hash_alg:4;103u32 cipher_alg:4;104u32 pad_type:2;105u32 op_group:2;106u32 dir:1;107u32 opcode:3;108} bf;109u32 w;110} __attribute__((packed));111112#define CRYPTO_MODE_ECB 0113#define CRYPTO_MODE_CBC 1114115#define CRYPTO_FEEDBACK_MODE_NO_FB 0116#define CRYPTO_FEEDBACK_MODE_64BIT_OFB 0117#define CRYPTO_FEEDBACK_MODE_8BIT_CFB 1118#define CRYPTO_FEEDBACK_MODE_1BIT_CFB 2119#define CRYPTO_FEEDBACK_MODE_128BIT_CFB 3120121#define SA_AES_KEY_LEN_128 2122#define SA_AES_KEY_LEN_192 3123#define SA_AES_KEY_LEN_256 4124125#define SA_REV2 1126/**127* The follow defines bits sa_command_1128* In Basic hash mode this bit define simple hash or hmac.129* In IPsec mode, this bit define muting control.130*/131#define SA_HASH_MODE_HASH 0132#define SA_HASH_MODE_HMAC 1133#define SA_MC_ENABLE 0134#define SA_MC_DISABLE 1135#define SA_NOT_COPY_HDR 0136#define SA_COPY_HDR 1137#define SA_NOT_COPY_PAD 0138#define SA_COPY_PAD 1139#define SA_NOT_COPY_PAYLOAD 0140#define SA_COPY_PAYLOAD 1141#define SA_EXTENDED_SN_OFF 0142#define SA_EXTENDED_SN_ON 1143#define SA_SEQ_MASK_OFF 0144#define SA_SEQ_MASK_ON 1145146union sa_command_1 {147struct {148u32 crypto_mode31:1;149u32 save_arc4_state:1;150u32 arc4_stateful:1;151u32 key_len:5;152u32 hash_crypto_offset:8;153u32 sa_rev:2;154u32 byte_offset:1;155u32 hmac_muting:1;156u32 feedback_mode:2;157u32 crypto_mode9_8:2;158u32 extended_seq_num:1;159u32 seq_num_mask:1;160u32 mutable_bit_proc:1;161u32 ip_version:1;162u32 copy_pad:1;163u32 copy_payload:1;164u32 copy_hdr:1;165u32 rsv1:1;166} bf;167u32 w;168} __attribute__((packed));169170struct dynamic_sa_ctl {171u32 sa_contents;172union sa_command_0 sa_command_0;173union sa_command_1 sa_command_1;174} __attribute__((packed));175176/**177* State Record for Security Association (SA)178*/179struct sa_state_record {180u32 save_iv[4];181u32 save_hash_byte_cnt[2];182u32 save_digest[16];183} __attribute__((packed));184185/**186* Security Association (SA) for AES128187*188*/189struct dynamic_sa_aes128 {190struct dynamic_sa_ctl ctrl;191u32 key[4];192u32 iv[4]; /* for CBC, OFC, and CFB mode */193u32 state_ptr;194u32 reserved;195} __attribute__((packed));196197#define SA_AES128_LEN (sizeof(struct dynamic_sa_aes128)/4)198#define SA_AES128_CONTENTS 0x3e000042199200/*201* Security Association (SA) for AES192202*/203struct dynamic_sa_aes192 {204struct dynamic_sa_ctl ctrl;205u32 key[6];206u32 iv[4]; /* for CBC, OFC, and CFB mode */207u32 state_ptr;208u32 reserved;209} __attribute__((packed));210211#define SA_AES192_LEN (sizeof(struct dynamic_sa_aes192)/4)212#define SA_AES192_CONTENTS 0x3e000062213214/**215* Security Association (SA) for AES256216*/217struct dynamic_sa_aes256 {218struct dynamic_sa_ctl ctrl;219u32 key[8];220u32 iv[4]; /* for CBC, OFC, and CFB mode */221u32 state_ptr;222u32 reserved;223} __attribute__((packed));224225#define SA_AES256_LEN (sizeof(struct dynamic_sa_aes256)/4)226#define SA_AES256_CONTENTS 0x3e000082227#define SA_AES_CONTENTS 0x3e000002228229/**230* Security Association (SA) for HASH160: HMAC-SHA1231*/232struct dynamic_sa_hash160 {233struct dynamic_sa_ctl ctrl;234u32 inner_digest[5];235u32 outer_digest[5];236u32 state_ptr;237u32 reserved;238} __attribute__((packed));239#define SA_HASH160_LEN (sizeof(struct dynamic_sa_hash160)/4)240#define SA_HASH160_CONTENTS 0x2000a502241242#endif243244245