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 #include "net/cert/internal/signature_policy.h" | 5 #include "net/cert/internal/signature_policy.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "net/cert/internal/cert_errors.h" | 8 #include "net/cert/internal/cert_errors.h" |
9 | 9 |
10 #include <openssl/obj.h> | 10 #include <openssl/obj.h> |
(...skipping 18 matching lines...) Expand all Loading... |
29 | 29 |
30 bool SignaturePolicy::IsAcceptableCurveForEcdsa(int curve_nid, | 30 bool SignaturePolicy::IsAcceptableCurveForEcdsa(int curve_nid, |
31 CertErrors* errors) const { | 31 CertErrors* errors) const { |
32 switch (curve_nid) { | 32 switch (curve_nid) { |
33 case NID_X9_62_prime256v1: | 33 case NID_X9_62_prime256v1: |
34 case NID_secp384r1: | 34 case NID_secp384r1: |
35 case NID_secp521r1: | 35 case NID_secp521r1: |
36 return true; | 36 return true; |
37 } | 37 } |
38 | 38 |
39 errors->Add(kUnacceptableCurveForEcdsa); | 39 errors->AddError(kUnacceptableCurveForEcdsa); |
40 return false; | 40 return false; |
41 } | 41 } |
42 | 42 |
43 bool SignaturePolicy::IsAcceptableModulusLengthForRsa( | 43 bool SignaturePolicy::IsAcceptableModulusLengthForRsa( |
44 size_t modulus_length_bits, | 44 size_t modulus_length_bits, |
45 CertErrors* errors) const { | 45 CertErrors* errors) const { |
46 if (modulus_length_bits < 2048) { | 46 if (modulus_length_bits < 2048) { |
47 // TODO(crbug.com/634443): Add a parameter for actual modulus size. | 47 // TODO(crbug.com/634443): Add a parameter for actual modulus size. |
48 errors->Add(kRsaModulusLessThan2048); | 48 errors->AddError(kRsaModulusLessThan2048); |
49 return false; | 49 return false; |
50 } | 50 } |
51 | 51 |
52 return true; | 52 return true; |
53 } | 53 } |
54 | 54 |
55 SimpleSignaturePolicy::SimpleSignaturePolicy(size_t min_rsa_modulus_length_bits) | 55 SimpleSignaturePolicy::SimpleSignaturePolicy(size_t min_rsa_modulus_length_bits) |
56 : min_rsa_modulus_length_bits_(min_rsa_modulus_length_bits) {} | 56 : min_rsa_modulus_length_bits_(min_rsa_modulus_length_bits) {} |
57 | 57 |
58 bool SimpleSignaturePolicy::IsAcceptableModulusLengthForRsa( | 58 bool SimpleSignaturePolicy::IsAcceptableModulusLengthForRsa( |
59 size_t modulus_length_bits, | 59 size_t modulus_length_bits, |
60 CertErrors* errors) const { | 60 CertErrors* errors) const { |
61 if (modulus_length_bits < min_rsa_modulus_length_bits_) { | 61 if (modulus_length_bits < min_rsa_modulus_length_bits_) { |
62 // TODO(crbug.com/634443): Add parameters for actual and expected modulus | 62 // TODO(crbug.com/634443): Add parameters for actual and expected modulus |
63 // size. | 63 // size. |
64 errors->Add(kRsaModulusTooSmall); | 64 errors->AddError(kRsaModulusTooSmall); |
65 return false; | 65 return false; |
66 } | 66 } |
67 | 67 |
68 return true; | 68 return true; |
69 } | 69 } |
70 | 70 |
71 } // namespace net | 71 } // namespace net |
OLD | NEW |