]> git.saurik.com Git - apple/xnu.git/blob - EXTERNAL_HEADERS/corecrypto/ccdrbg_impl.h
263dded51603cb45b9e6d66d4c2cedaa1583e9f1
[apple/xnu.git] / EXTERNAL_HEADERS / corecrypto / ccdrbg_impl.h
1 /* Copyright (c) (2012,2015,2016,2019) 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 /* opaque drbg structure */
16 struct ccdrbg_state;
17
18 struct ccdrbg_info {
19 /*! Size of the DRBG state in bytes **/
20 size_t size;
21
22 /*! Instantiate the PRNG
23 @param prng The PRNG state
24 @param entropylen Length of entropy
25 @param entropy Entropy bytes
26 @param inlen Length of additional input
27 @param in Additional input bytes
28 @return 0 if successful
29 */
30 int (*init)(const struct ccdrbg_info *info, struct ccdrbg_state *drbg,
31 size_t entropyLength, const void* entropy,
32 size_t nonceLength, const void* nonce,
33 size_t psLength, const void* ps);
34
35 /*! Add entropy to the PRNG
36 @param prng The PRNG state
37 @param entropylen Length of entropy
38 @param entropy Entropy bytes
39 @param inlen Length of additional input
40 @param in Additional input bytes
41 @return 0 if successful
42 */
43 int (*reseed)(struct ccdrbg_state *prng,
44 size_t entropylen, const void *entropy,
45 size_t inlen, const void *in);
46
47 /*! Read from the PRNG in a FIPS Testing compliant manor
48 @param prng The PRNG state to read from
49 @param out [out] Where to store the data
50 @param outlen Length of data desired (octets)
51 @param inlen Length of additional input
52 @param in Additional input bytes
53 @return 0 if successfull
54 */
55 int (*generate)(struct ccdrbg_state *prng,
56 size_t outlen, void *out,
57 size_t inlen, const void *in);
58
59 /*! Terminate a PRNG state
60 @param prng The PRNG state to terminate
61 */
62 void (*done)(struct ccdrbg_state *prng);
63
64 /** private parameters */
65 const void *custom;
66 };
67
68
69
70 #endif // _CORECRYPTO_CCDRBG_IMPL_H_