Output BoringSSL errors in OEMCrypto test to stderr

(This is a merge of http://go/wvgerrit/135033 from the Widevine repo.)

Previously, errors from BoringSSL in OEMCrypto were printed to stdout.
This patch moves them to stderr.

Bug: 202752544
Test: OEMCrypto unit tests
Change-Id: Ifad3e4db40e796e0320863e5a58882822e657a31
This commit is contained in:
John W. Bruce
2021-10-11 12:19:42 -07:00
parent 6be8cc6b12
commit f2457565c0

View File

@@ -167,7 +167,7 @@ void dump_boringssl_error() {
while (auto err = ERR_get_error()) {
char buffer[120];
ERR_error_string_n(err, buffer, sizeof(buffer));
cout << "BoringSSL Error -- " << buffer << "\n";
cerr << "BoringSSL Error -- " << buffer << "\n";
}
}
@@ -1486,7 +1486,7 @@ void Session::LoadOEMCert(bool verify_cert) {
if (i == 0) {
public_rsa_ = EVP_PKEY_get1_RSA(pubkey.get());
if (!public_rsa_) {
cout << "d2i_RSAPrivateKey failed.\n";
cerr << "d2i_RSAPrivateKey failed.\n";
dump_boringssl_error();
ASSERT_TRUE(nullptr != public_rsa_);
}
@@ -1538,7 +1538,7 @@ void Session::PreparePublicKey(const uint8_t* rsa_key, size_t rsa_key_length) {
if (public_rsa_) RSA_free(public_rsa_);
public_rsa_ = EVP_PKEY_get1_RSA(evp.get());
if (!public_rsa_) {
cout << "d2i_RSAPrivateKey failed. ";
cerr << "d2i_RSAPrivateKey failed. ";
dump_boringssl_error();
FAIL() << "Could not parse public RSA key.";
}
@@ -1640,7 +1640,7 @@ void Session::VerifyRSASignature(const vector<uint8_t>& message,
bool Session::GenerateRSASessionKey(vector<uint8_t>* session_key,
vector<uint8_t>* enc_session_key) {
if (!public_rsa_) {
cout << "No public RSA key loaded in test code.\n";
cerr << "No public RSA key loaded in test code.\n";
return false;
}
*session_key = wvcdm::a2b_hex("6fa479c731d2770b6a61a5d1420bb9d1");
@@ -1650,7 +1650,7 @@ bool Session::GenerateRSASessionKey(vector<uint8_t>* session_key,
&(enc_session_key->front()), public_rsa_, RSA_PKCS1_OAEP_PADDING);
int size = static_cast<int>(RSA_size(public_rsa_));
if (status != size) {
cout << "GenerateRSASessionKey error encrypting session key.\n";
cerr << "GenerateRSASessionKey error encrypting session key.\n";
dump_boringssl_error();
return false;
}