Bug #5251
closedEVP_PKEY_base_id returns 0
100%
Description
We use EVP_PKEY_base_id to get the key type, which is required when using HMAC signing. Latest ndn-cxx.
This might be a bug in OpenSSL. Thoughts?
The following code prints 0 for me, and HMAC signing fails.
#include <openssl/evp.h>
#include <openssl/rsa.h>
void main() {
EVP_PKEY *pkey = NULL;
unsigned char buf[32] = {1};
if (!(pkey = EVP_PKEY_new_raw_private_key(EVP_PKEY_HMAC, NULL, buf, 32))) {
exit(1);
}
printf ("%d\n", EVP_PKEY_base_id(pkey));
}
$ openssl version
OpenSSL 3.0.2 15 Mar 2022 (Library: OpenSSL 3.0.2 15 Mar 2022)
Updated by Davide Pesavento almost 2 years ago
- Category set to Security
- Start date deleted (
01/12/2023)
Updated by Davide Pesavento almost 2 years ago
- Related to Feature #5154: OpenSSL 3.0 support added
- Related to Task #5241: Redesign support for HMAC keys added
Updated by Davide Pesavento almost 2 years ago
The man page for EVP_PKEY_base_id says:
The following functions are only reliable with EVP_PKEYs that have been assigned an internal key with EVP_PKEY_assign_*():
EVP_PKEY_get_id(), EVP_PKEY_get_base_id(), EVP_PKEY_type()
However, the EVP_PKEY_assign_*
functions were deprecated in openssl 3.0, and in any case I don't see such a function for HMAC.
The man page for EVP_PKEY_new_raw_private_key says:
EVP_PKEY_new_raw_private_key() may also be used with most MACs implemented as public key algorithms, so key types such as "HMAC", "POLY1305", "SIPHASH", [...] are also accepted. This usage is, as mentioned above, discouraged in favor of the EVP_MAC(3) API.
The EVP_MAC
API is new in openssl 3.0. This new API does not seem to use the EVP_PKEY
structure; instead the key is passed as void*
or char*
to the relevant functions.
Updated by Davide Pesavento almost 2 years ago
@Varun Patil do you still plan to report this upstream?
Updated by Davide Pesavento over 1 year ago
- Status changed from New to Code review
- Assignee set to Varun Patil
- Target version set to 0.9.0
- % Done changed from 0 to 100
Updated by Davide Pesavento over 1 year ago
- Status changed from Code review to Closed