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

Side by Side Diff: net/cert/internal/signature_algorithm.cc

Issue 2349093002: Change the interface for parsing SignatureAlgorithm to take a (Closed)
Patch Set: rebase Created 4 years, 3 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/cert/internal/signature_algorithm.h" 5 #include "net/cert/internal/signature_algorithm.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 } 530 }
531 531
532 RsaPssParameters::RsaPssParameters(DigestAlgorithm mgf1_hash, 532 RsaPssParameters::RsaPssParameters(DigestAlgorithm mgf1_hash,
533 uint32_t salt_length) 533 uint32_t salt_length)
534 : mgf1_hash_(mgf1_hash), salt_length_(salt_length) { 534 : mgf1_hash_(mgf1_hash), salt_length_(salt_length) {
535 } 535 }
536 536
537 SignatureAlgorithm::~SignatureAlgorithm() { 537 SignatureAlgorithm::~SignatureAlgorithm() {
538 } 538 }
539 539
540 std::unique_ptr<SignatureAlgorithm> SignatureAlgorithm::CreateFromDer( 540 std::unique_ptr<SignatureAlgorithm> SignatureAlgorithm::Create(
541 const der::Input& algorithm_identifier) { 541 const der::Input& algorithm_identifier,
542 CertErrors* errors) {
543 // TODO(crbug.com/634443): Add useful error information.
544
542 der::Input oid; 545 der::Input oid;
543 der::Input params; 546 der::Input params;
544 if (!ParseAlgorithmIdentifier(algorithm_identifier, &oid, &params)) 547 if (!ParseAlgorithmIdentifier(algorithm_identifier, &oid, &params))
545 return nullptr; 548 return nullptr;
546 549
547 // TODO(eroman): Each OID is tested for equality in order, which is not 550 // TODO(eroman): Each OID is tested for equality in order, which is not
548 // particularly efficient. 551 // particularly efficient.
549 552
550 if (oid == der::Input(kOidSha1WithRsaEncryption)) 553 if (oid == der::Input(kOidSha1WithRsaEncryption))
551 return ParseRsaPkcs1(DigestAlgorithm::Sha1, params); 554 return ParseRsaPkcs1(DigestAlgorithm::Sha1, params);
(...skipping 18 matching lines...) Expand all
570 573
571 if (oid == der::Input(kOidEcdsaWithSha512)) 574 if (oid == der::Input(kOidEcdsaWithSha512))
572 return ParseEcdsa(DigestAlgorithm::Sha512, params); 575 return ParseEcdsa(DigestAlgorithm::Sha512, params);
573 576
574 if (oid == der::Input(kOidRsaSsaPss)) 577 if (oid == der::Input(kOidRsaSsaPss))
575 return ParseRsaPss(params); 578 return ParseRsaPss(params);
576 579
577 if (oid == der::Input(kOidSha1WithRsaSignature)) 580 if (oid == der::Input(kOidSha1WithRsaSignature))
578 return ParseRsaPkcs1(DigestAlgorithm::Sha1, params); 581 return ParseRsaPkcs1(DigestAlgorithm::Sha1, params);
579 582
583 // TODO(crbug.com/634443): Add an error indicating what the OID
584 // was.
585
580 return nullptr; // Unsupported OID. 586 return nullptr; // Unsupported OID.
581 } 587 }
582 588
583 std::unique_ptr<SignatureAlgorithm> SignatureAlgorithm::CreateRsaPkcs1( 589 std::unique_ptr<SignatureAlgorithm> SignatureAlgorithm::CreateRsaPkcs1(
584 DigestAlgorithm digest) { 590 DigestAlgorithm digest) {
585 return base::WrapUnique( 591 return base::WrapUnique(
586 new SignatureAlgorithm(SignatureAlgorithmId::RsaPkcs1, digest, nullptr)); 592 new SignatureAlgorithm(SignatureAlgorithmId::RsaPkcs1, digest, nullptr));
587 } 593 }
588 594
589 std::unique_ptr<SignatureAlgorithm> SignatureAlgorithm::CreateEcdsa( 595 std::unique_ptr<SignatureAlgorithm> SignatureAlgorithm::CreateEcdsa(
(...skipping 17 matching lines...) Expand all
607 return nullptr; 613 return nullptr;
608 } 614 }
609 615
610 SignatureAlgorithm::SignatureAlgorithm( 616 SignatureAlgorithm::SignatureAlgorithm(
611 SignatureAlgorithmId algorithm, 617 SignatureAlgorithmId algorithm,
612 DigestAlgorithm digest, 618 DigestAlgorithm digest,
613 std::unique_ptr<SignatureAlgorithmParameters> params) 619 std::unique_ptr<SignatureAlgorithmParameters> params)
614 : algorithm_(algorithm), digest_(digest), params_(std::move(params)) {} 620 : algorithm_(algorithm), digest_(digest), params_(std::move(params)) {}
615 621
616 } // namespace net 622 } // namespace net
OLDNEW
« no previous file with comments | « net/cert/internal/signature_algorithm.h ('k') | net/cert/internal/signature_algorithm_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698