]>
git.saurik.com Git - apple/xnu.git/blob - bsd/dev/random/YarrowCoreLib/src/prngpriv.h
2 * Copyright (c) 1999, 2000-2001 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
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
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.
21 * @APPLE_LICENSE_HEADER_END@
27 Contains: Private typedefs and #defines for Counterpane Yarrow PRNG.
29 Written by: Counterpane, Inc.
31 Copyright: (c) 2000 by Apple Computer, Inc., all rights reserved.
33 Change History (most recent first):
35 02/10/99 dpm Created, based on Counterpane source.
41 Completely private header for the Counterpane PRNG. Should only be included by prng.c
44 #ifndef __YARROW_PRNG_PRIV_H__
45 #define __YARROW_PRNG_PRIV_H__
47 #include "userdefines.h"
48 #include "dev/random/YarrowCoreLib/include/yarrow.h"
49 #include "entropysources.h"
54 #define TOTAL_SOURCES ENTROPY_SOURCES+USER_SOURCES
57 #define COMP_SOURCES TOTAL_SOURCES
59 #define COMP_SOURCES ENTROPY_SOURCES
63 typedef enum prng_ready_status
{
64 PRNG_READY
= 33, /* Compiler will initialize to either 0 or random if allowed to */
68 /* Top level output state */
72 UINT index
; /* current byte to output */
73 UINT numout
; /* bytes since last prng_make_new_state */
76 /* PRNG state structure */
81 /* Entropy Pools (somewhat unlike a gene pool) */
83 UINT poolSize
[TOTAL_SOURCES
]; /* Note that size is in bytes and est in bits */
84 UINT poolEstBits
[TOTAL_SOURCES
];
85 COMP_CTX comp_state
[COMP_SOURCES
];
88 prng_ready_status ready
;
92 * Clients see an opaque PrngRef; internal code uses the
95 typedef struct PRNG PRNG
;
99 #define CHECKSTATE(p) \
100 if(p==NULL) {return PRNG_ERR_NOT_READY;} /* Does the state exist? */ \
101 if(p->ready != PRNG_READY) {return PRNG_ERR_NOT_READY;} /* Set error state and return */
102 /* To make sure that a pointer isn't NULL */
103 #define PCHECK(ptr) if(ptr==NULL) {return PRNG_ERR_NULL_POINTER;}
104 /* To make sure that malloc returned a valid value */
105 #define MCHECK(ptr) if(ptr==NULL) {return PRNG_ERR_LOW_MEMORY;}
106 /* To make sure that a given value is non-negative */
107 #if defined(macintosh) || defined(__APPLE__)
108 /* original looks like a bogon */
109 #define ZCHECK(val) if(val<0) {return PRNG_ERR_OUT_OF_BOUNDS;}
111 #define ZCHECK(val) if(p<0) {return PRNG_ERR_OUT_OF_BOUNDS;}
112 #endif /* macintosh */
113 /* To make sure that the generator state is valid */
114 #define GENCHECK(p) if(p->outstate.index>20) {return PRNG_ERR_OUT_OF_BOUNDS;} /* index is unsigned */
115 /* To make sure that the entropy pool is valid */
116 #define POOLCHECK(p) /* */