| 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 #ifndef NET_CERT_INTERNAL_SIGNATURE_ALGORITHM_H_ | 5 #ifndef NET_CERT_INTERNAL_SIGNATURE_ALGORITHM_H_ |
| 6 #define NET_CERT_INTERNAL_SIGNATURE_ALGORITHM_H_ | 6 #define NET_CERT_INTERNAL_SIGNATURE_ALGORITHM_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 | 11 |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "net/base/net_export.h" | 14 #include "net/base/net_export.h" |
| 15 | 15 |
| 16 namespace net { | 16 namespace net { |
| 17 | 17 |
| 18 class CertErrors; |
| 19 |
| 18 namespace der { | 20 namespace der { |
| 19 class Input; | 21 class Input; |
| 20 } // namespace der | 22 } // namespace der |
| 21 | 23 |
| 22 // The digest algorithm used within a signature. | 24 // The digest algorithm used within a signature. |
| 23 enum class DigestAlgorithm { | 25 enum class DigestAlgorithm { |
| 24 Sha1, | 26 Sha1, |
| 25 Sha256, | 27 Sha256, |
| 26 Sha384, | 28 Sha384, |
| 27 Sha512, | 29 Sha512, |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 // SignatureAlgorithm describes a signature algorithm and its parameters. This | 82 // SignatureAlgorithm describes a signature algorithm and its parameters. This |
| 81 // corresponds to "AlgorithmIdentifier" from RFC 5280. | 83 // corresponds to "AlgorithmIdentifier" from RFC 5280. |
| 82 class NET_EXPORT SignatureAlgorithm { | 84 class NET_EXPORT SignatureAlgorithm { |
| 83 public: | 85 public: |
| 84 ~SignatureAlgorithm(); | 86 ~SignatureAlgorithm(); |
| 85 | 87 |
| 86 SignatureAlgorithmId algorithm() const { return algorithm_; } | 88 SignatureAlgorithmId algorithm() const { return algorithm_; } |
| 87 DigestAlgorithm digest() const { return digest_; } | 89 DigestAlgorithm digest() const { return digest_; } |
| 88 | 90 |
| 89 // Creates a SignatureAlgorithm by parsing a DER-encoded "AlgorithmIdentifier" | 91 // Creates a SignatureAlgorithm by parsing a DER-encoded "AlgorithmIdentifier" |
| 90 // (RFC 5280). Returns nullptr on failure. | 92 // (RFC 5280). Returns nullptr on failure. If |errors| was non-null then |
| 91 static std::unique_ptr<SignatureAlgorithm> CreateFromDer( | 93 // error/warning information is output to it. |
| 92 const der::Input& algorithm_identifier); | 94 static std::unique_ptr<SignatureAlgorithm> Create( |
| 95 const der::Input& algorithm_identifier, |
| 96 CertErrors* errors); |
| 93 | 97 |
| 94 // Creates a new SignatureAlgorithm with the given type and parameters. | 98 // Creates a new SignatureAlgorithm with the given type and parameters. |
| 99 // Guaranteed to return non-null result. |
| 95 static std::unique_ptr<SignatureAlgorithm> CreateRsaPkcs1( | 100 static std::unique_ptr<SignatureAlgorithm> CreateRsaPkcs1( |
| 96 DigestAlgorithm digest); | 101 DigestAlgorithm digest); |
| 97 static std::unique_ptr<SignatureAlgorithm> CreateEcdsa( | 102 static std::unique_ptr<SignatureAlgorithm> CreateEcdsa( |
| 98 DigestAlgorithm digest); | 103 DigestAlgorithm digest); |
| 99 static std::unique_ptr<SignatureAlgorithm> CreateRsaPss( | 104 static std::unique_ptr<SignatureAlgorithm> CreateRsaPss( |
| 100 DigestAlgorithm digest, | 105 DigestAlgorithm digest, |
| 101 DigestAlgorithm mgf1_hash, | 106 DigestAlgorithm mgf1_hash, |
| 102 uint32_t salt_length); | 107 uint32_t salt_length); |
| 103 | 108 |
| 104 // The following methods retrieve the parameters for the signature algorithm. | 109 // The following methods retrieve the parameters for the signature algorithm. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 118 const SignatureAlgorithmId algorithm_; | 123 const SignatureAlgorithmId algorithm_; |
| 119 const DigestAlgorithm digest_; | 124 const DigestAlgorithm digest_; |
| 120 const std::unique_ptr<SignatureAlgorithmParameters> params_; | 125 const std::unique_ptr<SignatureAlgorithmParameters> params_; |
| 121 | 126 |
| 122 DISALLOW_COPY_AND_ASSIGN(SignatureAlgorithm); | 127 DISALLOW_COPY_AND_ASSIGN(SignatureAlgorithm); |
| 123 }; | 128 }; |
| 124 | 129 |
| 125 } // namespace net | 130 } // namespace net |
| 126 | 131 |
| 127 #endif // NET_CERT_INTERNAL_SIGNATURE_ALGORITHM_H_ | 132 #endif // NET_CERT_INTERNAL_SIGNATURE_ALGORITHM_H_ |
| OLD | NEW |