Commit 74633553 authored by Dr. Stephen Henson's avatar Dr. Stephen Henson
Browse files

Experimental HMAC support via EVP_PKEY_METHOD.

parent 376bf1d4
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -68,6 +68,7 @@ extern const EVP_PKEY_ASN1_METHOD rsa_asn1_meths[];
extern const EVP_PKEY_ASN1_METHOD dsa_asn1_meths[];
extern const EVP_PKEY_ASN1_METHOD dh_asn1_meth;
extern const EVP_PKEY_ASN1_METHOD eckey_asn1_meth;
extern const EVP_PKEY_ASN1_METHOD hmac_asn1_meth;

/* Keep this sorted in type order !! */
static const EVP_PKEY_ASN1_METHOD *standard_methods[] = 
@@ -87,8 +88,9 @@ static const EVP_PKEY_ASN1_METHOD *standard_methods[] =
	&dsa_asn1_meths[4],
#endif
#ifndef OPENSSL_NO_EC
	&eckey_asn1_meth
	&eckey_asn1_meth,
#endif
	&hmac_asn1_meth
	};

typedef int sk_cmp_fn_type(const char * const *a, const char * const *b);
+1 −0
Original line number Diff line number Diff line
@@ -150,6 +150,7 @@ static ERR_STRING_DATA ERR_str_libraries[]=
{ERR_PACK(ERR_LIB_TS,0,0)		,"time stamp routines"},
{ERR_PACK(ERR_LIB_ENGINE,0,0)		,"engine routines"},
{ERR_PACK(ERR_LIB_OCSP,0,0)		,"OCSP routines"},
{ERR_PACK(ERR_LIB_HMAC,0,0)		,"HMAC routines"},
{0,NULL},
	};

+2 −0
Original line number Diff line number Diff line
@@ -195,6 +195,7 @@ typedef struct err_state_st
#define ERR_LIB_ECDH		43
#define ERR_LIB_STORE           44
#define ERR_LIB_TS		45
#define ERR_LIB_HMAC		46

#define ERR_LIB_USER		128

@@ -227,6 +228,7 @@ typedef struct err_state_st
#define ECDHerr(f,r)  ERR_PUT_error(ERR_LIB_ECDH,(f),(r),__FILE__,__LINE__)
#define STOREerr(f,r) ERR_PUT_error(ERR_LIB_STORE,(f),(r),__FILE__,__LINE__)
#define TSerr(f,r) ERR_PUT_error(ERR_LIB_TS,(f),(r),__FILE__,__LINE__)
#define HMACerr(f,r) ERR_PUT_error(ERR_LIB_HMAC,(f),(r),__FILE__,__LINE__)

/* Borland C seems too stupid to be able to shift and do longs in
 * the pre-processor :-( */
+1 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ L ECDSA crypto/ecdsa/ecdsa.h crypto/ecdsa/ecs_err.c
L ECDH		crypto/ecdh/ecdh.h		crypto/ecdh/ech_err.c
L STORE		crypto/store/store.h		crypto/store/str_err.c
L TS		crypto/ts/ts.h			crypto/ts/ts_err.c
L HMAC		crypto/hmac/hmac.h		crypto/hmac/hmac_err.c

# additional header files to be scanned for function names
L NONE		crypto/x509/x509_vfy.h		NONE
+16 −3
Original line number Diff line number Diff line
@@ -198,19 +198,32 @@ int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl)
		if (ctx->digest && ctx->digest->ctx_size)
			OPENSSL_free(ctx->md_data);
		ctx->digest=type;
		if (type->ctx_size)
		if (!(ctx->flags & EVP_MD_CTX_FLAG_NO_INIT) && type->ctx_size)
			{
			ctx->update = type->update;
			ctx->md_data=OPENSSL_malloc(type->ctx_size);
			}
		}
#ifndef OPENSSL_NO_ENGINE
skip_to_init:
#endif
	if (ctx->pctx)
		{
		int r;
		r = EVP_PKEY_CTX_ctrl(ctx->pctx, -1, EVP_PKEY_OP_TYPE_SIG,
					EVP_PKEY_CTRL_DIGESTINIT, 0, ctx);
		if (r <= 0 && (r != -2))
			return 0;
		}
	if (ctx->flags & EVP_MD_CTX_FLAG_NO_INIT)
		return 1;
	return ctx->digest->init(ctx);
	}

int EVP_DigestUpdate(EVP_MD_CTX *ctx, const void *data,
	     size_t count)
	{
	return ctx->digest->update(ctx,data,count);
	return ctx->update(ctx,data,count);
	}

/* The caller can assume that this removes any secret data from the context */
@@ -272,7 +285,7 @@ int EVP_MD_CTX_copy_ex(EVP_MD_CTX *out, const EVP_MD_CTX *in)
	EVP_MD_CTX_cleanup(out);
	memcpy(out,in,sizeof *out);

	if (out->digest->ctx_size)
	if (in->md_data && out->digest->ctx_size)
		{
		if (tmp_buf) out->md_data = tmp_buf;
		else out->md_data=OPENSSL_malloc(out->digest->ctx_size);
Loading