1109998Smarkm/* crypto/rand/rand_lcl.h */
268651Skris/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
368651Skris * All rights reserved.
468651Skris *
568651Skris * This package is an SSL implementation written
668651Skris * by Eric Young (eay@cryptsoft.com).
768651Skris * The implementation was written so as to conform with Netscapes SSL.
8296465Sdelphij *
968651Skris * This library is free for commercial and non-commercial use as long as
1068651Skris * the following conditions are aheared to.  The following conditions
1168651Skris * apply to all code found in this distribution, be it the RC4, RSA,
1268651Skris * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
1368651Skris * included with this distribution is covered by the same copyright terms
1468651Skris * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15296465Sdelphij *
1668651Skris * Copyright remains Eric Young's, and as such any Copyright notices in
1768651Skris * the code are not to be removed.
1868651Skris * If this package is used in a product, Eric Young should be given attribution
1968651Skris * as the author of the parts of the library used.
2068651Skris * This can be in the form of a textual message at program startup or
2168651Skris * in documentation (online or textual) provided with the package.
22296465Sdelphij *
2368651Skris * Redistribution and use in source and binary forms, with or without
2468651Skris * modification, are permitted provided that the following conditions
2568651Skris * are met:
2668651Skris * 1. Redistributions of source code must retain the copyright
2768651Skris *    notice, this list of conditions and the following disclaimer.
2868651Skris * 2. Redistributions in binary form must reproduce the above copyright
2968651Skris *    notice, this list of conditions and the following disclaimer in the
3068651Skris *    documentation and/or other materials provided with the distribution.
3168651Skris * 3. All advertising materials mentioning features or use of this software
3268651Skris *    must display the following acknowledgement:
3368651Skris *    "This product includes cryptographic software written by
3468651Skris *     Eric Young (eay@cryptsoft.com)"
3568651Skris *    The word 'cryptographic' can be left out if the rouines from the library
3668651Skris *    being used are not cryptographic related :-).
37296465Sdelphij * 4. If you include any Windows specific code (or a derivative thereof) from
3868651Skris *    the apps directory (application code) you must include an acknowledgement:
3968651Skris *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40296465Sdelphij *
4168651Skris * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
4268651Skris * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
4368651Skris * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
4468651Skris * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
4568651Skris * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
4668651Skris * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
4768651Skris * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
4868651Skris * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
4968651Skris * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
5068651Skris * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
5168651Skris * SUCH DAMAGE.
52296465Sdelphij *
5368651Skris * The licence and distribution terms for any publically available version or
5468651Skris * derivative of this code cannot be changed.  i.e. this code cannot simply be
5568651Skris * copied and put under another distribution licence
5668651Skris * [including the GNU Public Licence.]
5768651Skris */
5868651Skris/* ====================================================================
5968651Skris * Copyright (c) 1998-2000 The OpenSSL Project.  All rights reserved.
6068651Skris *
6168651Skris * Redistribution and use in source and binary forms, with or without
6268651Skris * modification, are permitted provided that the following conditions
6368651Skris * are met:
6468651Skris *
6568651Skris * 1. Redistributions of source code must retain the above copyright
66296465Sdelphij *    notice, this list of conditions and the following disclaimer.
6768651Skris *
6868651Skris * 2. Redistributions in binary form must reproduce the above copyright
6968651Skris *    notice, this list of conditions and the following disclaimer in
7068651Skris *    the documentation and/or other materials provided with the
7168651Skris *    distribution.
7268651Skris *
7368651Skris * 3. All advertising materials mentioning features or use of this
7468651Skris *    software must display the following acknowledgment:
7568651Skris *    "This product includes software developed by the OpenSSL Project
7668651Skris *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
7768651Skris *
7868651Skris * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
7968651Skris *    endorse or promote products derived from this software without
8068651Skris *    prior written permission. For written permission, please contact
8168651Skris *    openssl-core@openssl.org.
8268651Skris *
8368651Skris * 5. Products derived from this software may not be called "OpenSSL"
8468651Skris *    nor may "OpenSSL" appear in their names without prior written
8568651Skris *    permission of the OpenSSL Project.
8668651Skris *
8768651Skris * 6. Redistributions of any form whatsoever must retain the following
8868651Skris *    acknowledgment:
8968651Skris *    "This product includes software developed by the OpenSSL Project
9068651Skris *    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
9168651Skris *
9268651Skris * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
9368651Skris * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
9468651Skris * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
9568651Skris * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
9668651Skris * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
9768651Skris * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
9868651Skris * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
9968651Skris * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
10068651Skris * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
10168651Skris * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
10268651Skris * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
10368651Skris * OF THE POSSIBILITY OF SUCH DAMAGE.
10468651Skris * ====================================================================
10568651Skris *
10668651Skris * This product includes cryptographic software written by Eric Young
10768651Skris * (eay@cryptsoft.com).  This product includes software written by Tim
10868651Skris * Hudson (tjh@cryptsoft.com).
10968651Skris *
11068651Skris */
11168651Skris
11268651Skris#ifndef HEADER_RAND_LCL_H
113296465Sdelphij# define HEADER_RAND_LCL_H
11468651Skris
115296465Sdelphij# define ENTROPY_NEEDED 32      /* require 256 bits = 32 bytes of randomness */
11668651Skris
117296465Sdelphij# if !defined(USE_MD5_RAND) && !defined(USE_SHA1_RAND) && !defined(USE_MDC2_RAND) && !defined(USE_MD2_RAND)
118296465Sdelphij#  if !defined(OPENSSL_NO_SHA) && !defined(OPENSSL_NO_SHA1)
119296465Sdelphij#   define USE_SHA1_RAND
120296465Sdelphij#  elif !defined(OPENSSL_NO_MD5)
121296465Sdelphij#   define USE_MD5_RAND
122296465Sdelphij#  elif !defined(OPENSSL_NO_MDC2) && !defined(OPENSSL_NO_DES)
123296465Sdelphij#   define USE_MDC2_RAND
124296465Sdelphij#  elif !defined(OPENSSL_NO_MD2)
125296465Sdelphij#   define USE_MD2_RAND
126296465Sdelphij#  else
127296465Sdelphij#   error No message digest algorithm available
128296465Sdelphij#  endif
129296465Sdelphij# endif
13068651Skris
131296465Sdelphij# include <openssl/evp.h>
132296465Sdelphij# define MD_Update(a,b,c)        EVP_DigestUpdate(a,b,c)
133296465Sdelphij# define MD_Final(a,b)           EVP_DigestFinal_ex(a,b,NULL)
134296465Sdelphij# if defined(USE_MD5_RAND)
135296465Sdelphij#  include <openssl/md5.h>
136296465Sdelphij#  define MD_DIGEST_LENGTH        MD5_DIGEST_LENGTH
137296465Sdelphij#  define MD_Init(a)              EVP_DigestInit_ex(a,EVP_md5(), NULL)
138296465Sdelphij#  define MD(a,b,c)               EVP_Digest(a,b,c,NULL,EVP_md5(), NULL)
139296465Sdelphij# elif defined(USE_SHA1_RAND)
140296465Sdelphij#  include <openssl/sha.h>
141296465Sdelphij#  define MD_DIGEST_LENGTH        SHA_DIGEST_LENGTH
142296465Sdelphij#  define MD_Init(a)              EVP_DigestInit_ex(a,EVP_sha1(), NULL)
143296465Sdelphij#  define MD(a,b,c)               EVP_Digest(a,b,c,NULL,EVP_sha1(), NULL)
144296465Sdelphij# elif defined(USE_MDC2_RAND)
145296465Sdelphij#  include <openssl/mdc2.h>
146296465Sdelphij#  define MD_DIGEST_LENGTH        MDC2_DIGEST_LENGTH
147296465Sdelphij#  define MD_Init(a)              EVP_DigestInit_ex(a,EVP_mdc2(), NULL)
148296465Sdelphij#  define MD(a,b,c)               EVP_Digest(a,b,c,NULL,EVP_mdc2(), NULL)
149296465Sdelphij# elif defined(USE_MD2_RAND)
150296465Sdelphij#  include <openssl/md2.h>
151296465Sdelphij#  define MD_DIGEST_LENGTH        MD2_DIGEST_LENGTH
152296465Sdelphij#  define MD_Init(a)              EVP_DigestInit_ex(a,EVP_md2(), NULL)
153296465Sdelphij#  define MD(a,b,c)               EVP_Digest(a,b,c,NULL,EVP_md2(), NULL)
154296465Sdelphij# endif
15568651Skris
156296465Sdelphij# ifndef OPENSSL_NO_ENGINE
157296465Sdelphijvoid int_RAND_set_callbacks(int (*set_rand_func) (const RAND_METHOD *meth,
158296465Sdelphij                                                  const RAND_METHOD **pmeth),
159296465Sdelphij                            const RAND_METHOD *(*get_rand_func)
160296465Sdelphij                             (const RAND_METHOD **pmeth));
161194206Ssimonint eng_RAND_set_rand_method(const RAND_METHOD *meth,
162296465Sdelphij                             const RAND_METHOD **pmeth);
163194206Ssimonconst RAND_METHOD *eng_RAND_get_rand_method(const RAND_METHOD **pmeth);
164296465Sdelphij# endif
16568651Skris
16668651Skris#endif
167