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_SIGNATURE_POLICY_H_ | |
| 6 #define NET_CERT_INTERNAL_SIGNATURE_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 // SignaturePolicy is an interface (and base implementation) for applying | |
| 17 // policies when verifying signed data. It lets callers override which | |
| 18 // algorithms, named curves, and key sizes to allow. | |
| 19 class NET_EXPORT SignaturePolicy { | |
| 20 public: | |
| 21 virtual ~SignaturePolicy() {} | |
| 22 | |
| 23 // Implementations should return true if |algorithm| is acceptable. For | |
| 24 // instance, implementations could reject any signature algorithms that used | |
| 25 // SHA-1. | |
| 26 // | |
| 27 // The default implementation accepts all signature algorithms. | |
| 28 virtual bool IsAcceptableSignatureAlgorithm( | |
| 29 const SignatureAlgorithm& algorithm) const; | |
| 30 | |
| 31 // Implementations should return true if |curve_nid| is an allowed | |
| 32 // elliptical curve. |curve_nid| is an object ID from BoringSSL (for example | |
| 33 // NID_secp384r1). | |
|
davidben
2015/08/03 18:52:48
This means the interface has a BoringSSL dependenc
eroman
2015/08/06 21:15:38
Acknowledged (left the dependency as-is)
| |
| 34 // | |
| 35 // The default implementation accepts secp256r1, secp384r1, secp521r1 only. | |
| 36 virtual bool IsAcceptableCurveForEcdsa(int curve_nid) const; | |
| 37 | |
| 38 // Implementations should return true if |modulus_length_bits| is an allowed | |
| 39 // RSA key size in bits. | |
| 40 // | |
| 41 // The default implementation accepts any modulus length >= 2048 bits. | |
| 42 virtual bool IsAcceptableModulusLengthForRsa( | |
| 43 size_t modulus_length_bits) const; | |
| 44 }; | |
| 45 | |
| 46 // SimpleSignaturePolicy modifies the base SignaturePolicy by allowing the | |
| 47 // minimum RSA key length to be specified (rather than hard coded to 2048). | |
| 48 class NET_EXPORT SimpleSignaturePolicy : public SignaturePolicy { | |
|
davidben
2015/08/03 18:52:49
Do you expect this to be used outside of the test
eroman
2015/08/06 21:15:38
I *think* it will be used outside of the test, sin
| |
| 49 public: | |
| 50 explicit SimpleSignaturePolicy(size_t min_rsa_modulus_length_bits); | |
| 51 | |
| 52 bool IsAcceptableModulusLengthForRsa( | |
| 53 size_t modulus_length_bits) const override; | |
| 54 | |
| 55 private: | |
| 56 const size_t min_rsa_modulus_length_bits_; | |
| 57 }; | |
| 58 | |
| 59 } // namespace net | |
| 60 | |
| 61 #endif // NET_CERT_INTERNAL_SIGNATURE_POLICY_H_ | |
| OLD | NEW |