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