1 /*
2  * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 /*!
8  @file
9  @brief This file contains all of the CryptoCell POLY APIs, their enums and definitions.
10  */
11 
12  /*!
13  @defgroup cc_poly CryptoCell POLY APIs
14  @brief Contains all CryptoCell POLY APIs. See mbedtls_cc_poly.h.
15 
16  @{
17  @ingroup cryptocell_api
18  @}
19  */
20 
21 #ifndef _MBEDTLS_CC_POLY_H
22 #define _MBEDTLS_CC_POLY_H
23 
24 
25 #include "cc_pal_types.h"
26 #include "cc_error.h"
27 
28 
29 #ifdef __cplusplus
30 extern "C"
31 {
32 #endif
33 
34 /************************ Defines ******************************/
35 /*! The size of the POLY key in words. */
36 #define CC_POLY_KEY_SIZE_IN_WORDS       8
37 /*! The size of the POLY key in Bytes. */
38 #define CC_POLY_KEY_SIZE_IN_BYTES       (CC_POLY_KEY_SIZE_IN_WORDS*CC_32BIT_WORD_SIZE)
39 /*! The size of the POLY MAC in words. */
40 #define CC_POLY_MAC_SIZE_IN_WORDS       4
41 /*! The size of the POLY MAC in Bytes. */
42 #define CC_POLY_MAC_SIZE_IN_BYTES       (CC_POLY_MAC_SIZE_IN_WORDS*CC_32BIT_WORD_SIZE)
43 
44 /************************ Typedefs  ****************************/
45 
46 /*! The definition of the ChaCha-MAC buffer. */
47 typedef uint32_t mbedtls_poly_mac[CC_POLY_MAC_SIZE_IN_WORDS];
48 
49 /*! The definition of the ChaCha-key buffer. */
50 typedef uint32_t mbedtls_poly_key[CC_POLY_KEY_SIZE_IN_WORDS];
51 
52 /************************ Public Functions **********************/
53 
54 /****************************************************************************************************/
55 /*!
56   @brief This function performs the POLY MAC Calculation.
57 
58   @return \c CC_OK on success.
59   @return A non-zero value on failure, as defined in mbedtls_cc_poly_error.h.
60  */
61 CIMPORT_C CCError_t  mbedtls_poly(
62         mbedtls_poly_key     pKey,         /*!< [in] A pointer to the key buffer of the user. */
63         uint8_t              *pDataIn,     /*!< [in] A pointer to the buffer of the input data to the ChaCha. Must not be null. */
64         size_t               dataInSize,   /*!< [in] The size of the input data. Must not be zero. */
65         mbedtls_poly_mac     macRes        /*!< [in/out] A pointer to the MAC-result buffer.*/
66 );
67 
68 
69 
70 #ifdef __cplusplus
71 }
72 #endif
73 
74 #endif /* #ifndef _MBEDTLS_CC_POLY_H */
75