1 // Copyright (C) 2022 Beken Corporation 2 // 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 #pragma once 16 17 #include "securityip_types.h" 18 19 #ifdef __cplusplus 20 extern "C" { 21 #endif 22 23 24 /* @brief Overview about this API header 25 * 26 */ 27 28 /** 29 * @brief VAULT API 30 * @defgroup bk_api_vault VAULT API group 31 * @{ 32 */ 33 34 /** 35 * @brief Init the VAULT driver 36 * 37 * This API init the resoure common: 38 * - Init VAULT driver control memory 39 * 40 * @attention 1. This API should be called before any other VAULT APIs. 41 * 42 * @return 43 * - BK_OK: succeed 44 * - BK_ERR_VAULT_DRIVER_INIT_FAIL: vault driver init failed 45 * - others: other errors. 46 */ 47 bk_err_t bk_securityip_driver_init(void); 48 49 /** 50 * @brief Deinit the VAULT driver 51 * 52 * This API free all resource related to VAULT and disable VAULT. 53 * 54 * @return 55 * - BK_OK: succeed 56 * - others: other errors. 57 */ 58 bk_err_t bk_securityip_driver_deinit(void); 59 60 /** 61 * @brief trng default config 62 * 63 * This function set the default TRNG configuartion and actives the TRNG. 64 * 65 * @return 66 * - BK_OK: succeed. 67 * - BK_FAIL: fail. 68 */ 69 bk_err_t bk_securityip_trng_def_cfg(void); 70 71 72 /** 73 * @brief Generate a TRNG number 74 * 75 * This function generates a number of bytes (random number/data) into the buffer at Data_p. 76 * 77 * @param [in] DataSize 78 * Number of random data bytes. 79 * Note: DataSize <= 65535. 80 * 81 * @param [in,out] RandNum_p 82 * Pointer to buffer in which random data will be returned. 83 * 84 * @return 85 * - BK_OK: succeed. 86 * - BK_FAIL: fail. 87 */ 88 bk_err_t bk_securityip_get_trng(uint32_t size, uint8_t * RandNum_p); 89 90 #ifdef __cplusplus 91 } 92 #endif 93 94 95