Commit ff3fa48f authored by Ben Laurie's avatar Ben Laurie
Browse files

Improve back compatibility.

parent 87166e1f
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -1065,7 +1065,7 @@ int MAIN(int argc, char **argv)
		HMAC_CTX hctx;

		HMAC_CTX_init(&hctx);
		HMAC_Init(&hctx,(unsigned char *)"This is a key...",
		HMAC_Init_ex(&hctx,(unsigned char *)"This is a key...",
			     16,EVP_md5());

		for (j=0; j<SIZE_NUM; j++)
@@ -1074,7 +1074,7 @@ int MAIN(int argc, char **argv)
			Time_F(START);
			for (count=0,run=1; COND(c[D_HMAC][j]); count++)
				{
				HMAC_Init(&hctx,NULL,0,NULL);
				HMAC_Init_ex(&hctx,NULL,0,NULL);
                                HMAC_Update(&hctx,buf,lengths[j]);
                                HMAC_Final(&hctx,&(hmac[0]),NULL);
				}
+1 −1
Original line number Diff line number Diff line
@@ -100,7 +100,7 @@ int PKCS5_PBKDF2_HMAC_SHA1(const char *pass, int passlen,
		itmp[1] = (unsigned char)((i >> 16) & 0xff);
		itmp[2] = (unsigned char)((i >> 8) & 0xff);
		itmp[3] = (unsigned char)(i & 0xff);
		HMAC_Init(&hctx, pass, passlen, EVP_sha1());
		HMAC_Init_ex(&hctx, pass, passlen, EVP_sha1());
		HMAC_Update(&hctx, salt, saltlen);
		HMAC_Update(&hctx, itmp, 4);
		HMAC_Final(&hctx, digtmp, NULL);
+10 −2
Original line number Diff line number Diff line
@@ -60,7 +60,7 @@
#include <string.h>
#include <openssl/hmac.h>

void HMAC_Init(HMAC_CTX *ctx, const void *key, int len,
void HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int len,
		  const EVP_MD *md)
	{
	int i,j,reset=0;
@@ -110,6 +110,14 @@ void HMAC_Init(HMAC_CTX *ctx, const void *key, int len,
	EVP_MD_CTX_copy_ex(&ctx->md_ctx,&ctx->i_ctx);
	}

void HMAC_Init(HMAC_CTX *ctx, const void *key, int len,
	       const EVP_MD *md)
	{
	if(key && md)
	    HMAC_CTX_init(ctx);
	HMAC_Init_ex(ctx,key,len,md);
	}

void HMAC_Update(HMAC_CTX *ctx, const unsigned char *data, int len)
	{
	EVP_DigestUpdate(&ctx->md_ctx,data,len);
+5 −1
Original line number Diff line number Diff line
@@ -86,7 +86,11 @@ typedef struct hmac_ctx_st
void HMAC_CTX_init(HMAC_CTX *ctx);
void HMAC_CTX_cleanup(HMAC_CTX *ctx);

#define HMAC_cleanup(ctx) HMAC_CTX_cleanup(ctx) /* deprecated */

void HMAC_Init(HMAC_CTX *ctx, const void *key, int len,
	       const EVP_MD *md); /* deprecated */
void HMAC_Init_ex(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);
+1 −1
Original line number Diff line number Diff line
@@ -87,7 +87,7 @@ int PKCS12_gen_mac (PKCS12 *p12, const char *pass, int passlen,
		return 0;
	}
	HMAC_CTX_init(&hmac);
	HMAC_Init (&hmac, key, PKCS12_MAC_KEY_LENGTH, md_type);
	HMAC_Init_ex (&hmac, key, PKCS12_MAC_KEY_LENGTH, md_type);
    	HMAC_Update (&hmac, p12->authsafes->d.data->data,
					 p12->authsafes->d.data->length);
    	HMAC_Final (&hmac, mac, maclen);
Loading