xref: /optee_os/core/include/tee/tee_cryp_utl.h (revision 6e954a6e42bd37911605d3b4cd22e4d1d23c2372)
1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*
3  * Copyright (c) 2014, Linaro Limited
4  */
5 
6 #ifndef TEE_CRYP_UTL_H
7 #define TEE_CRYP_UTL_H
8 
9 #include <tee_api_types.h>
10 #include <crypto/crypto.h>
11 
12 #if !defined(CFG_WITH_SOFTWARE_PRNG)
13 TEE_Result get_rng_array(void *buffer, int len);
14 #endif
15 
16 TEE_Result tee_hash_get_digest_size(uint32_t algo, size_t *size);
17 TEE_Result tee_hash_createdigest(uint32_t algo, const uint8_t *data,
18 				 size_t datalen, uint8_t *digest,
19 				 size_t digestlen);
20 TEE_Result tee_mac_get_digest_size(uint32_t algo, size_t *size);
21 TEE_Result tee_cipher_get_block_size(uint32_t algo, size_t *size);
22 TEE_Result tee_do_cipher_update(void *ctx, uint32_t algo,
23 				TEE_OperationMode mode, bool last_block,
24 				const uint8_t *data, size_t len, uint8_t *dst);
25 TEE_Result tee_aes_cbc_cts_update(void *cbc_ctx, void *ecb_ctx,
26 				  TEE_OperationMode mode, bool last_block,
27 				  const uint8_t *data, size_t len,
28 				  uint8_t *dst);
29 
30 /*
31  * plat_prng_add_jitter_entropy() - Adds jitter to RNG entropy pool
32  * @sid:	source ID, normally unique per location of the call
33  * @pnum:	pointer where the pool number for this @sid is stored
34  *
35  * Note that the supplied @sid controls (CRYPTO_RNG_SRC_IS_QUICK()) whether
36  * RPC is allowed to be performed or the event just will be queued for later
37  * consumption.
38  */
39 void plat_prng_add_jitter_entropy(enum crypto_rng_src sid, unsigned int *pnum);
40 
41 void plat_rng_init(void);
42 
43 #endif
44