1 /* 2 * This file is part of the openHiTLS project. 3 * 4 * openHiTLS is licensed under the Mulan PSL v2. 5 * You can use this software according to the terms and conditions of the Mulan PSL v2. 6 * You may obtain a copy of Mulan PSL v2 at: 7 * 8 * http://license.coscl.org.cn/MulanPSL2 9 * 10 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 11 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 12 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 13 * See the Mulan PSL v2 for more details. 14 */ 15 16 #ifndef ES_HEALTH_TEST_H 17 #define ES_HEALTH_TEST_H 18 19 #include "hitls_build.h" 20 #if defined(HITLS_CRYPTO_ENTROPY) && defined(HITLS_CRYPTO_ENTROPY_SYS) 21 22 #include <stdint.h> 23 24 #ifdef __cplusplus 25 extern "C" { 26 #endif 27 28 typedef struct { 29 // RCT 30 uint32_t rctCutoff; // NIST SP800-90B 4.4.1 Parameter C 31 uint32_t rctCount; // NIST SP800-90B 4.4.1 Parameter B 32 // APT 33 uint32_t aptBaseSet; // Indicates whether aptBaseData has been set. The value must be initialized to 0. 34 uint32_t aptCount; // NIST SP800-90B 4.4.2 Parameter B 35 uint32_t aptWindowSize; // NIST SP800-90B 4.4.2 Parameter W 36 uint32_t aptI; // counters 37 uint32_t aptCutOff; // NIST SP800-90B 4.4.2 Parameter C 38 uint64_t aptBaseData; // NIST SP800-90B 4.4.2 Parameter A 39 uint64_t lastData; // NIST SP800-90B 4.4.1 Parameter A 40 } ES_HealthTest; 41 42 /* Repetition Count Test */ 43 int32_t ES_HealthTestRct(ES_HealthTest *state, uint64_t data); 44 45 /* Adaptive Proportion Test */ 46 int32_t ES_HealthTestApt(ES_HealthTest *state, uint64_t data); 47 48 #ifdef __cplusplus 49 } 50 #endif 51 52 #endif 53 54 #endif