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