1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*
3  * Copyright 2019-2020 NXP
4  *
5  * MAC interface calling the HW crypto driver.
6  */
7 #ifndef __DRVCRYPT_MAC_H__
8 #define __DRVCRYPT_MAC_H__
9 
10 #include <crypto/crypto_impl.h>
11 #include <drvcrypt.h>
12 #include <tee_api_types.h>
13 
14 /*
15  * Crypto library HMAC driver allocation function prototype
16  */
17 typedef TEE_Result (*drvcrypt_mac_allocate)(struct crypto_mac_ctx **ctx,
18 					    uint32_t algo);
19 
20 /*
21  * Register a HMAC processing driver in the crypto API
22  *
23  * @allocate - Callback for driver context allocation in the crypto layer
24  */
drvcrypt_register_hmac(drvcrypt_mac_allocate allocate)25 static inline TEE_Result drvcrypt_register_hmac(drvcrypt_mac_allocate allocate)
26 {
27 	return drvcrypt_register(CRYPTO_HMAC, (void *)allocate);
28 }
29 
30 /*
31  * Register a CMAC processing driver in the crypto API
32  *
33  * @allocate - Callback for driver context allocation in the crypto layer
34  */
drvcrypt_register_cmac(drvcrypt_mac_allocate allocate)35 static inline TEE_Result drvcrypt_register_cmac(drvcrypt_mac_allocate allocate)
36 {
37 	return drvcrypt_register(CRYPTO_CMAC, (void *)allocate);
38 }
39 #endif /* __DRVCRYPT_MAC_H__ */
40