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

Side by Side Diff: crypto/signature_verifier_openssl.cc

Issue 1739403002: Cut down on usage of deprecated APIs in //crypto. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: grumble grumble string vector char uint8_t grumble Created 4 years, 9 months 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 unified diff | Download patch
« no previous file with comments | « crypto/rsa_private_key_openssl.cc ('k') | net/socket/ssl_client_socket_openssl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "crypto/signature_verifier.h" 5 #include "crypto/signature_verifier.h"
6 6
7 #include <openssl/bytestring.h>
7 #include <openssl/evp.h> 8 #include <openssl/evp.h>
8 #include <openssl/x509.h> 9 #include <openssl/x509.h>
9 #include <stdint.h> 10 #include <stdint.h>
10 11
11 #include <vector> 12 #include <vector>
12 13
13 #include "base/logging.h" 14 #include "base/logging.h"
14 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
15 #include "crypto/openssl_util.h" 16 #include "crypto/openssl_util.h"
16 #include "crypto/scoped_openssl_types.h" 17 #include "crypto/scoped_openssl_types.h"
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 const uint8_t* public_key_info, 133 const uint8_t* public_key_info,
133 int public_key_info_len, 134 int public_key_info_len,
134 EVP_PKEY_CTX** pkey_ctx) { 135 EVP_PKEY_CTX** pkey_ctx) {
135 if (verify_context_) 136 if (verify_context_)
136 return false; 137 return false;
137 138
138 verify_context_ = new VerifyContext; 139 verify_context_ = new VerifyContext;
139 140
140 signature_.assign(signature, signature + signature_len); 141 signature_.assign(signature, signature + signature_len);
141 142
142 const uint8_t* ptr = public_key_info; 143 CBS cbs;
143 ScopedEVP_PKEY public_key(d2i_PUBKEY(nullptr, &ptr, public_key_info_len)); 144 CBS_init(&cbs, public_key_info, public_key_info_len);
144 if (!public_key.get() || ptr != public_key_info + public_key_info_len) 145 ScopedEVP_PKEY public_key(EVP_parse_public_key(&cbs));
146 if (!public_key || CBS_len(&cbs) != 0)
145 return false; 147 return false;
146 148
147 verify_context_->ctx.reset(EVP_MD_CTX_create()); 149 verify_context_->ctx.reset(EVP_MD_CTX_create());
148 int rv = EVP_DigestVerifyInit(verify_context_->ctx.get(), pkey_ctx, 150 int rv = EVP_DigestVerifyInit(verify_context_->ctx.get(), pkey_ctx,
149 digest, nullptr, public_key.get()); 151 digest, nullptr, public_key.get());
150 return rv == 1; 152 return rv == 1;
151 } 153 }
152 154
153 void SignatureVerifier::Reset() { 155 void SignatureVerifier::Reset() {
154 delete verify_context_; 156 delete verify_context_;
155 verify_context_ = NULL; 157 verify_context_ = NULL;
156 signature_.clear(); 158 signature_.clear();
157 } 159 }
158 160
159 } // namespace crypto 161 } // namespace crypto
OLDNEW
« no previous file with comments | « crypto/rsa_private_key_openssl.cc ('k') | net/socket/ssl_client_socket_openssl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698