xref: /optee_os/core/include/crypto/crypto_accel.h (revision 9f34db38245c9b3a4e6e7e63eb78a75e23ab2da3)
1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*
3  * Copyright (c) 2020-2023, Linaro Limited
4  */
5 
6 #ifndef __CRYPTO_CRYPTO_ACCEL_H
7 #define __CRYPTO_CRYPTO_ACCEL_H
8 
9 #include <tee_api_types.h>
10 
11 TEE_Result crypto_accel_aes_expand_keys(const void *key, size_t key_len,
12 					void *enc_key, void *dec_key,
13 					size_t expanded_key_len,
14 					unsigned int *round_count);
15 
16 void crypto_accel_aes_ecb_enc(void *out, const void *in, const void *key,
17 			      unsigned int round_count,
18 			      unsigned int block_count);
19 void crypto_accel_aes_ecb_dec(void *out, const void *in, const void *key,
20 			      unsigned int round_count,
21 			      unsigned int block_count);
22 
23 void crypto_accel_aes_cbc_enc(void *out, const void *in, const void *key,
24 			      unsigned int round_count,
25 			      unsigned int block_count, void *iv);
26 void crypto_accel_aes_cbc_dec(void *out, const void *in, const void *key,
27 			      unsigned int round_count,
28 			      unsigned int block_count, void *iv);
29 
30 void crypto_accel_aes_ctr_be_enc(void *out, const void *in, const void *key,
31 				 unsigned int round_count,
32 				 unsigned int block_count, void *iv);
33 
34 void crypto_accel_aes_xts_enc(void *out, const void *in, const void *key1,
35 			      unsigned int round_count,
36 			      unsigned int block_count, const void *key2,
37 			      void *tweak);
38 void crypto_accel_aes_xts_dec(void *out, const void *in, const void *key1,
39 			      unsigned int round_count,
40 			      unsigned int block_count, const void *key2,
41 			      void *tweak);
42 
43 void crypto_accel_sha1_compress(uint32_t state[5], const void *src,
44 				unsigned int block_count);
45 void crypto_accel_sha256_compress(uint32_t state[8], const void *src,
46 				  unsigned int block_count);
47 void crypto_accel_sha512_compress(uint64_t state[8], const void *src,
48 				  unsigned int block_count);
49 void crypto_accel_sha3_compress(uint64_t state[25], const void *src,
50 				unsigned int block_count,
51 				unsigned int digest_size);
52 void crypto_accel_sm3_compress(uint32_t state[8], const void *src,
53 			       unsigned int block_count);
54 
55 void crypto_accel_sm4_setkey_enc(uint32_t sk[32], const uint8_t key[16]);
56 void crypto_accel_sm4_setkey_dec(uint32_t sk[32], const uint8_t key[16]);
57 void crypto_accel_sm4_ecb_enc(void *out, const void *in, const void *key,
58 			      unsigned int len);
59 void crypto_accel_sm4_cbc_enc(void *out, const void *in, const void *key,
60 			      unsigned int len, void *iv);
61 void crypto_accel_sm4_cbc_dec(void *out, const void *in, const void *key,
62 			      unsigned int len, void *iv);
63 void crypto_accel_sm4_ctr_enc(void *out, const void *in, const void *key,
64 			      unsigned int len, void *iv);
65 void crypto_accel_sm4_xts_enc(void *out, const void *in, const void *key1,
66 			      const void *key2, unsigned int len, void *iv);
67 void crypto_accel_sm4_xts_dec(void *out, const void *in, const void *key1,
68 			      const void *key2, unsigned int len, void *iv);
69 
70 #endif /*__CRYPTO_CRYPTO_ACCEL_H*/
71