1 // SPDX-License-Identifier: BSD-2-Clause
2 /*
3  * Copyright 2018-2019 NXP
4  *
5  * Brief   Crypto Hash interface implementation to enable HW driver.
6  */
7 #include <assert.h>
8 #include <drvcrypt.h>
9 #include <drvcrypt_hash.h>
10 #include <utee_defines.h>
11 #include <util.h>
12 
drvcrypt_hash_alloc_ctx(struct crypto_hash_ctx ** ctx,uint32_t algo)13 TEE_Result drvcrypt_hash_alloc_ctx(struct crypto_hash_ctx **ctx, uint32_t algo)
14 {
15 	TEE_Result ret = TEE_ERROR_NOT_IMPLEMENTED;
16 	hw_hash_allocate hash_alloc = NULL;
17 
18 	CRYPTO_TRACE("hash alloc_ctx algo 0x%" PRIX32, algo);
19 
20 	assert(ctx);
21 
22 	hash_alloc = drvcrypt_get_ops(CRYPTO_HASH);
23 
24 	if (hash_alloc)
25 		ret = hash_alloc(ctx, algo);
26 
27 	CRYPTO_TRACE("hash alloc_ctx ret 0x%" PRIX32, ret);
28 
29 	return ret;
30 }
31