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