-
Notifications
You must be signed in to change notification settings - Fork 170
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
BoringSSLRSAPublicKey use EVP_PKEY API #205
Conversation
Motivation Increased versatility of the `BoringSSLRSAPublicKey` encrypt and decrypt methods to make future extensions possible. Modifications Switch the `BoringSSLRSAPublicKey` encrypt and decrypt methods to use the `EVP_PKEY_*` API directly rather than going through the RSA abstractions. Result Increased versatility of the `BoringSSLRSAPublicKey` encrypt and decrypt methods.
CInt(dataPtr.count), | ||
dataPtr.baseAddress, | ||
|
||
let pkey = CCryptoBoringSSL_EVP_PKEY_new() |
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.
I wonder if we should amend the type to only hold this as an EVP_PKEY, instead of holding an RSA pointer at all.
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.
Obviously you have more context here but I'm not sure that's the best thing to do.
The RSA pointer is currently used in a few different locations outside of the initializers e.g. pkcs1DERRepresentation
, derRepresentation
, keySizeInBits
, isValidSignature
. Each of these would then need a call to get the RSA pointer unless we also stored that (which is an option). I looked for alternative functions but there are a few including BIO
operations which now have annotations in the docs which look like deprecations (here) which I think make this complex enough to warrant a separate piece of work if we want to do it.
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.
Since the get0
functions offer a cheap way to access the underlying RSA object we have opted to just keep hold of the EVP_KEY
) | ||
return rc | ||
|
||
return rc == 0 ? CInt(-1) : CInt(writtenLength) |
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.
Let's not use -1 as a sentinel, let's just throw.
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.
Nice one, this LGTM.
Switch BoringSSLRSAPublicKey encrypt/decrypt methods to use
EVP_PKEY_*
APIMotivation
Increased versatility of the
BoringSSLRSAPublicKey
encrypt and decrypt methods to make future extensions possible.Modifications
Switch the
BoringSSLRSAPublicKey
encrypt and decrypt methods to use theEVP_PKEY_*
API directly rather than going through the RSA abstractions.Result
Increased versatility of the
BoringSSLRSAPublicKey
encrypt and decrypt methods.