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

Side by Side Diff: components/client_update_protocol/ecdsa.cc

Issue 2768033002: Use size_t in crypto::SignatureVerifier. (Closed)
Patch Set: . Created 3 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 | « no previous file | components/crx_file/crx_file.cc » ('j') | crypto/signature_verifier.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "components/client_update_protocol/ecdsa.h" 5 #include "components/client_update_protocol/ecdsa.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 signed_message.insert(signed_message.end(), response_hash.begin(), 163 signed_message.insert(signed_message.end(), response_hash.begin(),
164 response_hash.end()); 164 response_hash.end());
165 signed_message.insert(signed_message.end(), request_query_cup2key_.begin(), 165 signed_message.insert(signed_message.end(), request_query_cup2key_.begin(),
166 request_query_cup2key_.end()); 166 request_query_cup2key_.end());
167 167
168 const std::vector<uint8_t> signed_message_hash = 168 const std::vector<uint8_t> signed_message_hash =
169 SHA256HashVec(signed_message); 169 SHA256HashVec(signed_message);
170 170
171 // Initialize the signature verifier. 171 // Initialize the signature verifier.
172 crypto::SignatureVerifier verifier; 172 crypto::SignatureVerifier verifier;
173 if (!verifier.VerifyInit( 173 if (!verifier.VerifyInit(crypto::SignatureVerifier::ECDSA_SHA256,
174 crypto::SignatureVerifier::ECDSA_SHA256, &signature.front(), 174 &signature.front(), signature.size(),
175 static_cast<int>(signature.size()), &public_key_.front(), 175 &public_key_.front(), public_key_.size())) {
176 static_cast<int>(public_key_.size()))) {
177 DVLOG(1) << "Couldn't init SignatureVerifier."; 176 DVLOG(1) << "Couldn't init SignatureVerifier.";
178 return false; 177 return false;
179 } 178 }
180 179
181 // If the verification fails, that implies one of two outcomes: 180 // If the verification fails, that implies one of two outcomes:
182 // * The signature was modified 181 // * The signature was modified
183 // * The buffer that the server signed does not match the buffer that the 182 // * The buffer that the server signed does not match the buffer that the
184 // client assembled -- implying that either request body or response body 183 // client assembled -- implying that either request body or response body
185 // was modified, or a different nonce value was used. 184 // was modified, or a different nonce value was used.
186 verifier.VerifyUpdate(&signed_message_hash.front(), 185 verifier.VerifyUpdate(&signed_message_hash.front(),
187 static_cast<int>(signed_message_hash.size())); 186 signed_message_hash.size());
188 return verifier.VerifyFinal(); 187 return verifier.VerifyFinal();
189 } 188 }
190 189
191 } // namespace client_update_protocol 190 } // namespace client_update_protocol
OLDNEW
« no previous file with comments | « no previous file | components/crx_file/crx_file.cc » ('j') | crypto/signature_verifier.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698