• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  *
15  * Description: Provides trng driver header \n
16  *
17  * History: \n
18  * 2023-03-14, Create file. \n
19  */
20 #ifndef TRNG_H
21 #define TRNG_H
22 
23 #include <stdint.h>
24 #include "errcode.h"
25 
26 #ifdef __cplusplus
27 #if __cplusplus
28 extern "C" {
29 #endif
30 #endif
31 
32 /**
33  * @defgroup security_unified_trng Trng
34  * @ingroup  drivers_driver_security_unified
35  * @{
36  */
37 
38 /**
39  * @if Eng
40  * @brief  obtaining hardware random numbers.
41  * @note   random number of the size of the uint32_t type,generate random numbers of other sizes, which need to be
42            called cyclically.
43  * @param  [in]  randnum Pointer to the buffer where the generated random number is stored
44  * @retval ERRCODE_SUCC Success.
45  * @retval Other        Failure. For details, see @ref errcode_t
46  * @else
47  * @brief  获取硬件随机数。
48  * @note   生成uint32_t类型大小的随机数,生成其他大小的随机数,需要循环调用该接口。
49  * @param  [in]  randnum 指向存储生成的随机数的缓冲区的指针。
50  * @retval ERRCODE_SUCC 成功。
51  * @retval Other        失败,参考 @ref errcode_t 。
52  * @endif
53  */
54 errcode_t uapi_drv_cipher_trng_get_random(uint32_t *randnum);
55 
56 /**
57  * @if Eng
58  * @brief  obtains a hardware random number of a specified size.
59  * @param  [in]  randnum Pointer to the buffer where the generated random number is stored.
60  * @param  [in]  size Size of the generated random number.
61  * @retval ERRCODE_SUCC Success.
62  * @retval Other        Failure. For details, see @ref errcode_t
63  * @else
64  * @brief  获取指定大小的硬件随机数。
65  * @param  [in]  randnum 指向存储生成的随机数的缓冲区的指针。
66  * @param  [in]  size 生成随机数的大小。
67  * @retval ERRCODE_SUCC 成功。
68  * @retval Other        失败,参考 @ref errcode_t 。
69  * @endif
70  */
71 errcode_t uapi_drv_cipher_trng_get_random_bytes(uint8_t *randnum, uint32_t size);
72 
73 /**
74  * @}
75  */
76 
77 #ifdef __cplusplus
78 #if __cplusplus
79 }
80 #endif
81 #endif
82 
83 #endif
84