OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_CERT_STATUS_FLAGS_H_ | 5 #ifndef NET_CERT_CERT_STATUS_FLAGS_H_ |
6 #define NET_CERT_CERT_STATUS_FLAGS_H_ | 6 #define NET_CERT_CERT_STATUS_FLAGS_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "net/base/net_export.h" | 9 #include "net/base/net_export.h" |
10 | 10 |
(...skipping 17 matching lines...) Expand all Loading... |
28 static const CertStatus CERT_STATUS_UNABLE_TO_CHECK_REVOCATION = 1 << 5; | 28 static const CertStatus CERT_STATUS_UNABLE_TO_CHECK_REVOCATION = 1 << 5; |
29 static const CertStatus CERT_STATUS_REVOKED = 1 << 6; | 29 static const CertStatus CERT_STATUS_REVOKED = 1 << 6; |
30 static const CertStatus CERT_STATUS_INVALID = 1 << 7; | 30 static const CertStatus CERT_STATUS_INVALID = 1 << 7; |
31 static const CertStatus CERT_STATUS_WEAK_SIGNATURE_ALGORITHM = 1 << 8; | 31 static const CertStatus CERT_STATUS_WEAK_SIGNATURE_ALGORITHM = 1 << 8; |
32 // 1 << 9 was used for CERT_STATUS_NOT_IN_DNS | 32 // 1 << 9 was used for CERT_STATUS_NOT_IN_DNS |
33 static const CertStatus CERT_STATUS_NON_UNIQUE_NAME = 1 << 10; | 33 static const CertStatus CERT_STATUS_NON_UNIQUE_NAME = 1 << 10; |
34 static const CertStatus CERT_STATUS_WEAK_KEY = 1 << 11; | 34 static const CertStatus CERT_STATUS_WEAK_KEY = 1 << 11; |
35 static const CertStatus CERT_STATUS_WEAK_DH_KEY = 1 << 12; | 35 static const CertStatus CERT_STATUS_WEAK_DH_KEY = 1 << 12; |
36 static const CertStatus CERT_STATUS_PINNED_KEY_MISSING = 1 << 13; | 36 static const CertStatus CERT_STATUS_PINNED_KEY_MISSING = 1 << 13; |
37 | 37 |
38 // Bits 16 to 31 are for non-error statuses. | 38 // Bits 16 to 29 are for non-error statuses. |
39 static const CertStatus CERT_STATUS_IS_EV = 1 << 16; | 39 static const CertStatus CERT_STATUS_IS_EV = 1 << 16; |
40 static const CertStatus CERT_STATUS_REV_CHECKING_ENABLED = 1 << 17; | 40 static const CertStatus CERT_STATUS_REV_CHECKING_ENABLED = 1 << 17; |
41 // bit 18 was CERT_STATUS_IS_DNSSEC. | 41 // bit 18 was CERT_STATUS_IS_DNSSEC. |
42 | 42 |
| 43 // Bits 30, 31 are for Certificate Transparency. |
| 44 static const int CERTIFICATE_TRANSPARENCY_STATUS_SHIFT = 30; |
| 45 static const int CERTIFICATE_TRANSPARENCY_STATUS_MASK = 3; |
| 46 enum { |
| 47 CERT_TRANSPARENCY_NO_SCTS = 0, |
| 48 CERT_TRANSPARENCY_SCT_FROM_UNKNOWN_LOGS = 1, |
| 49 CERT_TRANSPARENCY_SCT_FAILED_VALIDATION = 2, |
| 50 CERT_TRANSPARENCY_SCT_VALIDATED_OK = 3, |
| 51 }; |
| 52 |
43 // Returns true if the specified cert status has an error set. | 53 // Returns true if the specified cert status has an error set. |
44 static inline bool IsCertStatusError(CertStatus status) { | 54 static inline bool IsCertStatusError(CertStatus status) { |
45 return (CERT_STATUS_ALL_ERRORS & status) != 0; | 55 return (CERT_STATUS_ALL_ERRORS & status) != 0; |
46 } | 56 } |
47 | 57 |
48 // IsCertStatusMinorError returns true iff |cert_status| indicates a condition | 58 // IsCertStatusMinorError returns true iff |cert_status| indicates a condition |
49 // that should typically be ignored by automated requests. (i.e. a revocation | 59 // that should typically be ignored by automated requests. (i.e. a revocation |
50 // check failure.) | 60 // check failure.) |
51 NET_EXPORT bool IsCertStatusMinorError(CertStatus cert_status); | 61 NET_EXPORT bool IsCertStatusMinorError(CertStatus cert_status); |
52 | 62 |
53 // Maps a network error code to the equivalent certificate status flag. If | 63 // Maps a network error code to the equivalent certificate status flag. If |
54 // the error code is not a certificate error, it is mapped to 0. | 64 // the error code is not a certificate error, it is mapped to 0. |
55 NET_EXPORT CertStatus MapNetErrorToCertStatus(int error); | 65 NET_EXPORT CertStatus MapNetErrorToCertStatus(int error); |
56 | 66 |
57 // Maps the most serious certificate error in the certificate status flags | 67 // Maps the most serious certificate error in the certificate status flags |
58 // to the equivalent network error code. | 68 // to the equivalent network error code. |
59 NET_EXPORT int MapCertStatusToNetError(CertStatus cert_status); | 69 NET_EXPORT int MapCertStatusToNetError(CertStatus cert_status); |
60 | 70 |
| 71 inline int CertificateTransparencyStateFromCertStatus(CertStatus cert_status) { |
| 72 return (cert_status >> CERTIFICATE_TRANSPARENCY_STATUS_SHIFT) & |
| 73 CERTIFICATE_TRANSPARENCY_STATUS_MASK; |
| 74 } |
| 75 |
61 } // namespace net | 76 } // namespace net |
62 | 77 |
63 #endif // NET_CERT_CERT_STATUS_FLAGS_H_ | 78 #endif // NET_CERT_CERT_STATUS_FLAGS_H_ |
OLD | NEW |