Wrapped OEMCrypto RSA key operations.

[ Merge of http://go/wvgerrit/115545 ]

This change wraps the RSA key in a public and private key class that is
similar to how ECC keys are wrapped.

This new wrapper replaces deprecated OpenSSL/BoringSSL RSA signing and
signature verification API and uses the generic key digest context for
RSASSA-PSS signatures.

Bug: 135283522
Test: Future CL
Change-Id: Ifff649a3abcca127cc539f937c429c7da8acdcc6
This commit is contained in:
Alex Dale
2021-02-18 14:30:41 -08:00
parent c42782f6d3
commit 7a46bc3c87
3 changed files with 1540 additions and 12 deletions

View File

@@ -70,10 +70,10 @@ class EccPublicKey {
// Serializes the public key into an ASN.1 DER encoded SubjectPublicKey
// representation.
// On success, |*buffer_size| is populated with the number of bytes
// On success, |buffer_size| is populated with the number of bytes
// written to |buffer|, and OEMCrypto_SUCCESS is returned.
// If the provided |*buffer_size| is too small, ERROR_SHORT_BUFFER
// is returned and |*buffer_size| is set to the required buffer size.
// If the provided |buffer_size| is too small, ERROR_SHORT_BUFFER
// is returned and |buffer_size| is set to the required buffer size.
OEMCryptoResult Serialize(uint8_t* buffer, size_t* buffer_size) const;
// Same as above, except directly returns the serialized key.
// Returns an empty vector on error.
@@ -167,10 +167,10 @@ class EccPrivateKey {
// Serializes the private key into an ASN.1 DER encoded ECPrivateKey
// representation.
// On success, |*buffer_size| is populated with the number of bytes
// On success, |buffer_size| is populated with the number of bytes
// written to |buffer|, and SUCCESS is returned.
// If the provided |*buffer_size| is too small,
// OEMCrypto_ERROR_SHORT_BUFFER is returned and |*buffer_size| is
// If the provided |buffer_size| is too small,
// OEMCrypto_ERROR_SHORT_BUFFER is returned and |buffer_size| is
// set to the required buffer size.
OEMCryptoResult Serialize(uint8_t* buffer, size_t* buffer_size) const;
// Same as above, except directly returns the serialized key.
@@ -184,10 +184,10 @@ class EccPrivateKey {
// - SHA-256 / secp256r1
// - SHA-384 / secp384r1 (optional support)
// - SHA-512 / secp521r1 (optional support)
// On success, |*signature_length| is populated with the number of
// On success, |signature_length| is populated with the number of
// bytes written to |signature|, and SUCCESS is returned.
// If the provided |*signature_length| is too small,
// OEMCrypto_ERROR_SHORT_BUFFER is returned and |*signature_length|
// If the provided |signature_length| is too small,
// OEMCrypto_ERROR_SHORT_BUFFER is returned and |signature_length|
// is set to the required signature size.
OEMCryptoResult GenerateSignature(const uint8_t* message,
size_t message_length, uint8_t* signature,
@@ -203,10 +203,10 @@ class EccPrivateKey {
// Derives the OEMCrypto session key used for deriving other keys.
// The provided public key must be of the same curve.
// On success, |*session_key_size| is populated with the number of
// On success, |session_key_size| is populated with the number of
// bytes written to |session_key|, and OEMCrypto_SUCCESS is returned.
// If the provided |*session_key_size| is too small,
// OEMCrypto_ERROR_SHORT_BUFFER is returned and |*session_key_size|
// If the provided |session_key_size| is too small,
// OEMCrypto_ERROR_SHORT_BUFFER is returned and |session_key_size|
// is set to the required buffer size.
OEMCryptoResult DeriveSessionKey(const EccPublicKey& public_key,
uint8_t* session_key,