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