-
Notifications
You must be signed in to change notification settings - Fork 122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
allow HMAC via EVP_PKEY raw privkey functions #1338
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #1338 +/- ##
==========================================
- Coverage 76.84% 76.84% -0.01%
==========================================
Files 425 425
Lines 71502 71532 +30
==========================================
+ Hits 54948 54970 +22
- Misses 16554 16562 +8 ☔ View full report in Codecov by Sentry. |
087bb11
to
71111aa
Compare
71111aa
to
45c743d
Compare
|
||
// The semantics of the EVP APIs are to return the length, if |priv| is NULL. | ||
if (priv == NULL) { | ||
*len = key->key_len; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we do a null check on len
here, or can we always assume that to be a valid pointer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a check above
EXPECT_TRUE(EVP_PKEY_get_raw_private_key(raw_pkey.get(), retrieved_key.data(), | ||
&retrieved_key_len)); | ||
retrieved_key.resize(retrieved_key_len); | ||
EXPECT_EQ(Bytes(retrieved_key), Bytes(key)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
considering branch coverage... should we add a case where we resize the buffer andretrieved_key_len
to something smaller than the key size and and expect failure?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure I added one more here. There are cases where the key could be NULL, so I've filtered those out here.
45c743d
to
f5b7f34
Compare
e5ce5e6
to
24ceacc
Compare
c8efdff
to
424ce04
Compare
This adds support for consuming `EVP_PKEY_HMAC` through `EVP_PKEY_new_raw_private_key` and `EVP_PKEY_get_raw_private_key`. Logic for `set_priv_raw` and `get_priv_raw` are required for `EVP_PKEY_HMAC`'s ASN1 methods to get things working. New tests setting the key and retrieving it for `EVP_PKEY_HMAC` were also added.
Issues:
Resolves
CryptoAlg-1704
Description of changes:
Follow up from #1324 (comment), Bind consumes
EVP_PKEY_HMAC
though this codepath, so we'll have to add support for this within the EVP_PKEY function pointers.OpenSSL also encourages using
EVP_PKEY_new_raw_private_key
instead ofEVP_PKEY_new_mac_key
: https://www.openssl.org/docs/manmaster/man3/EVP_PKEY_new_mac_key.htmlCall-outs:
N/A
Testing:
New test for
EVP_PKEY_{new,get}_raw_private_key
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and the ISC license.