1 /* Copyright (c) (2012,2015,2016,2019-2021) Apple Inc. All rights reserved. 2 * 3 * corecrypto is licensed under Apple Inc.’s Internal Use License Agreement (which 4 * is contained in the License.txt file distributed with corecrypto) and only to 5 * people who accept that license. IMPORTANT: Any license rights granted to you by 6 * Apple Inc. (if any) are limited to internal use within your organization only on 7 * devices and computers you own or control, for the sole purpose of verifying the 8 * security characteristics and correct functioning of the Apple Software. You may 9 * not, directly or indirectly, redistribute the Apple Software or any portions thereof. 10 */ 11 12 #ifndef _CORECRYPTO_CCDRBG_IMPL_H_ 13 #define _CORECRYPTO_CCDRBG_IMPL_H_ 14 15 #include <corecrypto/cc.h> 16 17 /* opaque drbg structure */ 18 struct ccdrbg_state; 19 20 struct ccdrbg_info { 21 /*! Size of the DRBG state in bytes **/ 22 size_t size; 23 24 /*! Instantiate the PRNG 25 @param prng The PRNG state 26 @param entropylen Length of entropy 27 @param entropy Entropy bytes 28 @param inlen Length of additional input 29 @param in Additional input bytes 30 @return 0 if successful 31 */ 32 int (*CC_SPTR(ccdrbg_info, init))(const struct ccdrbg_info *info, struct ccdrbg_state *drbg, 33 size_t entropyLength, const void* entropy, 34 size_t nonceLength, const void* nonce, 35 size_t psLength, const void* ps); 36 37 /*! Add entropy to the PRNG 38 @param prng The PRNG state 39 @param entropylen Length of entropy 40 @param entropy Entropy bytes 41 @param inlen Length of additional input 42 @param in Additional input bytes 43 @return 0 if successful 44 */ 45 int (*CC_SPTR(ccdrbg_info, reseed))(struct ccdrbg_state *prng, 46 size_t entropylen, const void *entropy, 47 size_t inlen, const void *in); 48 49 /*! Read from the PRNG in a FIPS Testing compliant manor 50 @param prng The PRNG state to read from 51 @param out [out] Where to store the data 52 @param outlen Length of data desired (octets) 53 @param inlen Length of additional input 54 @param in Additional input bytes 55 @return 0 if successfull 56 */ 57 int (*CC_SPTR(ccdrbg_info, generate))(struct ccdrbg_state *prng, 58 size_t outlen, void *out, 59 size_t inlen, const void *in); 60 61 /*! Terminate a PRNG state 62 @param prng The PRNG state to terminate 63 */ 64 void (*CC_SPTR(ccdrbg_info, done))(struct ccdrbg_state *prng); 65 66 /** private parameters */ 67 const void *custom; 68 }; 69 70 71 72 #endif // _CORECRYPTO_CCDRBG_IMPL_H_ 73