]> git.saurik.com Git - apple/xnu.git/blob - bsd/dev/random/YarrowCoreLib/include/yarrow.h
xnu-792.12.6.tar.gz
[apple/xnu.git] / bsd / dev / random / YarrowCoreLib / include / yarrow.h
1 /*
2 * Copyright (c) 2006 Apple Computer, Inc. All Rights Reserved.
3 *
4 * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
14 * agreement.
15 *
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
18 * file.
19 *
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
27 *
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
29 */
30
31 /*
32 File: yarrow.h
33
34 Contains: Public header file for Counterpane's Yarrow Pseudo-random
35 number generator.
36
37 Written by: Counterpane, Inc.
38
39 Copyright: (c) 2000 by Apple Computer, Inc., all rights reserved.
40
41 Change History (most recent first):
42
43 02/10/99 dpm Created, based on Counterpane source.
44
45 */
46 /*
47 yarrow.h
48
49 Main header file for Counterpane's Yarrow Pseudo-random number generator.
50 */
51
52 #ifndef __YARROW_H__
53 #define __YARROW_H__
54
55 #if defined(macintosh) || defined(__APPLE__)
56 #include "WindowsTypesForMac.h"
57 #endif
58
59 #if defined(__cplusplus)
60 extern "C" {
61 #endif
62
63 /* Error Codes */
64 typedef enum prng_error_status {
65 PRNG_SUCCESS = 0,
66 PRNG_ERR_REINIT,
67 PRNG_ERR_WRONG_CALLER,
68 PRNG_ERR_NOT_READY,
69 PRNG_ERR_NULL_POINTER,
70 PRNG_ERR_LOW_MEMORY,
71 PRNG_ERR_OUT_OF_BOUNDS,
72 PRNG_ERR_COMPRESSION,
73 PRNG_ERR_NOT_ENOUGH_ENTROPY,
74 PRNG_ERR_MUTEX,
75 PRNG_ERR_TIMEOUT,
76 PRNG_ERR_PROGRAM_FLOW
77 } prng_error_status;
78
79 /*
80 * Entropy sources
81 */
82 enum user_sources {
83 CLIENT_SOURCE = 0,
84 ENTROPY_FILE_SOURCE,
85 SYSTEM_SOURCE,
86 USER_SOURCES /* Leave as last source */
87 };
88
89
90 /* Declare YARROWAPI as __declspec(dllexport) before
91 including this file in the actual DLL */
92 #ifndef YARROWAPI
93 #if defined(macintosh) || defined(__APPLE__)
94 #define YARROWAPI
95 #else
96 #define YARROWAPI __declspec(dllimport)
97 #endif
98 #endif
99
100 /* Public function forward declarations */
101
102 #if defined(macintosh) || defined(__APPLE__)
103 /*
104 * Mac changes:
105 * 1. PrngRef context for all functions. Thus no global variables.
106 * 2. Strong enum typing (prng_error_status instead of int return).
107 */
108 struct PRNG;
109 typedef struct PRNG *PrngRef;
110
111 YARROWAPI prng_error_status
112 prngInitialize(
113 PrngRef *prng);
114 YARROWAPI prng_error_status
115 prngDestroy(
116 PrngRef prng);
117 YARROWAPI prng_error_status
118 prngOutput(
119 PrngRef prng,
120 BYTE *outbuf,
121 UINT outbuflen);
122 /* this one has no context */
123 YARROWAPI prng_error_status
124 prngStretch(
125 BYTE *inbuf,
126 UINT inbuflen,
127 BYTE *outbuf,
128 UINT outbuflen);
129 YARROWAPI prng_error_status
130 prngInput(
131 PrngRef prng,
132 BYTE *inbuf,
133 UINT inbuflen,
134 UINT poolnum,
135 UINT estbits);
136 YARROWAPI prng_error_status
137 prngForceReseed(
138 PrngRef prng,
139 LONGLONG ticks);
140 YARROWAPI prng_error_status
141 prngAllowReseed(
142 PrngRef prng,
143 LONGLONG ticks);
144 YARROWAPI prng_error_status
145 prngProcessSeedBuffer(
146 PrngRef prng,
147 BYTE *buf,
148 LONGLONG ticks);
149 YARROWAPI prng_error_status
150 prngSlowPoll(
151 PrngRef prng,
152 UINT pollsize);
153 #else
154 /* original Counterpane API */
155 YARROWAPI int prngOutput(BYTE *outbuf,UINT outbuflen);
156 YARROWAPI int prngStretch(BYTE *inbuf,UINT inbuflen,BYTE *outbuf,UINT outbuflen);
157 YARROWAPI int prngInput(BYTE *inbuf,UINT inbuflen,UINT poolnum,UINT estbits);
158 YARROWAPI int prngForceReseed(LONGLONG ticks);
159 YARROWAPI int prngAllowReseed(LONGLONG ticks);
160 YARROWAPI int prngProcessSeedBuffer(BYTE *buf,LONGLONG ticks);
161 YARROWAPI int prngSlowPoll(UINT pollsize);
162 #endif
163
164 #if defined(__cplusplus)
165 }
166 #endif
167
168 #endif