diff options
author | Dr. Stephen Henson <steve@openssl.org> | 2007-04-11 17:20:40 +0000 |
---|---|---|
committer | Dr. Stephen Henson <steve@openssl.org> | 2007-04-11 17:20:40 +0000 |
commit | 2022cfe07e331dc4b69829ca4dd45c295190d471 (patch) | |
tree | 502b38f6f67849331f027bd1a98ebb412b857eec /crypto/evp | |
parent | 47b71e6ee9c421162b1cf610bd1ca22843691764 (diff) |
New -mac and -macopt options to dgst utility. Reimplement -hmac option in
terms of new API.
Diffstat (limited to 'crypto/evp')
-rw-r--r-- | crypto/evp/evp.h | 3 | ||||
-rw-r--r-- | crypto/evp/pmeth_gn.c | 21 |
2 files changed, 24 insertions, 0 deletions
diff --git a/crypto/evp/evp.h b/crypto/evp/evp.h index b2fb2a6a4b..7b979504e6 100644 --- a/crypto/evp/evp.h +++ b/crypto/evp/evp.h @@ -1027,6 +1027,9 @@ int EVP_PKEY_CTX_ctrl_str(EVP_PKEY_CTX *ctx, const char *type, int EVP_PKEY_CTX_get_operation(EVP_PKEY_CTX *ctx); void EVP_PKEY_CTX_set0_keygen_info(EVP_PKEY_CTX *ctx, int *dat, int datlen); +EVP_PKEY *EVP_PKEY_new_mac_key(int type, ENGINE *e, + unsigned char *key, int keylen); + void EVP_PKEY_CTX_set_data(EVP_PKEY_CTX *ctx, void *data); void *EVP_PKEY_CTX_get_data(EVP_PKEY_CTX *ctx); EVP_PKEY *EVP_PKEY_CTX_get0_pkey(EVP_PKEY_CTX *ctx); diff --git a/crypto/evp/pmeth_gn.c b/crypto/evp/pmeth_gn.c index eb81d52134..17e0d5473a 100644 --- a/crypto/evp/pmeth_gn.c +++ b/crypto/evp/pmeth_gn.c @@ -196,3 +196,24 @@ int EVP_PKEY_CTX_get_keygen_info(EVP_PKEY_CTX *ctx, int idx) return 0; return ctx->keygen_info[idx]; } + +EVP_PKEY *EVP_PKEY_new_mac_key(int type, ENGINE *e, + unsigned char *key, int keylen) + { + EVP_PKEY_CTX *mac_ctx = NULL; + EVP_PKEY *mac_key = NULL; + mac_ctx = EVP_PKEY_CTX_new_id(type, e); + if (!mac_ctx) + return NULL; + if (EVP_PKEY_keygen_init(mac_ctx) <= 0) + goto merr; + if (EVP_PKEY_CTX_ctrl(mac_ctx, -1, EVP_PKEY_OP_KEYGEN, + EVP_PKEY_CTRL_SET_MAC_KEY, keylen, key) <= 0) + goto merr; + if (EVP_PKEY_keygen(mac_ctx, &mac_key) <= 0) + goto merr; + merr: + if (mac_ctx) + EVP_PKEY_CTX_free(mac_ctx); + return mac_key; + } |