diff options
author | Rich Salz <rsalz@openssl.org> | 2017-06-22 15:21:43 +0200 |
---|---|---|
committer | Rich Salz <rsalz@openssl.org> | 2017-07-15 07:51:34 +0200 |
commit | da8fc25a989cf4f4d26d626a85477e8a9282da12 (patch) | |
tree | 428bd385034d2a3a24d13cb0e8fa3ee37f06f6b7 /crypto/rand/rand_lcl.h | |
parent | For Windows, use _stat rather than stat (diff) | |
download | openssl-da8fc25a989cf4f4d26d626a85477e8a9282da12.tar.xz openssl-da8fc25a989cf4f4d26d626a85477e8a9282da12.zip |
Start to overhaul RAND API
Remove unused rand_hw_xor, MD/EVP indirection
Make rand_pseudo same as rand.
Cleanup formatting and ifdef control
Rename some things:
- rand_meth to openssl_rand_meth; make it global
- source file
- lock/init functions, start per-thread state
- ossl_meth_init to ossl_rand_init
Put state into RAND_STATE structure
And put OSSL_RAND_STATE into ossl_typ.h
Use "randomness" instead of "entropy"
Reviewed-by: Ben Kaduk <kaduk@mit.edu>
(Merged from https://github.com/openssl/openssl/pull/3758)
Diffstat (limited to 'crypto/rand/rand_lcl.h')
-rw-r--r-- | crypto/rand/rand_lcl.h | 36 |
1 files changed, 7 insertions, 29 deletions
diff --git a/crypto/rand/rand_lcl.h b/crypto/rand/rand_lcl.h index d98c90e2ac..69c9630122 100644 --- a/crypto/rand/rand_lcl.h +++ b/crypto/rand/rand_lcl.h @@ -10,37 +10,15 @@ #ifndef HEADER_RAND_LCL_H # define HEADER_RAND_LCL_H -# define ENTROPY_NEEDED 32 /* require 256 bits = 32 bytes of randomness */ - -# if !defined(USE_MD5_RAND) && !defined(USE_SHA1_RAND) && !defined(USE_MDC2_RAND) && !defined(USE_MD2_RAND) -# define USE_SHA1_RAND -# endif +/* we require 256 bits of randomness */ +# define RANDOMNESS_NEEDED (256 / 8) # include <openssl/evp.h> -# define MD_Update(a,b,c) EVP_DigestUpdate(a,b,c) -# define MD_Final(a,b) EVP_DigestFinal_ex(a,b,NULL) -# if defined(USE_MD5_RAND) -# include <openssl/md5.h> -# define MD_DIGEST_LENGTH MD5_DIGEST_LENGTH -# define MD_Init(a) EVP_DigestInit_ex(a,EVP_md5(), NULL) -# define MD(a,b,c) EVP_Digest(a,b,c,NULL,EVP_md5(), NULL) -# elif defined(USE_SHA1_RAND) -# include <openssl/sha.h> -# define MD_DIGEST_LENGTH SHA_DIGEST_LENGTH -# define MD_Init(a) EVP_DigestInit_ex(a,EVP_sha1(), NULL) -# define MD(a,b,c) EVP_Digest(a,b,c,NULL,EVP_sha1(), NULL) -# elif defined(USE_MDC2_RAND) -# include <openssl/mdc2.h> -# define MD_DIGEST_LENGTH MDC2_DIGEST_LENGTH -# define MD_Init(a) EVP_DigestInit_ex(a,EVP_mdc2(), NULL) -# define MD(a,b,c) EVP_Digest(a,b,c,NULL,EVP_mdc2(), NULL) -# elif defined(USE_MD2_RAND) -# include <openssl/md2.h> -# define MD_DIGEST_LENGTH MD2_DIGEST_LENGTH -# define MD_Init(a) EVP_DigestInit_ex(a,EVP_md2(), NULL) -# define MD(a,b,c) EVP_Digest(a,b,c,NULL,EVP_md2(), NULL) -# endif +# include <openssl/sha.h> + +# define RAND_DIGEST EVP_sha1() +# define RAND_DIGEST_LENGTH SHA_DIGEST_LENGTH -void rand_hw_xor(unsigned char *buf, size_t num); +extern RAND_METHOD openssl_rand_meth; #endif |