• 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 source \n
16  *
17  * History: \n
18  * 2023-03-22, Create file. \n
19  */
20 
21 #include "trng.h"
22 #include "kapi_trng.h"
23 
24 #include "sl_common.h"
25 
uapi_drv_cipher_trng_get_random(uint32_t * randnum)26 errcode_t uapi_drv_cipher_trng_get_random(uint32_t *randnum)
27 {
28     uapi_pm_add_sleep_veto(PM_SECURITY_VETO_ID);
29     int32_t ret = kapi_cipher_trng_get_random(randnum);
30     uapi_pm_remove_sleep_veto(PM_SECURITY_VETO_ID);
31     return crypto_sl_common_get_errcode(ret);
32 }
33 
uapi_drv_cipher_trng_get_random_bytes(uint8_t * randnum,uint32_t size)34 errcode_t uapi_drv_cipher_trng_get_random_bytes(uint8_t *randnum, uint32_t size)
35 {
36     uapi_pm_add_sleep_veto(PM_SECURITY_VETO_ID);
37     int32_t ret = kapi_cipher_trng_get_multi_random(size, randnum);
38     uapi_pm_remove_sleep_veto(PM_SECURITY_VETO_ID);
39     return crypto_sl_common_get_errcode(ret);
40 }