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