]> git.saurik.com Git - apple/xnu.git/blame - bsd/dev/random/YarrowCoreLib/include/yarrow.h
xnu-344.21.74.tar.gz
[apple/xnu.git] / bsd / dev / random / YarrowCoreLib / include / yarrow.h
CommitLineData
0b4e3aa0
A
1/*
2 * Copyright (c) 1999, 2000-2001 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
d7e50217 6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
0b4e3aa0 7 *
d7e50217
A
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
0b4e3aa0
A
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
d7e50217
A
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.
0b4e3aa0
A
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)
55extern "C" {
56#endif
57
58/* Error Codes */
59typedef 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 */
77enum 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 */
103struct PRNG;
104typedef struct PRNG *PrngRef;
105
106YARROWAPI prng_error_status
107prngInitialize(
108 PrngRef *prng);
109YARROWAPI prng_error_status
110prngDestroy(
111 PrngRef prng);
112YARROWAPI prng_error_status
113prngOutput(
114 PrngRef prng,
115 BYTE *outbuf,
116 UINT outbuflen);
117/* this one has no context */
118YARROWAPI prng_error_status
119prngStretch(
120 BYTE *inbuf,
121 UINT inbuflen,
122 BYTE *outbuf,
123 UINT outbuflen);
124YARROWAPI prng_error_status
125prngInput(
126 PrngRef prng,
127 BYTE *inbuf,
128 UINT inbuflen,
129 UINT poolnum,
130 UINT estbits);
131YARROWAPI prng_error_status
132prngForceReseed(
133 PrngRef prng,
134 LONGLONG ticks);
135YARROWAPI prng_error_status
136prngAllowReseed(
137 PrngRef prng,
138 LONGLONG ticks);
139YARROWAPI prng_error_status
140prngProcessSeedBuffer(
141 PrngRef prng,
142 BYTE *buf,
143 LONGLONG ticks);
144YARROWAPI prng_error_status
145prngSlowPoll(
146 PrngRef prng,
147 UINT pollsize);
148#else
149/* original Counterpane API */
150YARROWAPI int prngOutput(BYTE *outbuf,UINT outbuflen);
151YARROWAPI int prngStretch(BYTE *inbuf,UINT inbuflen,BYTE *outbuf,UINT outbuflen);
152YARROWAPI int prngInput(BYTE *inbuf,UINT inbuflen,UINT poolnum,UINT estbits);
153YARROWAPI int prngForceReseed(LONGLONG ticks);
154YARROWAPI int prngAllowReseed(LONGLONG ticks);
155YARROWAPI int prngProcessSeedBuffer(BYTE *buf,LONGLONG ticks);
156YARROWAPI int prngSlowPoll(UINT pollsize);
157#endif
158
159#if defined(__cplusplus)
160}
161#endif
162
163#endif