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

Side by Side Diff: net/quic/crypto/proof_verifier_chromium.cc

Issue 1679873005: Switch SignatureVerifier to taking an algorithm enum. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix iOS build 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 | « extensions/browser/verified_contents.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "net/quic/crypto/proof_verifier_chromium.h" 5 #include "net/quic/crypto/proof_verifier_chromium.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 358
359 bool ok = verifier.VerifyInitRSAPSS( 359 bool ok = verifier.VerifyInitRSAPSS(
360 hash_alg, mask_hash_alg, hash_len, 360 hash_alg, mask_hash_alg, hash_len,
361 reinterpret_cast<const uint8_t*>(signature.data()), signature.size(), 361 reinterpret_cast<const uint8_t*>(signature.data()), signature.size(),
362 reinterpret_cast<const uint8_t*>(spki.data()), spki.size()); 362 reinterpret_cast<const uint8_t*>(spki.data()), spki.size());
363 if (!ok) { 363 if (!ok) {
364 DLOG(WARNING) << "VerifyInitRSAPSS failed"; 364 DLOG(WARNING) << "VerifyInitRSAPSS failed";
365 return false; 365 return false;
366 } 366 }
367 } else if (type == X509Certificate::kPublicKeyTypeECDSA) { 367 } else if (type == X509Certificate::kPublicKeyTypeECDSA) {
368 // This is the algorithm ID for ECDSA with SHA-256. Parameters are ABSENT. 368 if (!verifier.VerifyInit(crypto::SignatureVerifier::ECDSA_SHA256,
369 // RFC 5758: 369 reinterpret_cast<const uint8_t*>(signature.data()),
370 // ecdsa-with-SHA256 OBJECT IDENTIFIER ::= { iso(1) member-body(2) 370 signature.size(),
371 // us(840) ansi-X9-62(10045) signatures(4) ecdsa-with-SHA2(3) 2 } 371 reinterpret_cast<const uint8_t*>(spki.data()),
372 // ... 372 spki.size())) {
373 // When the ecdsa-with-SHA224, ecdsa-with-SHA256, ecdsa-with-SHA384, or
374 // ecdsa-with-SHA512 algorithm identifier appears in the algorithm field
375 // as an AlgorithmIdentifier, the encoding MUST omit the parameters
376 // field. That is, the AlgorithmIdentifier SHALL be a SEQUENCE of one
377 // component, the OID ecdsa-with-SHA224, ecdsa-with-SHA256, ecdsa-with-
378 // SHA384, or ecdsa-with-SHA512.
379 // See also RFC 5480, Appendix A.
380 static const uint8_t kECDSAWithSHA256AlgorithmID[] = {
381 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02,
382 };
383
384 if (!verifier.VerifyInit(
385 kECDSAWithSHA256AlgorithmID, sizeof(kECDSAWithSHA256AlgorithmID),
386 reinterpret_cast<const uint8_t*>(signature.data()),
387 signature.size(), reinterpret_cast<const uint8_t*>(spki.data()),
388 spki.size())) {
389 DLOG(WARNING) << "VerifyInit failed"; 373 DLOG(WARNING) << "VerifyInit failed";
390 return false; 374 return false;
391 } 375 }
392 } else { 376 } else {
393 LOG(ERROR) << "Unsupported public key type " << type; 377 LOG(ERROR) << "Unsupported public key type " << type;
394 return false; 378 return false;
395 } 379 }
396 380
397 verifier.VerifyUpdate(reinterpret_cast<const uint8_t*>(kProofSignatureLabel), 381 verifier.VerifyUpdate(reinterpret_cast<const uint8_t*>(kProofSignatureLabel),
398 sizeof(kProofSignatureLabel)); 382 sizeof(kProofSignatureLabel));
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 } 434 }
451 return status; 435 return status;
452 } 436 }
453 437
454 void ProofVerifierChromium::OnJobComplete(Job* job) { 438 void ProofVerifierChromium::OnJobComplete(Job* job) {
455 active_jobs_.erase(job); 439 active_jobs_.erase(job);
456 delete job; 440 delete job;
457 } 441 }
458 442
459 } // namespace net 443 } // namespace net
OLDNEW
« no previous file with comments | « extensions/browser/verified_contents.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698