diff options
author | Ben Laurie <ben@openssl.org> | 2001-07-30 23:57:25 +0000 |
---|---|---|
committer | Ben Laurie <ben@openssl.org> | 2001-07-30 23:57:25 +0000 |
commit | dbad169019598981174ff46c7a9bf58373b0e53a (patch) | |
tree | ce8ca1188d5614648f24b03967785543f1edc8f5 /crypto/hmac | |
parent | 3ba5d1cf2eb6ef28ac5f6d9f3d28020d00c5be50 (diff) | |
download | openssl-dbad169019598981174ff46c7a9bf58373b0e53a.tar.gz |
Really add the EVP and all of the DES changes.
Diffstat (limited to 'crypto/hmac')
-rw-r--r-- | crypto/hmac/Makefile.ssl | 21 | ||||
-rw-r--r-- | crypto/hmac/hmac.c | 30 | ||||
-rw-r--r-- | crypto/hmac/hmac.h | 4 | ||||
-rw-r--r-- | crypto/hmac/hmactest.c | 1 |
4 files changed, 31 insertions, 25 deletions
diff --git a/crypto/hmac/Makefile.ssl b/crypto/hmac/Makefile.ssl index 9b24e29941..41152e6809 100644 --- a/crypto/hmac/Makefile.ssl +++ b/crypto/hmac/Makefile.ssl @@ -80,18 +80,11 @@ clean: # DO NOT DELETE THIS LINE -- make depend depends on it. hmac.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h -hmac.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h -hmac.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h -hmac.o: ../../include/openssl/des.h ../../include/openssl/dh.h -hmac.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h -hmac.o: ../../include/openssl/evp.h ../../include/openssl/hmac.h -hmac.o: ../../include/openssl/idea.h ../../include/openssl/md2.h -hmac.o: ../../include/openssl/md4.h ../../include/openssl/md5.h -hmac.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h +hmac.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h +hmac.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h +hmac.o: ../../include/openssl/e_os2.h ../../include/openssl/evp.h +hmac.o: ../../include/openssl/hmac.h ../../include/openssl/obj_mac.h hmac.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h -hmac.o: ../../include/openssl/opensslv.h ../../include/openssl/rc2.h -hmac.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h -hmac.o: ../../include/openssl/rd_fst.h ../../include/openssl/rijndael.h -hmac.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h -hmac.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h -hmac.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h hmac.c +hmac.o: ../../include/openssl/opensslv.h ../../include/openssl/rsa.h +hmac.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h +hmac.o: ../../include/openssl/symhacks.h diff --git a/crypto/hmac/hmac.c b/crypto/hmac/hmac.c index e1ec79e093..4403c84269 100644 --- a/crypto/hmac/hmac.c +++ b/crypto/hmac/hmac.c @@ -107,13 +107,12 @@ void HMAC_Init(HMAC_CTX *ctx, const void *key, int len, EVP_DigestInit(&ctx->o_ctx,md); EVP_DigestUpdate(&ctx->o_ctx,pad,EVP_MD_block_size(md)); } - - memcpy(&ctx->md_ctx,&ctx->i_ctx,sizeof(ctx->i_ctx)); + EVP_MD_CTX_copy(&ctx->md_ctx,&ctx->i_ctx); } void HMAC_Update(HMAC_CTX *ctx, const unsigned char *data, int len) { - EVP_DigestUpdate(&(ctx->md_ctx),data,len); + EVP_DigestUpdate(&ctx->md_ctx,data,len); } void HMAC_Final(HMAC_CTX *ctx, unsigned char *md, unsigned int *len) @@ -124,15 +123,25 @@ void HMAC_Final(HMAC_CTX *ctx, unsigned char *md, unsigned int *len) j=EVP_MD_block_size(ctx->md); - EVP_DigestFinal(&(ctx->md_ctx),buf,&i); - memcpy(&(ctx->md_ctx),&(ctx->o_ctx),sizeof(ctx->o_ctx)); - EVP_DigestUpdate(&(ctx->md_ctx),buf,i); - EVP_DigestFinal(&(ctx->md_ctx),md,len); + EVP_DigestFinal(&ctx->md_ctx,buf,&i); + EVP_MD_CTX_copy(&ctx->md_ctx,&ctx->o_ctx); + EVP_DigestUpdate(&ctx->md_ctx,buf,i); + EVP_DigestFinal(&ctx->md_ctx,md,len); + } + +void HMAC_CTX_init(HMAC_CTX *ctx) + { + EVP_MD_CTX_init(&ctx->i_ctx); + EVP_MD_CTX_init(&ctx->o_ctx); + EVP_MD_CTX_init(&ctx->md_ctx); } -void HMAC_cleanup(HMAC_CTX *ctx) +void HMAC_CTX_cleanup(HMAC_CTX *ctx) { - memset(ctx,0,sizeof(HMAC_CTX)); + EVP_MD_CTX_cleanup(&ctx->i_ctx); + EVP_MD_CTX_cleanup(&ctx->o_ctx); + EVP_MD_CTX_cleanup(&ctx->md_ctx); + memset(ctx,0,sizeof *ctx); } unsigned char *HMAC(const EVP_MD *evp_md, const void *key, int key_len, @@ -143,10 +152,11 @@ unsigned char *HMAC(const EVP_MD *evp_md, const void *key, int key_len, static unsigned char m[EVP_MAX_MD_SIZE]; if (md == NULL) md=m; + HMAC_CTX_init(&c); HMAC_Init(&c,key,key_len,evp_md); HMAC_Update(&c,d,n); HMAC_Final(&c,md,md_len); - HMAC_cleanup(&c); + HMAC_CTX_cleanup(&c); return(md); } diff --git a/crypto/hmac/hmac.h b/crypto/hmac/hmac.h index 7ed945da98..e70b01b2fb 100644 --- a/crypto/hmac/hmac.h +++ b/crypto/hmac/hmac.h @@ -83,11 +83,13 @@ typedef struct hmac_ctx_st #define HMAC_size(e) (EVP_MD_size((e)->md)) +void HMAC_CTX_init(HMAC_CTX *ctx); +void HMAC_CTX_cleanup(HMAC_CTX *ctx); + void HMAC_Init(HMAC_CTX *ctx, const void *key, int len, const EVP_MD *md); void HMAC_Update(HMAC_CTX *ctx, const unsigned char *data, int len); void HMAC_Final(HMAC_CTX *ctx, unsigned char *md, unsigned int *len); -void HMAC_cleanup(HMAC_CTX *ctx); unsigned char *HMAC(const EVP_MD *evp_md, const void *key, int key_len, const unsigned char *d, int n, unsigned char *md, unsigned int *md_len); diff --git a/crypto/hmac/hmactest.c b/crypto/hmac/hmactest.c index b8557b182e..96d3beb8e6 100644 --- a/crypto/hmac/hmactest.c +++ b/crypto/hmac/hmactest.c @@ -68,6 +68,7 @@ int main(int argc, char *argv[]) } #else #include <openssl/hmac.h> +#include <openssl/md5.h> #ifdef CHARSET_EBCDIC #include <openssl/ebcdic.h> |