Index: net/cert/internal/signature_algorithm.cc |
diff --git a/net/cert/internal/signature_algorithm.cc b/net/cert/internal/signature_algorithm.cc |
index 13243ea428798b509d3d804c4308147565d4a935..315243f3968ebe9378ef585af770e841ea02dcd7 100644 |
--- a/net/cert/internal/signature_algorithm.cc |
+++ b/net/cert/internal/signature_algorithm.cc |
@@ -321,49 +321,6 @@ scoped_ptr<SignatureAlgorithm> ParseEcdsa(DigestAlgorithm digest, |
return SignatureAlgorithm::CreateEcdsa(digest); |
} |
-// Parses a HashAlgorithm as defined by RFC 5912: |
-// |
-// HashAlgorithm ::= AlgorithmIdentifier{DIGEST-ALGORITHM, |
-// {HashAlgorithms}} |
-// |
-// HashAlgorithms DIGEST-ALGORITHM ::= { |
-// { IDENTIFIER id-sha1 PARAMS TYPE NULL ARE preferredPresent } | |
-// { IDENTIFIER id-sha224 PARAMS TYPE NULL ARE preferredPresent } | |
-// { IDENTIFIER id-sha256 PARAMS TYPE NULL ARE preferredPresent } | |
-// { IDENTIFIER id-sha384 PARAMS TYPE NULL ARE preferredPresent } | |
-// { IDENTIFIER id-sha512 PARAMS TYPE NULL ARE preferredPresent } |
-// } |
-WARN_UNUSED_RESULT bool ParseHashAlgorithm(const der::Input input, |
- DigestAlgorithm* out) { |
- der::Input oid; |
- der::Input params; |
- if (!ParseAlgorithmIdentifier(input, &oid, ¶ms)) |
- return false; |
- |
- DigestAlgorithm hash; |
- |
- if (oid == der::Input(kOidSha1)) { |
- hash = DigestAlgorithm::Sha1; |
- } else if (oid == der::Input(kOidSha256)) { |
- hash = DigestAlgorithm::Sha256; |
- } else if (oid == der::Input(kOidSha384)) { |
- hash = DigestAlgorithm::Sha384; |
- } else if (oid == der::Input(kOidSha512)) { |
- hash = DigestAlgorithm::Sha512; |
- } else { |
- // Unsupported digest algorithm. |
- return false; |
- } |
- |
- // From RFC 5912: "PARAMS TYPE NULL ARE preferredPresent". Which is to say |
- // the can either be absent, or NULL. |
- if (!IsEmpty(params) && !IsNull(params)) |
- return false; |
- |
- *out = hash; |
- return true; |
-} |
- |
// Parses a MaskGenAlgorithm as defined by RFC 5912: |
// |
// MaskGenAlgorithm ::= AlgorithmIdentifier{ALGORITHM, |
@@ -539,6 +496,37 @@ scoped_ptr<SignatureAlgorithm> ParseRsaPss(const der::Input& params) { |
} // namespace |
+WARN_UNUSED_RESULT bool ParseHashAlgorithm(const der::Input input, |
+ DigestAlgorithm* out) { |
+ der::Input oid; |
+ der::Input params; |
+ if (!ParseAlgorithmIdentifier(input, &oid, ¶ms)) |
+ return false; |
+ |
+ DigestAlgorithm hash; |
+ |
+ if (oid == der::Input(kOidSha1)) { |
+ hash = DigestAlgorithm::Sha1; |
+ } else if (oid == der::Input(kOidSha256)) { |
+ hash = DigestAlgorithm::Sha256; |
+ } else if (oid == der::Input(kOidSha384)) { |
+ hash = DigestAlgorithm::Sha384; |
+ } else if (oid == der::Input(kOidSha512)) { |
+ hash = DigestAlgorithm::Sha512; |
+ } else { |
+ // Unsupported digest algorithm. |
+ return false; |
+ } |
+ |
+ // From RFC 5912: "PARAMS TYPE NULL ARE preferredPresent". Which is to say |
+ // the can either be absent, or NULL. |
+ if (!IsEmpty(params) && !IsNull(params)) |
+ return false; |
+ |
+ *out = hash; |
+ return true; |
+} |
+ |
RsaPssParameters::RsaPssParameters(DigestAlgorithm mgf1_hash, |
uint32_t salt_length) |
: mgf1_hash_(mgf1_hash), salt_length_(salt_length) { |