2 * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the OpenSSL license (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
10 #ifndef HEADER_RAND_LCL_H
11 # define HEADER_RAND_LCL_H
13 # define ENTROPY_NEEDED 32 /* require 256 bits = 32 bytes of randomness */
15 # if !defined(USE_MD5_RAND) && !defined(USE_SHA1_RAND) && !defined(USE_MDC2_RAND) && !defined(USE_MD2_RAND)
16 # define USE_SHA1_RAND
19 # include <openssl/evp.h>
20 # define MD_Update(a,b,c) EVP_DigestUpdate(a,b,c)
21 # define MD_Final(a,b) EVP_DigestFinal_ex(a,b,NULL)
22 # if defined(USE_MD5_RAND)
23 # include <openssl/md5.h>
24 # define MD_DIGEST_LENGTH MD5_DIGEST_LENGTH
25 # define MD_Init(a) EVP_DigestInit_ex(a,EVP_md5(), NULL)
26 # define MD(a,b,c) EVP_Digest(a,b,c,NULL,EVP_md5(), NULL)
27 # elif defined(USE_SHA1_RAND)
28 # include <openssl/sha.h>
29 # define MD_DIGEST_LENGTH SHA_DIGEST_LENGTH
30 # define MD_Init(a) EVP_DigestInit_ex(a,EVP_sha1(), NULL)
31 # define MD(a,b,c) EVP_Digest(a,b,c,NULL,EVP_sha1(), NULL)
32 # elif defined(USE_MDC2_RAND)
33 # include <openssl/mdc2.h>
34 # define MD_DIGEST_LENGTH MDC2_DIGEST_LENGTH
35 # define MD_Init(a) EVP_DigestInit_ex(a,EVP_mdc2(), NULL)
36 # define MD(a,b,c) EVP_Digest(a,b,c,NULL,EVP_mdc2(), NULL)
37 # elif defined(USE_MD2_RAND)
38 # include <openssl/md2.h>
39 # define MD_DIGEST_LENGTH MD2_DIGEST_LENGTH
40 # define MD_Init(a) EVP_DigestInit_ex(a,EVP_md2(), NULL)
41 # define MD(a,b,c) EVP_Digest(a,b,c,NULL,EVP_md2(), NULL)
44 void rand_hw_xor(unsigned char *buf, size_t num);