]> git.saurik.com Git - apple/xnu.git/blob - EXTERNAL_HEADERS/corecrypto/ccrng.h
xnu-3789.31.2.tar.gz
[apple/xnu.git] / EXTERNAL_HEADERS / corecrypto / ccrng.h
1 /*
2 * ccrng.h
3 * corecrypto
4 *
5 * Created on 12/13/2010
6 *
7 * Copyright (c) 2010,2011,2013,2014,2015 Apple Inc. All rights reserved.
8 *
9 */
10
11 #ifndef _CORECRYPTO_CCRNG_H_
12 #define _CORECRYPTO_CCRNG_H_
13
14 #include <stdint.h>
15
16 #include <corecrypto/cc.h>
17
18 #define CC_ERR_DEVICE -100
19 #define CC_ERR_INTERUPTS -101
20 #define CC_ERR_CRYPTO_CONFIG -102
21 #define CC_ERR_PERMS -103
22 #define CC_ERR_PARAMETER -104
23 #define CC_ERR_MEMORY -105
24 #define CC_ERR_FILEDESC -106
25 #define CC_ERR_OUT_OF_ENTROPY -107
26 #define CC_ERR_INTERNAL -108
27 #define CC_ERR_ATFORK -109
28 #define CC_ERR_OVERFLOW -110
29
30 #define CCRNG_STATE_COMMON \
31 int (*generate)(struct ccrng_state *rng, size_t outlen, void *out);
32
33 /* Get a pointer to a ccrng has never been simpler! Just call this */
34 struct ccrng_state *ccrng(int *error);
35
36 /* default state structure - do not instantiate, instead use the specific one you need */
37 struct ccrng_state {
38 CCRNG_STATE_COMMON
39 };
40
41 #define ccrng_generate(ctx, outlen, out) ((ctx)->generate((ctx), (outlen), (out)))
42
43 #endif /* _CORECRYPTO_CCRNG_H_ */