1 /***************************************************************************** 2 * NationS Microcontroller Software Support 3 * ---------------------------------------------------------------------------- 4 * Copyright (c) 2020, NationS Corporation 5 * 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions are met: 10 * 11 * - Redistributions of source code must retain the above copyright notice, 12 * this list of conditions and the disclaimer below. 13 * 14 * NationS's name may not be used to endorse or promote products derived from 15 * this software without specific prior written permission. 16 * 17 * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY NATIONZ "AS IS" AND ANY EXPRESS OR 18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 20 * DISCLAIMED. IN NO EVENT SHALL NATIONZ BE LIABLE FOR ANY DIRECT, INDIRECT, 21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 23 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 25 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 26 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * ****************************************************************************/ 28 /***************************************************************************** 29 * File Name: n32g43x_rng.h 30 * Function: Declaring RNG algorithm library API 31 * version: V1.2.0 32 * Author: zhang.zhenshan 33 * date: 2020-4-8 34 * ****************************************************************************/ 35 36 #ifndef _N32G43X_RNG_H_ 37 #define _N32G43X_RNG_H_ 38 39 #include <stdint.h> 40 41 enum{ 42 RNG_OK = 0x5a5a5a5a, 43 LENError = 0x311ECF50, //RNG generation of key length error 44 ADDRNULL = 0x7A9DB86C, // This address is empty 45 }; 46 47 48 //u32 RNG_init(void); 49 /** 50 * @brief Get pseudo random number 51 * @param[out] rand pointer to random number 52 * @param[in] the wordlen of random number 53 * @param[in] the seed, can be NULL 54 * @return RNG_OK:get random number success; othets: get random number fail 55 * @note 56 */ 57 uint32_t GetPseudoRand_U32(uint32_t *rand, uint32_t wordLen,uint32_t seed[2]); 58 59 60 /** 61 * @brief Get true random number 62 * @param[out] rand pointer to random number 63 * @param[in] the wordlen of random number 64 * @return RNG_OK:get random number success; othets: get random number fail 65 * @note 66 */ 67 uint32_t GetTrueRand_U32(uint32_t *rand, uint32_t wordLen); 68 69 /** 70 * @brief Get RNG lib version 71 * @param[out] type pointer one byte type information represents the type of the lib, like Commercial version.\ 72 * @Bits 0~4 stands for Commercial (C), Security (S), Normal (N), Evaluation (E), Test (T), Bits 5~7 are reserved. e.g. 0x09 stands for CE version. 73 * @param[out] customer pointer one byte customer information represents customer ID. for example, 0x00 stands for standard version, 0x01 is for Tianyu customized version... 74 * @param[out] date pointer array which include three bytes date information. If the returned bytes are 18,9,13,this denotes September 13,2018 75 * @param[out] version pointer one byte version information represents develop version of the lib. e.g. 0x12 denotes version 1.2. 76 * @return none 77 * @1.You can recall this function to get RSA lib information 78 */ 79 void RNG_Version(uint8_t *type, uint8_t *customer, uint8_t date[3], uint8_t *version); 80 81 #endif 82 83 84