1 /***************************************************************************//**
2 * \file cy_crypto_core_trng.h
3 * \version 2.40
4 *
5 * \brief
6 * This file provides provides constant and parameters
7 * for the API of the TRNG in the Crypto block driver.
8 *
9 ********************************************************************************
10 * Copyright 2016-2020 Cypress Semiconductor Corporation
11 * SPDX-License-Identifier: Apache-2.0
12 *
13 * Licensed under the Apache License, Version 2.0 (the "License");
14 * you may not use this file except in compliance with the License.
15 * You may obtain a copy of the License at
16 *
17 * http://www.apache.org/licenses/LICENSE-2.0
18 *
19 * Unless required by applicable law or agreed to in writing, software
20 * distributed under the License is distributed on an "AS IS" BASIS,
21 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 * See the License for the specific language governing permissions and
23 * limitations under the License.
24 *******************************************************************************/
25
26 #if !defined (CY_CRYPTO_CORE_TRNG_H)
27 #define CY_CRYPTO_CORE_TRNG_H
28
29 #include "cy_device.h"
30
31 #if defined (CY_IP_MXCRYPTO)
32
33 #include "cy_crypto_common.h"
34
35 #if defined(__cplusplus)
36 extern "C" {
37 #endif
38
39 #if (CPUSS_CRYPTO_TR == 1)
40
41 #include "cy_crypto_core_trng_v1.h"
42 #include "cy_crypto_core_trng_v2.h"
43
44 typedef cy_en_crypto_status_t (*cy_crypto_trng_func_t)(CRYPTO_Type *base,
45 uint32_t GAROPol,
46 uint32_t FIROPol,
47 uint32_t max,
48 uint32_t *randomNum);
49
50 /**
51 * \addtogroup group_crypto_lld_rng_functions
52 * \{
53 */
54
55 /*******************************************************************************
56 * Function Name: Cy_Crypto_Core_Trng
57 ****************************************************************************//**
58 *
59 * Generates a True Random Number.
60 *
61 * \param base
62 * The pointer to the CRYPTO instance.
63 *
64 * \param GAROPol
65 * The polynomial for the programmable Galois ring oscillator.
66 *
67 * \param FIROPol
68 * The polynomial for the programmable Fibonacci ring oscillator.
69 *
70 * \param max
71 * The maximum length of a random number, in the range of [0, 32] bits.
72 *
73 * \param randomNum
74 * The pointer to a generated true random number. Must be 4-byte aligned.
75 *
76 * \return
77 * \ref cy_en_crypto_status_t
78 *
79 *******************************************************************************/
Cy_Crypto_Core_Trng(CRYPTO_Type * base,uint32_t GAROPol,uint32_t FIROPol,uint32_t max,uint32_t * randomNum)80 __STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Trng(CRYPTO_Type *base,
81 uint32_t GAROPol,
82 uint32_t FIROPol,
83 uint32_t max,
84 uint32_t *randomNum)
85 {
86 cy_en_crypto_status_t tmpResult;
87 if (CY_CRYPTO_V1)
88 {
89 tmpResult = Cy_Crypto_Core_V1_Trng(base, GAROPol, FIROPol, max, randomNum);
90 }
91 else
92 {
93 tmpResult = Cy_Crypto_Core_V2_Trng(base, GAROPol, FIROPol, max, randomNum);
94 }
95 return (tmpResult);
96 }
97
98 /** \} group_crypto_lld_rng_functions */
99
100 #endif /* #if (CPUSS_CRYPTO_TR == 1) */
101
102 #if defined(__cplusplus)
103 }
104 #endif
105
106 #endif /* CY_IP_MXCRYPTO */
107
108 #endif /* #if !defined (CY_CRYPTO_CORE_TRNG_H) */
109
110
111 /* [] END OF FILE */
112