diff options
author | Dr. Stephen Henson <steve@openssl.org> | 2001-06-20 00:30:40 +0200 |
---|---|---|
committer | Dr. Stephen Henson <steve@openssl.org> | 2001-06-20 00:30:40 +0200 |
commit | 323f289c480b0a8eb15ed3be2befbcc0f86e8904 (patch) | |
tree | a8f18dde28ce3c77b7bff50c2b45a44c556dfed4 /crypto/rand | |
parent | Fix memory leaks. (diff) | |
download | openssl-323f289c480b0a8eb15ed3be2befbcc0f86e8904.tar.xz openssl-323f289c480b0a8eb15ed3be2befbcc0f86e8904.zip |
Change all calls to low level digest routines in the library and
applications to use EVP. Add missing calls to HMAC_cleanup() and
don't assume HMAC_CTX can be copied using memcpy().
Note: this is almost identical to the patch submitted to openssl-dev
by Verdon Walker <VWalker@novell.com> except some redundant
EVP_add_digest_()/EVP_cleanup() calls were removed and some changes
made to avoid compiler warnings.
Diffstat (limited to 'crypto/rand')
-rw-r--r-- | crypto/rand/md_rand.c | 6 | ||||
-rw-r--r-- | crypto/rand/rand_lcl.h | 53 |
2 files changed, 15 insertions, 44 deletions
diff --git a/crypto/rand/md_rand.c b/crypto/rand/md_rand.c index d4d2f36ad4..1c87f21171 100644 --- a/crypto/rand/md_rand.c +++ b/crypto/rand/md_rand.c @@ -264,7 +264,7 @@ static void ssleay_rand_add(const void *buf, int num, double add) MD_Update(&m,buf,j); MD_Update(&m,(unsigned char *)&(md_c[0]),sizeof(md_c)); - MD_Final(local_md,&m); + MD_Final(&m,local_md); md_c[1]++; buf=(const char *)buf + j; @@ -457,7 +457,7 @@ static int ssleay_rand_bytes(unsigned char *buf, int num) } else MD_Update(&m,&(state[st_idx]),j); - MD_Final(local_md,&m); + MD_Final(&m,local_md); for (i=0; i<j; i++) { @@ -473,7 +473,7 @@ static int ssleay_rand_bytes(unsigned char *buf, int num) MD_Update(&m,local_md,MD_DIGEST_LENGTH); CRYPTO_w_lock(CRYPTO_LOCK_RAND); MD_Update(&m,md,MD_DIGEST_LENGTH); - MD_Final(md,&m); + MD_Final(&m,md); CRYPTO_w_unlock(CRYPTO_LOCK_RAND); memset(&m,0,sizeof(m)); diff --git a/crypto/rand/rand_lcl.h b/crypto/rand/rand_lcl.h index 1d9670738e..44d7cbba67 100644 --- a/crypto/rand/rand_lcl.h +++ b/crypto/rand/rand_lcl.h @@ -129,55 +129,26 @@ #endif #endif +#include <openssl/evp.h> +#define MD_CTX EVP_MD_CTX +#define MD_Update(a,b,c) EVP_DigestUpdate(a,b,c) +#define MD_Final(a,b) EVP_DigestFinal(a,b,NULL) #if defined(USE_MD5_RAND) -#include <openssl/md5.h> #define MD_DIGEST_LENGTH MD5_DIGEST_LENGTH -#define MD(a,b,c) MD5(a,b,c) +#define MD_Init(a) EVP_DigestInit(a,EVP_md5()) +#define MD(a,b,c) EVP_Digest(a,b,c,EVP_md5()) #elif defined(USE_SHA1_RAND) -#include <openssl/sha.h> #define MD_DIGEST_LENGTH SHA_DIGEST_LENGTH -#define MD(a,b,c) SHA1(a,b,c) +#define MD_Init(a) EVP_DigestInit(a,EVP_sha1()) +#define MD(a,b,c) EVP_Digest(a,b,c,EVP_sha1()) #elif defined(USE_MDC2_RAND) -#include <openssl/mdc2.h> #define MD_DIGEST_LENGTH MDC2_DIGEST_LENGTH -#define MD(a,b,c) MDC2(a,b,c) +#define MD_Init(a) EVP_DigestInit(a,EVP_mdc2()) +#define MD(a,b,c) EVP_Digest(a,b,c,EVP_mdc2()) #elif defined(USE_MD2_RAND) -#include <openssl/md2.h> #define MD_DIGEST_LENGTH MD2_DIGEST_LENGTH -#define MD(a,b,c) MD2(a,b,c) -#endif -#if defined(USE_MD5_RAND) -#include <openssl/md5.h> -#define MD_DIGEST_LENGTH MD5_DIGEST_LENGTH -#define MD_CTX MD5_CTX -#define MD_Init(a) MD5_Init(a) -#define MD_Update(a,b,c) MD5_Update(a,b,c) -#define MD_Final(a,b) MD5_Final(a,b) -#define MD(a,b,c) MD5(a,b,c) -#elif defined(USE_SHA1_RAND) -#include <openssl/sha.h> -#define MD_DIGEST_LENGTH SHA_DIGEST_LENGTH -#define MD_CTX SHA_CTX -#define MD_Init(a) SHA1_Init(a) -#define MD_Update(a,b,c) SHA1_Update(a,b,c) -#define MD_Final(a,b) SHA1_Final(a,b) -#define MD(a,b,c) SHA1(a,b,c) -#elif defined(USE_MDC2_RAND) -#include <openssl/mdc2.h> -#define MD_DIGEST_LENGTH MDC2_DIGEST_LENGTH -#define MD_CTX MDC2_CTX -#define MD_Init(a) MDC2_Init(a) -#define MD_Update(a,b,c) MDC2_Update(a,b,c) -#define MD_Final(a,b) MDC2_Final(a,b) -#define MD(a,b,c) MDC2(a,b,c) -#elif defined(USE_MD2_RAND) -#include <openssl/md2.h> -#define MD_DIGEST_LENGTH MD2_DIGEST_LENGTH -#define MD_CTX MD2_CTX -#define MD_Init(a) MD2_Init(a) -#define MD_Update(a,b,c) MD2_Update(a,b,c) -#define MD_Final(a,b) MD2_Final(a,b) -#define MD(a,b,c) MD2(a,b,c) +#define MD_Init(a) EVP_DigestInit(a,EVP_md2()) +#define MD(a,b,c) EVP_Digest(a,b,c,EVP_md2()) #endif |