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