Return error first if the returned status is not ok
[ Merge of http://go/wvgerrit/148249 ] Bug: 224375138 Test: GtsMediaDrmTests Change-Id: I10f0c1bc28342d6cd5ae7d373ef554321bb6d3c8
This commit is contained in:
@@ -1447,8 +1447,13 @@ CdmResponseType CryptoSession::GetBootCertificateChain(
|
||||
&additional_signature_length);
|
||||
});
|
||||
}
|
||||
return MapOEMCryptoResult(sts, GET_BOOT_CERTIFICATE_CHAIN_ERROR,
|
||||
"GetBootCertificateChain");
|
||||
if (sts != OEMCrypto_SUCCESS) {
|
||||
return MapOEMCryptoResult(sts, GET_BOOT_CERTIFICATE_CHAIN_ERROR,
|
||||
"GetBootCertificateChain");
|
||||
}
|
||||
bcc->resize(bcc_length);
|
||||
additional_signature->resize(additional_signature_length);
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
CdmResponseType CryptoSession::GenerateCertificateKeyPair(
|
||||
@@ -1494,6 +1499,11 @@ CdmResponseType CryptoSession::GenerateCertificateKeyPair(
|
||||
&wrapped_private_key_length, &oemcrypto_key_type),
|
||||
metrics_, oemcrypto_generate_certificate_key_pair_, status);
|
||||
});
|
||||
if (status != OEMCrypto_SUCCESS) {
|
||||
return MapOEMCryptoResult(status, GENERATE_CERTIFICATE_KEY_PAIR_ERROR,
|
||||
"GenerateCertificateKeyPair");
|
||||
}
|
||||
|
||||
public_key->resize(public_key_length);
|
||||
public_key_signature->resize(public_key_signature_length);
|
||||
wrapped_private_key->resize(wrapped_private_key_length);
|
||||
@@ -1505,13 +1515,10 @@ CdmResponseType CryptoSession::GenerateCertificateKeyPair(
|
||||
} else {
|
||||
LOGE("Unexpected key type returned from GenerateCertificateKeyPair: %d",
|
||||
static_cast<int>(oemcrypto_key_type));
|
||||
return MapOEMCryptoResult(status,
|
||||
GENERATE_CERTIFICATE_KEY_PAIR_UNKNOWN_TYPE_ERROR,
|
||||
"GenerateCertificateKeyPair");
|
||||
return GENERATE_CERTIFICATE_KEY_PAIR_UNKNOWN_TYPE_ERROR;
|
||||
}
|
||||
|
||||
return MapOEMCryptoResult(status, GENERATE_CERTIFICATE_KEY_PAIR_ERROR,
|
||||
"GenerateCertificateKeyPair");
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
CdmResponseType CryptoSession::LoadOemCertificatePrivateKey(
|
||||
@@ -1539,7 +1546,9 @@ CdmResponseType CryptoSession::LoadOemCertificatePrivateKey(
|
||||
// Private.
|
||||
CdmResponseType CryptoSession::SelectKey(const std::string& key_id,
|
||||
CdmCipherMode cipher_mode) {
|
||||
RETURN_IF_NOT_OPEN(CRYPTO_SESSION_NOT_OPEN);
|
||||
const OEMCryptoResult sts = WithOecSessionLock("SelectKey", [&] {
|
||||
RETURN_IF_NULL(key_session_, OEMCrypto_ERROR_INVALID_SESSION);
|
||||
return key_session_->SelectKey(key_id, cipher_mode);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user