Chromium Code Reviews| Index: net/cert/internal/signature_algorithm.cc |
| diff --git a/net/cert/internal/signature_algorithm.cc b/net/cert/internal/signature_algorithm.cc |
| index 9853ac024988d47ea2c051313497b71487af5cdb..19bb1838d284728e207744b01df631be7e41a56d 100644 |
| --- a/net/cert/internal/signature_algorithm.cc |
| +++ b/net/cert/internal/signature_algorithm.cc |
| @@ -513,7 +513,7 @@ std::unique_ptr<SignatureAlgorithm> ParseRsaPss(const der::Input& params) { |
| } // namespace |
| -WARN_UNUSED_RESULT bool ParseHashAlgorithm(const der::Input input, |
| +WARN_UNUSED_RESULT bool ParseHashAlgorithm(const der::Input& input, |
| DigestAlgorithm* out) { |
| der::Input oid; |
| der::Input params; |
| @@ -638,6 +638,39 @@ const RsaPssParameters* SignatureAlgorithm::ParamsForRsaPss() const { |
| return nullptr; |
| } |
| +bool SignatureAlgorithm::IsEquivalent(const der::Input& alg1_tlv, |
| + const der::Input& alg2_tlv) { |
| + if (alg1_tlv == alg2_tlv) |
| + return true; |
| + |
| + auto alg1 = Create(alg1_tlv, nullptr); |
| + auto alg2 = Create(alg2_tlv, nullptr); |
|
Ryan Sleevi
2017/03/09 00:45:26
I think this runs afoul of several of the principl
eroman
2017/03/09 01:09:44
Done.
|
| + |
| + // Do checks that apply to all algorithms. |
| + if (!alg1 || !alg2 || (alg1->algorithm() != alg2->algorithm()) || |
| + (alg1->digest() != alg2->digest())) { |
| + return false; |
| + } |
| + |
| + // Check algorithm-specific parameters for equality. |
| + switch (alg1->algorithm()) { |
| + case SignatureAlgorithmId::RsaPkcs1: |
| + case SignatureAlgorithmId::Ecdsa: |
| + DCHECK(!alg1->has_params()); |
| + DCHECK(!alg2->has_params()); |
| + return true; |
| + case SignatureAlgorithmId::RsaPss: { |
| + const auto* params1 = alg1->ParamsForRsaPss(); |
| + const auto* params2 = alg2->ParamsForRsaPss(); |
|
Ryan Sleevi
2017/03/09 00:45:26
ditto here
eroman
2017/03/09 01:09:44
Done.
|
| + return params1 && params2 && |
| + (params1->salt_length() == params2->salt_length()) && |
| + (params1->mgf1_hash() == params2->mgf1_hash()); |
| + } |
| + } |
| + |
| + return false; |
| +} |
| + |
| SignatureAlgorithm::SignatureAlgorithm( |
| SignatureAlgorithmId algorithm, |
| DigestAlgorithm digest, |