Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(32)

Unified Diff: crypto/signature_verifier_openssl.cc

Issue 685063007: Check trailing data when parsing ASN.1. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « crypto/rsa_private_key_openssl.cc ('k') | crypto/signature_verifier_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: crypto/signature_verifier_openssl.cc
diff --git a/crypto/signature_verifier_openssl.cc b/crypto/signature_verifier_openssl.cc
index a855120ef83bd233cae7b7e4be1d1ba2fce3627b..53637ebb60a269eb90f34e69e57d847498a3eef8 100644
--- a/crypto/signature_verifier_openssl.cc
+++ b/crypto/signature_verifier_openssl.cc
@@ -141,19 +141,14 @@ bool SignatureVerifier::CommonInit(const EVP_MD* digest,
signature_.assign(signature, signature + signature_len);
- // BIO_new_mem_buf is not const aware, but it does not modify the buffer.
- char* data = reinterpret_cast<char*>(const_cast<uint8*>(public_key_info));
- ScopedBIO bio(BIO_new_mem_buf(data, public_key_info_len));
- if (!bio.get())
- return false;
-
- ScopedEVP_PKEY public_key(d2i_PUBKEY_bio(bio.get(), NULL));
- if (!public_key.get())
+ const uint8_t* ptr = public_key_info;
+ ScopedEVP_PKEY public_key(d2i_PUBKEY(nullptr, &ptr, public_key_info_len));
+ if (!public_key.get() || ptr != public_key_info + public_key_info_len)
return false;
verify_context_->ctx.reset(EVP_MD_CTX_create());
int rv = EVP_DigestVerifyInit(verify_context_->ctx.get(), pkey_ctx,
- digest, NULL, public_key.get());
+ digest, nullptr, public_key.get());
return rv == 1;
}
« no previous file with comments | « crypto/rsa_private_key_openssl.cc ('k') | crypto/signature_verifier_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698