Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef NET_CERT_INTERNAL_VERIFICATION_POLICY_H_ | |
| 6 #define NET_CERT_INTERNAL_VERIFICATION_POLICY_H_ | |
| 7 | |
| 8 #include "base/compiler_specific.h" | |
| 9 #include "net/base/net_export.h" | |
| 10 #include "net/cert/internal/signature_algorithm.h" | |
| 11 | |
| 12 namespace net { | |
| 13 | |
| 14 class SignatureAlgorithm; | |
| 15 | |
| 16 // This interface specifies policies that apply when verifying signed data. | |
| 17 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.
| |
| 18 public: | |
| 19 virtual ~VerificationPolicy() {} | |
| 20 | |
| 21 // Implementations should return true if |algorithm| is an allowed digest | |
| 22 // algorithm. This will be called *anywhere* a hash algorithm is used, which | |
| 23 // includes the main digest algorithm for RSA PKCS#1 v1.5, ECDSA, and | |
| 24 // RSASSA-PSS, and also includes the hash function used by RSASSA-PSS mask | |
| 25 // gen function. | |
| 26 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
| |
| 27 | |
| 28 // Implementations should return true if |curve_nid| is an allowed | |
| 29 // elliptical curve. |curve_nid| is an object ID from BoringSSL (for example | |
| 30 // NID_secp384r1). | |
| 31 virtual bool IsAcceptableCurveForEcdsa(int curve_nid) const = 0; | |
| 32 | |
| 33 // Implementations should return true if |modulus_length_bits| is an allowed | |
| 34 // RSA key size in bits. | |
| 35 virtual bool IsAcceptableModulusLengthForRsa( | |
| 36 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
| |
| 37 }; | |
| 38 | |
| 39 // BaseVerificationPolicy is a concrete implementation of VerificationPolicy | |
| 40 // that applies some default behaviors, and allows configuring the minimum RSA | |
| 41 // key length. | |
| 42 // | |
| 43 // * Accepts all digest algorithms: SHA-1, SHA-256, SHA-384, SHA-512 | |
| 44 // * Accepts the following curves: secp256r1, secp384r1, secp521r1 | |
| 45 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
| |
| 46 public: | |
| 47 explicit BaseVerificationPolicy(size_t min_rsa_modulus_length_bits); | |
| 48 | |
| 49 bool IsAcceptableDigestAlgorithm(DigestAlgorithm algorithm) const override; | |
| 50 | |
| 51 bool IsAcceptableCurveForEcdsa(int curve_nid) const override; | |
| 52 | |
| 53 bool IsAcceptableModulusLengthForRsa( | |
| 54 size_t modulus_length_bits) const override; | |
| 55 | |
| 56 private: | |
| 57 const size_t min_rsa_modulus_length_bits_; | |
| 58 }; | |
| 59 | |
| 60 } // namespace net | |
| 61 | |
| 62 #endif // NET_CERT_INTERNAL_VERIFICATION_POLICY_H_ | |
| OLD | NEW |