diff options
author | Nathaniel McCallum <npmccallum@redhat.com> | 2016-06-15 14:02:04 -0400 |
---|---|---|
committer | Rich Salz <rsalz@openssl.org> | 2016-06-16 13:33:47 -0400 |
commit | ebad0b0beb1bb6913524549514111cbb91e6d494 (patch) | |
tree | 6fd3fafba3c61156d903bfd00ac42f9d667a9351 /crypto/evp/p_lib.c | |
parent | f219a1b0485309b6814f00985f7bbb45e72ee374 (diff) |
Add EVP_PKEY_get0_hmac() function
Before the addition of this function, it was impossible to read the
symmetric key from an EVP_PKEY_HMAC type EVP_PKEY.
Reviewed-by: Emilia Käsper <emilia@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1217)
Diffstat (limited to 'crypto/evp/p_lib.c')
-rw-r--r-- | crypto/evp/p_lib.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/crypto/evp/p_lib.c b/crypto/evp/p_lib.c index 0b50d3210e..802f6ddf09 100644 --- a/crypto/evp/p_lib.c +++ b/crypto/evp/p_lib.c @@ -237,6 +237,18 @@ void *EVP_PKEY_get0(const EVP_PKEY *pkey) return pkey->pkey.ptr; } +const unsigned char *EVP_PKEY_get0_hmac(const EVP_PKEY *pkey, size_t *len) +{ + ASN1_OCTET_STRING *os = NULL; + if (pkey->type != EVP_PKEY_HMAC) { + EVPerr(EVP_F_EVP_PKEY_GET0_HMAC, EVP_R_EXPECTING_AN_HMAC_KEY); + return NULL; + } + os = EVP_PKEY_get0(pkey); + *len = os->length; + return os->data; +} + #ifndef OPENSSL_NO_RSA int EVP_PKEY_set1_RSA(EVP_PKEY *pkey, RSA *key) { |