1 /*
2 * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7 #define CC_PAL_LOG_CUR_COMPONENT CC_LOG_MASK_CC_API
8
9 #include "mbedtls_cc_poly.h"
10 #include "poly.h"
11 #include "mbedtls_cc_poly_error.h"
12
13
mbedtls_poly(mbedtls_poly_key pKey,uint8_t * pDataIn,size_t dataInSize,mbedtls_poly_mac macRes)14 CIMPORT_C CCError_t mbedtls_poly(
15 mbedtls_poly_key pKey,
16 uint8_t *pDataIn,
17 size_t dataInSize,
18 mbedtls_poly_mac macRes)
19
20 {
21 CCError_t rc;
22
23 // Verify inputs
24 if (pKey == NULL) {
25 return CC_POLY_KEY_INVALID_ERROR;
26 }
27 if ((macRes == NULL) ||
28 ((pDataIn == NULL) ^ (dataInSize == 0)) ||
29 (dataInSize > CC_MAX_UINT32_VAL)) {
30 return CC_POLY_DATA_INVALID_ERROR;
31 }
32
33 // calculate teh MAC using PKA
34 rc = PolyMacCalc(pKey, NULL, 0, pDataIn, dataInSize, macRes, false);
35 if (rc != CC_OK) {
36 return CC_POLY_RESOURCES_ERROR;
37 }
38
39 return CC_OK;
40 }
41
42