]> git.saurik.com Git - apple/xnu.git/blob - EXTERNAL_HEADERS/corecrypto/ccdrbg_impl.h
efa1ef9ba3af24cc932c8c80dec3441e0f739993
[apple/xnu.git] / EXTERNAL_HEADERS / corecrypto / ccdrbg_impl.h
1 /*
2 * ccdrbg_impl.h
3 * corecrypto
4 *
5 * Created by James Murphy on 12/9/11.
6 * Copyright (c) 2011 Apple Inc. All rights reserved.
7 *
8 */
9
10 #ifndef _CORECRYPTO_CCDRBG_IMPL_H_
11 #define _CORECRYPTO_CCDRBG_IMPL_H_
12
13 /* opaque drbg structure */
14 struct ccdrbg_state;
15
16 struct ccdrbg_info {
17 /** Size of the DRBG state in bytes **/
18 size_t size;
19
20 /** Instantiate the PRNG
21 @param prng The PRNG state
22 @param entropylen Length of entropy
23 @param entropy Entropy bytes
24 @param inlen Length of additional input
25 @param in Additional input bytes
26 @return 0 if successful
27 */
28 int (*init)(const struct ccdrbg_info *info, struct ccdrbg_state *drbg,
29 unsigned long entropyLength, const void* entropy,
30 unsigned long nonceLength, const void* nonce,
31 unsigned long psLength, const void* ps);
32
33 /** Add entropy to the PRNG
34 @param prng The PRNG state
35 @param entropylen Length of entropy
36 @param entropy Entropy bytes
37 @param inlen Length of additional input
38 @param in Additional input bytes
39 @return 0 if successful
40 */
41 int (*reseed)(struct ccdrbg_state *prng,
42 unsigned long entropylen, const void *entropy,
43 unsigned long inlen, const void *in);
44
45 /** Read from the PRNG in a FIPS Testing compliant manor
46 @param prng The PRNG state to read from
47 @param out [out] Where to store the data
48 @param outlen Length of data desired (octets)
49 @param inlen Length of additional input
50 @param in Additional input bytes
51 @return 0 if successfull
52 */
53 int (*generate)(struct ccdrbg_state *prng,
54 unsigned long outlen, void *out,
55 unsigned long inlen, const void *in);
56
57 /** Terminate a PRNG state
58 @param prng The PRNG state to terminate
59 */
60 void (*done)(struct ccdrbg_state *prng);
61
62 /** private parameters */
63 const void *custom;
64 };
65
66
67
68 #endif // _CORECRYPTO_CCDRBG_IMPL_H_