1 /*
2  * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #ifndef  _CC_UTIL_CMAC_H
8 #define  _CC_UTIL_CMAC_H
9 
10 #include "cc_util_int_defs.h"
11 
12 /*! Defines the CMAC result buffer. */
13 typedef uint8_t CCUtilAesCmacResult_t[CC_UTIL_AES_CMAC_RESULT_SIZE_IN_BYTES];
14 
15 CCUtilError_t UtilCmacBuildDataForDerivation( const uint8_t               *pLabel,
16                                              size_t                      labelSize,
17                                              const uint8_t               *pContextData,
18                                              size_t                      contextSize,
19                                              uint8_t            *pDataIn,
20                                              size_t                 *pDataInSize,
21                                              size_t                      derivedKeySize);
22 /*!
23  * This function is used to generate bytes stream for key derivation purposes.
24  * The function gets an input data and can use use one of the following keys: KDR/Session/userKey.
25  *
26  * @param[in] keyType       - UTIL_USER_KEY / UTIL_ROOT_KEY
27  * @param[in] pUserKey      - A pointer to the user's key buffer (case of CC_UTIL_USER_KEY).
28  * @param[in] pDataIn       - A pointer to input buffer.
29  * @param[in] dataInSize    - Size of data in bytes.
30  * @param[out] pCmacResult  - A pointer to output buffer 16 bytes array.
31  *
32  * @return CC_UTIL_OK on success, otherwise failure
33  *
34  */
35 CCUtilError_t UtilCmacDeriveKey(UtilKeyType_t       keyType,
36                 CCAesUserKeyData_t      *pUserKey,
37                 uint8_t         *pDataIn,
38                 size_t                  dataInSize,
39                 CCUtilAesCmacResult_t   pCmacResult);
40 
41 
42 #endif /* _CC_UTIL_CMAC_H */
43