18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci/* Copyright (C) 2012-2019 ARM Limited (or its affiliates). */
38c2ecf20Sopenharmony_ci
48c2ecf20Sopenharmony_ci#ifndef _CC_CRYPTO_CTX_H_
58c2ecf20Sopenharmony_ci#define _CC_CRYPTO_CTX_H_
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ci#include <linux/types.h>
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#define CC_DRV_DES_IV_SIZE 8
108c2ecf20Sopenharmony_ci#define CC_DRV_DES_BLOCK_SIZE 8
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci#define CC_DRV_DES_ONE_KEY_SIZE 8
138c2ecf20Sopenharmony_ci#define CC_DRV_DES_DOUBLE_KEY_SIZE 16
148c2ecf20Sopenharmony_ci#define CC_DRV_DES_TRIPLE_KEY_SIZE 24
158c2ecf20Sopenharmony_ci#define CC_DRV_DES_KEY_SIZE_MAX CC_DRV_DES_TRIPLE_KEY_SIZE
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci#define CC_AES_IV_SIZE 16
188c2ecf20Sopenharmony_ci#define CC_AES_IV_SIZE_WORDS (CC_AES_IV_SIZE >> 2)
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_ci#define CC_AES_BLOCK_SIZE 16
218c2ecf20Sopenharmony_ci#define CC_AES_BLOCK_SIZE_WORDS 4
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_ci#define CC_AES_128_BIT_KEY_SIZE 16
248c2ecf20Sopenharmony_ci#define CC_AES_128_BIT_KEY_SIZE_WORDS	(CC_AES_128_BIT_KEY_SIZE >> 2)
258c2ecf20Sopenharmony_ci#define CC_AES_192_BIT_KEY_SIZE 24
268c2ecf20Sopenharmony_ci#define CC_AES_192_BIT_KEY_SIZE_WORDS	(CC_AES_192_BIT_KEY_SIZE >> 2)
278c2ecf20Sopenharmony_ci#define CC_AES_256_BIT_KEY_SIZE 32
288c2ecf20Sopenharmony_ci#define CC_AES_256_BIT_KEY_SIZE_WORDS	(CC_AES_256_BIT_KEY_SIZE >> 2)
298c2ecf20Sopenharmony_ci#define CC_AES_KEY_SIZE_MAX			CC_AES_256_BIT_KEY_SIZE
308c2ecf20Sopenharmony_ci#define CC_AES_KEY_SIZE_WORDS_MAX		(CC_AES_KEY_SIZE_MAX >> 2)
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_ci#define CC_MD5_DIGEST_SIZE	16
338c2ecf20Sopenharmony_ci#define CC_SHA1_DIGEST_SIZE	20
348c2ecf20Sopenharmony_ci#define CC_SHA224_DIGEST_SIZE	28
358c2ecf20Sopenharmony_ci#define CC_SHA256_DIGEST_SIZE	32
368c2ecf20Sopenharmony_ci#define CC_SHA256_DIGEST_SIZE_IN_WORDS 8
378c2ecf20Sopenharmony_ci#define CC_SHA384_DIGEST_SIZE	48
388c2ecf20Sopenharmony_ci#define CC_SHA512_DIGEST_SIZE	64
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_ci#define CC_SHA1_BLOCK_SIZE 64
418c2ecf20Sopenharmony_ci#define CC_SHA1_BLOCK_SIZE_IN_WORDS 16
428c2ecf20Sopenharmony_ci#define CC_MD5_BLOCK_SIZE 64
438c2ecf20Sopenharmony_ci#define CC_MD5_BLOCK_SIZE_IN_WORDS 16
448c2ecf20Sopenharmony_ci#define CC_SHA224_BLOCK_SIZE 64
458c2ecf20Sopenharmony_ci#define CC_SHA256_BLOCK_SIZE 64
468c2ecf20Sopenharmony_ci#define CC_SHA256_BLOCK_SIZE_IN_WORDS 16
478c2ecf20Sopenharmony_ci#define CC_SHA1_224_256_BLOCK_SIZE 64
488c2ecf20Sopenharmony_ci#define CC_SHA384_BLOCK_SIZE 128
498c2ecf20Sopenharmony_ci#define CC_SHA512_BLOCK_SIZE 128
508c2ecf20Sopenharmony_ci
518c2ecf20Sopenharmony_ci#define CC_DIGEST_SIZE_MAX CC_SHA512_DIGEST_SIZE
528c2ecf20Sopenharmony_ci#define CC_HASH_BLOCK_SIZE_MAX CC_SHA512_BLOCK_SIZE /*1024b*/
538c2ecf20Sopenharmony_ci
548c2ecf20Sopenharmony_ci#define CC_HMAC_BLOCK_SIZE_MAX CC_HASH_BLOCK_SIZE_MAX
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_ci#define CC_DRV_ALG_MAX_BLOCK_SIZE CC_HASH_BLOCK_SIZE_MAX
578c2ecf20Sopenharmony_ci
588c2ecf20Sopenharmony_ci#define CC_CPP_NUM_SLOTS	8
598c2ecf20Sopenharmony_ci#define CC_CPP_NUM_ALGS		2
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_cienum cc_cpp_alg {
628c2ecf20Sopenharmony_ci	CC_CPP_SM4 = 1,
638c2ecf20Sopenharmony_ci	CC_CPP_AES = 0
648c2ecf20Sopenharmony_ci};
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_cienum drv_engine_type {
678c2ecf20Sopenharmony_ci	DRV_ENGINE_NULL = 0,
688c2ecf20Sopenharmony_ci	DRV_ENGINE_AES = 1,
698c2ecf20Sopenharmony_ci	DRV_ENGINE_DES = 2,
708c2ecf20Sopenharmony_ci	DRV_ENGINE_HASH = 3,
718c2ecf20Sopenharmony_ci	DRV_ENGINE_RC4 = 4,
728c2ecf20Sopenharmony_ci	DRV_ENGINE_DOUT = 5,
738c2ecf20Sopenharmony_ci	DRV_ENGINE_RESERVE32B = S32_MAX,
748c2ecf20Sopenharmony_ci};
758c2ecf20Sopenharmony_ci
768c2ecf20Sopenharmony_cienum drv_crypto_alg {
778c2ecf20Sopenharmony_ci	DRV_CRYPTO_ALG_NULL = -1,
788c2ecf20Sopenharmony_ci	DRV_CRYPTO_ALG_AES  = 0,
798c2ecf20Sopenharmony_ci	DRV_CRYPTO_ALG_DES  = 1,
808c2ecf20Sopenharmony_ci	DRV_CRYPTO_ALG_HASH = 2,
818c2ecf20Sopenharmony_ci	DRV_CRYPTO_ALG_C2   = 3,
828c2ecf20Sopenharmony_ci	DRV_CRYPTO_ALG_HMAC = 4,
838c2ecf20Sopenharmony_ci	DRV_CRYPTO_ALG_AEAD = 5,
848c2ecf20Sopenharmony_ci	DRV_CRYPTO_ALG_BYPASS = 6,
858c2ecf20Sopenharmony_ci	DRV_CRYPTO_ALG_NUM = 7,
868c2ecf20Sopenharmony_ci	DRV_CRYPTO_ALG_RESERVE32B = S32_MAX
878c2ecf20Sopenharmony_ci};
888c2ecf20Sopenharmony_ci
898c2ecf20Sopenharmony_cienum drv_crypto_direction {
908c2ecf20Sopenharmony_ci	DRV_CRYPTO_DIRECTION_NULL = -1,
918c2ecf20Sopenharmony_ci	DRV_CRYPTO_DIRECTION_ENCRYPT = 0,
928c2ecf20Sopenharmony_ci	DRV_CRYPTO_DIRECTION_DECRYPT = 1,
938c2ecf20Sopenharmony_ci	DRV_CRYPTO_DIRECTION_DECRYPT_ENCRYPT = 3,
948c2ecf20Sopenharmony_ci	DRV_CRYPTO_DIRECTION_RESERVE32B = S32_MAX
958c2ecf20Sopenharmony_ci};
968c2ecf20Sopenharmony_ci
978c2ecf20Sopenharmony_cienum drv_cipher_mode {
988c2ecf20Sopenharmony_ci	DRV_CIPHER_NULL_MODE = -1,
998c2ecf20Sopenharmony_ci	DRV_CIPHER_ECB = 0,
1008c2ecf20Sopenharmony_ci	DRV_CIPHER_CBC = 1,
1018c2ecf20Sopenharmony_ci	DRV_CIPHER_CTR = 2,
1028c2ecf20Sopenharmony_ci	DRV_CIPHER_CBC_MAC = 3,
1038c2ecf20Sopenharmony_ci	DRV_CIPHER_XTS = 4,
1048c2ecf20Sopenharmony_ci	DRV_CIPHER_XCBC_MAC = 5,
1058c2ecf20Sopenharmony_ci	DRV_CIPHER_OFB = 6,
1068c2ecf20Sopenharmony_ci	DRV_CIPHER_CMAC = 7,
1078c2ecf20Sopenharmony_ci	DRV_CIPHER_CCM = 8,
1088c2ecf20Sopenharmony_ci	DRV_CIPHER_CBC_CTS = 11,
1098c2ecf20Sopenharmony_ci	DRV_CIPHER_GCTR = 12,
1108c2ecf20Sopenharmony_ci	DRV_CIPHER_ESSIV = 13,
1118c2ecf20Sopenharmony_ci	DRV_CIPHER_RESERVE32B = S32_MAX
1128c2ecf20Sopenharmony_ci};
1138c2ecf20Sopenharmony_ci
1148c2ecf20Sopenharmony_cienum drv_hash_mode {
1158c2ecf20Sopenharmony_ci	DRV_HASH_NULL = -1,
1168c2ecf20Sopenharmony_ci	DRV_HASH_SHA1 = 0,
1178c2ecf20Sopenharmony_ci	DRV_HASH_SHA256 = 1,
1188c2ecf20Sopenharmony_ci	DRV_HASH_SHA224 = 2,
1198c2ecf20Sopenharmony_ci	DRV_HASH_SHA512 = 3,
1208c2ecf20Sopenharmony_ci	DRV_HASH_SHA384 = 4,
1218c2ecf20Sopenharmony_ci	DRV_HASH_MD5 = 5,
1228c2ecf20Sopenharmony_ci	DRV_HASH_CBC_MAC = 6,
1238c2ecf20Sopenharmony_ci	DRV_HASH_XCBC_MAC = 7,
1248c2ecf20Sopenharmony_ci	DRV_HASH_CMAC = 8,
1258c2ecf20Sopenharmony_ci	DRV_HASH_SM3 = 9,
1268c2ecf20Sopenharmony_ci	DRV_HASH_MODE_NUM = 10,
1278c2ecf20Sopenharmony_ci	DRV_HASH_RESERVE32B = S32_MAX
1288c2ecf20Sopenharmony_ci};
1298c2ecf20Sopenharmony_ci
1308c2ecf20Sopenharmony_cienum drv_hash_hw_mode {
1318c2ecf20Sopenharmony_ci	DRV_HASH_HW_MD5 = 0,
1328c2ecf20Sopenharmony_ci	DRV_HASH_HW_SHA1 = 1,
1338c2ecf20Sopenharmony_ci	DRV_HASH_HW_SHA256 = 2,
1348c2ecf20Sopenharmony_ci	DRV_HASH_HW_SHA224 = 10,
1358c2ecf20Sopenharmony_ci	DRV_HASH_HW_SHA512 = 4,
1368c2ecf20Sopenharmony_ci	DRV_HASH_HW_SHA384 = 12,
1378c2ecf20Sopenharmony_ci	DRV_HASH_HW_GHASH = 6,
1388c2ecf20Sopenharmony_ci	DRV_HASH_HW_SM3 = 14,
1398c2ecf20Sopenharmony_ci	DRV_HASH_HW_RESERVE32B = S32_MAX
1408c2ecf20Sopenharmony_ci};
1418c2ecf20Sopenharmony_ci
1428c2ecf20Sopenharmony_ci#endif /* _CC_CRYPTO_CTX_H_ */
143