1 
2 /*
3  * Copyright (c) 2023, Arm Limited. All rights reserved.
4  *
5  * SPDX-License-Identifier: BSD-3-Clause
6  *
7  */
8 
9 #ifndef CC3XX_KDF_H
10 #define CC3XX_KDF_H
11 
12 #include "cc3xx_error.h"
13 #include "cc3xx_aes.h"
14 
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18 
19 /*
20  */
21 /**
22  * @brief                        This is a counter-mode KDF complying with NIST
23  *                               SP800-108 where the PRF is a the AES cipher
24  *                               using the CMAC mode of operation as per NIST
25  *                               SP800-38B.
26  *
27  * @note                         This funtion only outputs keys whose size is a
28  *                               multiple of the output size of the AES-CMAC
29  *                               operation (16 bytes).
30  *
31  * @param[in]  key_id            Which user/hardware key should be used.
32  * @param[in]  key               If key_id is set to CC3XX_AES_KEY_ID_USER_KEY,
33  *                               this buffer contains the key material.
34  * @param[in]  key_size          The size of the key being used.
35  * @param[in]  label             The label to input into the derivation
36  *                               operation.
37  * @param[in]  label_length      The length of the label.
38  * @param[in]  context           The context to input into the derivation
39  *                               operation.
40  * @param[in]  context_length    The length of the context.
41  * @param[out] output_key        The buffer to output the key into.
42  * @param[in] out_length         The size of the key to derive.
43  *
44  * @return                       CC3XX_ERR_SUCCESS on success, another
45  *                               cc3xx_err_t on error.
46  */
47 cc3xx_err_t cc3xx_kdf_cmac(cc3xx_aes_key_id_t key_id, const uint32_t *key,
48                            cc3xx_aes_keysize_t key_size,
49                            const uint8_t *label, size_t label_length,
50                            const uint8_t *context, size_t context_length,
51                            uint32_t *output_key, size_t out_length);
52 
53 #ifdef __cplusplus
54 }
55 #endif
56 
57 #endif /* CC3XX_KDF_H */
58