Remove Remaining OPENSSL_VERSION_NUMBER Conditional Compiles

Some of http://go/wvgerrit/46251 from Widevine repo.
The rest was merged in the oemcrypto refactor.

When we standardized on BoringSSL, these conditional compilations that
had been added as a stopgap for OpenSSL became unneeded. However, they
were not noticed and removed at the time.

Bug: 72459799
Test: CE CDM Unit Tests
Test: tested as part of http://go/ag/4674759

Change-Id: I693f691ffcb255e03660edaa6743cd0fb9ef12c6
This commit is contained in:
Fred Gylys-Colwell
2018-07-01 21:13:52 -07:00
parent b62a8f1652
commit 0099f8d08b

View File

@@ -90,22 +90,13 @@ bool AesCbcKey::Encrypt(const std::string& in, std::string* out,
return false;
}
#if (OPENSSL_VERSION_NUMBER < 0x10100000L)
EVP_CIPHER_CTX ctx_struct;
EVP_CIPHER_CTX* evp_cipher_ctx = &ctx_struct;
#else
EVP_CIPHER_CTX* evp_cipher_ctx = EVP_CIPHER_CTX_new();
#endif
if (EVP_EncryptInit(evp_cipher_ctx, EVP_aes_128_cbc(),
reinterpret_cast<uint8_t*>(&key_[0]),
reinterpret_cast<uint8_t*>(&(*iv)[0])) == 0) {
LOGE("AesCbcKey::Encrypt: AES CBC setup failure: %s",
ERR_error_string(ERR_get_error(), NULL));
#if (OPENSSL_VERSION_NUMBER < 0x10100000L)
EVP_CIPHER_CTX_cleanup(evp_cipher_ctx);
#else
EVP_CIPHER_CTX_free(evp_cipher_ctx);
#endif
return false;
}
@@ -117,11 +108,7 @@ bool AesCbcKey::Encrypt(const std::string& in, std::string* out,
in.size()) == 0) {
LOGE("AesCbcKey::Encrypt: encryption failure: %s",
ERR_error_string(ERR_get_error(), NULL));
#if (OPENSSL_VERSION_NUMBER < 0x10100000L)
EVP_CIPHER_CTX_cleanup(evp_cipher_ctx);
#else
EVP_CIPHER_CTX_free(evp_cipher_ctx);
#endif
return false;
}
@@ -131,19 +118,11 @@ bool AesCbcKey::Encrypt(const std::string& in, std::string* out,
&padding) == 0) {
LOGE("AesCbcKey::Encrypt: PKCS7 padding failure: %s",
ERR_error_string(ERR_get_error(), NULL));
#if (OPENSSL_VERSION_NUMBER < 0x10100000L)
EVP_CIPHER_CTX_cleanup(evp_cipher_ctx);
#else
EVP_CIPHER_CTX_free(evp_cipher_ctx);
#endif
return false;
}
#if (OPENSSL_VERSION_NUMBER < 0x10100000L)
EVP_CIPHER_CTX_cleanup(evp_cipher_ctx);
#else
EVP_CIPHER_CTX_free(evp_cipher_ctx);
#endif
out->resize(out_length + padding);
return true;
}
@@ -219,13 +198,7 @@ static int LogOpenSSLError(const char* msg, size_t /* len */, void* /* ctx */) {
static bool VerifyPSSSignature(EVP_PKEY *pkey, const std::string &message,
const std::string &signature) {
#if (OPENSSL_VERSION_NUMBER < 0x10100000L)
EVP_MD_CTX ctx_struct;
EVP_MD_CTX* evp_md_ctx = &ctx_struct;
EVP_MD_CTX_init(evp_md_ctx);
#else
EVP_MD_CTX* evp_md_ctx = EVP_MD_CTX_new();
#endif
EVP_PKEY_CTX *pctx = NULL;
if (EVP_DigestVerifyInit(evp_md_ctx, &pctx, EVP_sha1(), NULL /* no ENGINE */,
@@ -265,20 +238,12 @@ static bool VerifyPSSSignature(EVP_PKEY *pkey, const std::string &message,
goto err;
}
#if (OPENSSL_VERSION_NUMBER < 0x10100000L)
EVP_MD_CTX_cleanup(evp_md_ctx);
#else
EVP_MD_CTX_free(evp_md_ctx);
#endif
return true;
err:
ERR_print_errors_cb(LogOpenSSLError, NULL);
#if (OPENSSL_VERSION_NUMBER < 0x10100000L)
EVP_MD_CTX_cleanup(evp_md_ctx);
#else
EVP_MD_CTX_free(evp_md_ctx);
#endif
return false;
}