| OLD | NEW |
| 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 Loading... |
| 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, ¶ms)) | 547 if (!ParseAlgorithmIdentifier(algorithm_identifier, &oid, ¶ms)) |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |