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_CF_H 17 #define ES_CF_H 18 19 #include "hitls_build.h" 20 #if defined(HITLS_CRYPTO_ENTROPY) && defined(HITLS_CRYPTO_ENTROPY_SYS) 21 22 #include <stdint.h> 23 #include "crypt_local_types.h" 24 25 #ifdef __cplusplus 26 extern "C" { 27 #endif 28 typedef struct { 29 uint32_t algId; 30 union { 31 EAL_MdMethod mdMeth; 32 EAL_SymMethod ciMeth; 33 EAL_MacMethod macMeth; 34 } meth; 35 uint8_t *ctx; 36 /* Conditioning function initialization. */ 37 void *(*init)(void *mdMeth); 38 /* Conditioning Function Conditioning Raw Entropy Output. */ 39 int32_t (*update)(void *ctx, uint8_t *data, uint32_t dataLen); 40 /* Deinitialize the conditioning function. */ 41 void (*deinit)(void *ctx); 42 /* Output length of each conditioning function. */ 43 uint32_t (*getCfOutLen)(void *ctx); 44 /* Obtaining the Entropy Data After Conditioning. */ 45 uint8_t *(*getEntropyData)(void *ctx, uint32_t *len); 46 /* Obtains the entropy required for full entropy output. */ 47 uint32_t (*getNeedEntropy)(void *ctx); 48 } ES_CfMethod; 49 50 ES_CfMethod *ES_CFGetMethod(uint32_t algId, void *md); 51 52 ES_CfMethod *ES_CFGetDfMethod(EAL_MdMethod *mdMeth); 53 54 #ifdef __cplusplus 55 } 56 #endif 57 58 #endif 59 60 #endif