diff options
author | Dr. Stephen Henson <steve@openssl.org> | 2007-04-11 12:33:06 +0000 |
---|---|---|
committer | Dr. Stephen Henson <steve@openssl.org> | 2007-04-11 12:33:06 +0000 |
commit | 74633553a912519a6e73a9d830132e58f420a6c9 (patch) | |
tree | ad4b498680c993039f5b6371fd53c0091c828801 /crypto/evp/digest.c | |
parent | 376bf1d4aaddbc7645b364e6963b34951fe51f9b (diff) | |
download | openssl-74633553a912519a6e73a9d830132e58f420a6c9.tar.gz |
Experimental HMAC support via EVP_PKEY_METHOD.
Diffstat (limited to 'crypto/evp/digest.c')
-rw-r--r-- | crypto/evp/digest.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/crypto/evp/digest.c b/crypto/evp/digest.c index 256efd6e9d..095774bf62 100644 --- a/crypto/evp/digest.c +++ b/crypto/evp/digest.c @@ -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); |