Chromium Code Reviews| Index: net/cert/internal/verification_policy.h |
| diff --git a/net/cert/internal/verification_policy.h b/net/cert/internal/verification_policy.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..c255b38bfcf50957862acb24e2caf3acf5e4510d |
| --- /dev/null |
| +++ b/net/cert/internal/verification_policy.h |
| @@ -0,0 +1,62 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef NET_CERT_INTERNAL_VERIFICATION_POLICY_H_ |
| +#define NET_CERT_INTERNAL_VERIFICATION_POLICY_H_ |
| + |
| +#include "base/compiler_specific.h" |
| +#include "net/base/net_export.h" |
| +#include "net/cert/internal/signature_algorithm.h" |
| + |
| +namespace net { |
| + |
| +class SignatureAlgorithm; |
| + |
| +// This interface specifies policies that apply when verifying signed data. |
| +class NET_EXPORT VerificationPolicy { |
|
Ryan Sleevi
2015/07/28 21:14:53
Naming wise, this seems like it should be Signatur
eroman
2015/07/29 02:44:43
Done.
|
| + public: |
| + virtual ~VerificationPolicy() {} |
| + |
| + // Implementations should return true if |algorithm| is an allowed digest |
| + // algorithm. This will be called *anywhere* a hash algorithm is used, which |
| + // includes the main digest algorithm for RSA PKCS#1 v1.5, ECDSA, and |
| + // RSASSA-PSS, and also includes the hash function used by RSASSA-PSS mask |
| + // gen function. |
| + virtual bool IsAcceptableDigestAlgorithm(DigestAlgorithm algorithm) const = 0; |
|
Ryan Sleevi
2015/07/28 21:14:53
I'm a little torn on this interface, whether it sh
eroman
2015/07/29 02:44:43
Done (Changed to take a signature algorithm instea
|
| + |
| + // Implementations should return true if |curve_nid| is an allowed |
| + // elliptical curve. |curve_nid| is an object ID from BoringSSL (for example |
| + // NID_secp384r1). |
| + virtual bool IsAcceptableCurveForEcdsa(int curve_nid) const = 0; |
| + |
| + // Implementations should return true if |modulus_length_bits| is an allowed |
| + // RSA key size in bits. |
| + virtual bool IsAcceptableModulusLengthForRsa( |
| + size_t modulus_length_bits) const = 0; |
|
Ryan Sleevi
2015/07/28 21:14:53
We arguably similarly have an EC policy (nothing l
eroman
2015/07/29 02:44:43
This should already be covered by the IsAcceptable
|
| +}; |
| + |
| +// BaseVerificationPolicy is a concrete implementation of VerificationPolicy |
| +// that applies some default behaviors, and allows configuring the minimum RSA |
| +// key length. |
| +// |
| +// * Accepts all digest algorithms: SHA-1, SHA-256, SHA-384, SHA-512 |
| +// * Accepts the following curves: secp256r1, secp384r1, secp521r1 |
| +class NET_EXPORT BaseVerificationPolicy : public VerificationPolicy { |
|
Ryan Sleevi
2015/07/28 21:14:53
Curious why this split?
That is, why a pure virtu
eroman
2015/07/29 02:44:43
My reason for the split mainly came because of not
|
| + public: |
| + explicit BaseVerificationPolicy(size_t min_rsa_modulus_length_bits); |
| + |
| + bool IsAcceptableDigestAlgorithm(DigestAlgorithm algorithm) const override; |
| + |
| + bool IsAcceptableCurveForEcdsa(int curve_nid) const override; |
| + |
| + bool IsAcceptableModulusLengthForRsa( |
| + size_t modulus_length_bits) const override; |
| + |
| + private: |
| + const size_t min_rsa_modulus_length_bits_; |
| +}; |
| + |
| +} // namespace net |
| + |
| +#endif // NET_CERT_INTERNAL_VERIFICATION_POLICY_H_ |