]> git.saurik.com Git - apple/xnu.git/blame - bsd/dev/random/YarrowCoreLib/include/yarrow.h
xnu-344.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 *
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.
11 *
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
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
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.
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)
52extern "C" {
53#endif
54
55/* Error Codes */
56typedef 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 */
74enum 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 */
100struct PRNG;
101typedef struct PRNG *PrngRef;
102
103YARROWAPI prng_error_status
104prngInitialize(
105 PrngRef *prng);
106YARROWAPI prng_error_status
107prngDestroy(
108 PrngRef prng);
109YARROWAPI prng_error_status
110prngOutput(
111 PrngRef prng,
112 BYTE *outbuf,
113 UINT outbuflen);
114/* this one has no context */
115YARROWAPI prng_error_status
116prngStretch(
117 BYTE *inbuf,
118 UINT inbuflen,
119 BYTE *outbuf,
120 UINT outbuflen);
121YARROWAPI prng_error_status
122prngInput(
123 PrngRef prng,
124 BYTE *inbuf,
125 UINT inbuflen,
126 UINT poolnum,
127 UINT estbits);
128YARROWAPI prng_error_status
129prngForceReseed(
130 PrngRef prng,
131 LONGLONG ticks);
132YARROWAPI prng_error_status
133prngAllowReseed(
134 PrngRef prng,
135 LONGLONG ticks);
136YARROWAPI prng_error_status
137prngProcessSeedBuffer(
138 PrngRef prng,
139 BYTE *buf,
140 LONGLONG ticks);
141YARROWAPI prng_error_status
142prngSlowPoll(
143 PrngRef prng,
144 UINT pollsize);
145#else
146/* original Counterpane API */
147YARROWAPI int prngOutput(BYTE *outbuf,UINT outbuflen);
148YARROWAPI int prngStretch(BYTE *inbuf,UINT inbuflen,BYTE *outbuf,UINT outbuflen);
149YARROWAPI int prngInput(BYTE *inbuf,UINT inbuflen,UINT poolnum,UINT estbits);
150YARROWAPI int prngForceReseed(LONGLONG ticks);
151YARROWAPI int prngAllowReseed(LONGLONG ticks);
152YARROWAPI int prngProcessSeedBuffer(BYTE *buf,LONGLONG ticks);
153YARROWAPI int prngSlowPoll(UINT pollsize);
154#endif
155
156#if defined(__cplusplus)
157}
158#endif
159
160#endif