Merge cdm changes to android repo
Bug: 251924225 Test: GtsMediaTestCases Change-Id: I1b4e64c0abf701fe1f5017f14dc72b72c3ea6770
This commit is contained in:
@@ -326,6 +326,27 @@ bool RsaPublicKey::IsMatchingPrivateKey(
|
||||
return RsaKeysAreMatchingPair(GetRsaKey(), private_key.GetRsaKey());
|
||||
}
|
||||
|
||||
std::vector<uint8_t> RsaPrivateKey::GetPrivateExponent() const {
|
||||
const BIGNUM* d = RSA_get0_d(key_);
|
||||
if (d == nullptr) {
|
||||
LOGE("Private exponent must not be null");
|
||||
return {};
|
||||
}
|
||||
// Get the required length for the data.
|
||||
const size_t length = BN_num_bytes(d);
|
||||
if (length <= 0) {
|
||||
LOGE("Private exponent length must be positive");
|
||||
return {};
|
||||
}
|
||||
std::vector<uint8_t> serialized_private_exponent(length, 0);
|
||||
if (static_cast<size_t>(BN_bn2bin(d, serialized_private_exponent.data())) !=
|
||||
length) {
|
||||
LOGE("Failed to convert the private exponent");
|
||||
return {};
|
||||
}
|
||||
return serialized_private_exponent;
|
||||
}
|
||||
|
||||
OEMCryptoResult RsaPublicKey::Serialize(uint8_t* buffer,
|
||||
size_t* buffer_size) const {
|
||||
if (buffer_size == nullptr) {
|
||||
|
||||
Reference in New Issue
Block a user