| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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_BASE_CERT_STATUS_FLAGS_H_ | 5 #ifndef NET_BASE_CERT_STATUS_FLAGS_H_ |
| 6 #define NET_BASE_CERT_STATUS_FLAGS_H_ | 6 #define NET_BASE_CERT_STATUS_FLAGS_H_ |
| 7 | 7 |
| 8 namespace net { | 8 namespace net { |
| 9 | 9 |
| 10 // Status flags, such as errors and extended validation. | 10 // Status flags, such as errors and extended validation. |
| 11 enum { | 11 enum { |
| 12 // Bits 0 to 15 are for errors. | 12 // Bits 0 to 15 are for errors. |
| 13 CERT_STATUS_ALL_ERRORS = 0xFFFF, | 13 CERT_STATUS_ALL_ERRORS = 0xFFFF, |
| 14 CERT_STATUS_COMMON_NAME_INVALID = 1 << 0, | 14 CERT_STATUS_COMMON_NAME_INVALID = 1 << 0, |
| 15 CERT_STATUS_DATE_INVALID = 1 << 1, | 15 CERT_STATUS_DATE_INVALID = 1 << 1, |
| 16 CERT_STATUS_AUTHORITY_INVALID = 1 << 2, | 16 CERT_STATUS_AUTHORITY_INVALID = 1 << 2, |
| 17 // 1 << 3 is reserved for ERR_CERT_CONTAINS_ERRORS (not useful with WinHTTP). | 17 // 1 << 3 is reserved for ERR_CERT_CONTAINS_ERRORS (not useful with WinHTTP). |
| 18 CERT_STATUS_NO_REVOCATION_MECHANISM = 1 << 4, | 18 CERT_STATUS_NO_REVOCATION_MECHANISM = 1 << 4, |
| 19 CERT_STATUS_UNABLE_TO_CHECK_REVOCATION = 1 << 5, | 19 CERT_STATUS_UNABLE_TO_CHECK_REVOCATION = 1 << 5, |
| 20 CERT_STATUS_REVOKED = 1 << 6, | 20 CERT_STATUS_REVOKED = 1 << 6, |
| 21 CERT_STATUS_INVALID = 1 << 7, | 21 CERT_STATUS_INVALID = 1 << 7, |
| 22 CERT_STATUS_WEAK_SIGNATURE_ALGORITHM = 1 << 8, |
| 22 | 23 |
| 23 // Bits 16 to 30 are for non-error statuses. | 24 // Bits 16 to 30 are for non-error statuses. |
| 24 CERT_STATUS_IS_EV = 1 << 16, | 25 CERT_STATUS_IS_EV = 1 << 16, |
| 25 CERT_STATUS_REV_CHECKING_ENABLED = 1 << 17, | 26 CERT_STATUS_REV_CHECKING_ENABLED = 1 << 17, |
| 26 | 27 |
| 27 // 1 << 31 (the sign bit) is reserved so that the cert status will never be | 28 // 1 << 31 (the sign bit) is reserved so that the cert status will never be |
| 28 // negative. | 29 // negative. |
| 29 }; | 30 }; |
| 30 | 31 |
| 31 // Returns true if the specified cert status has an error set. | 32 // Returns true if the specified cert status has an error set. |
| 32 static inline bool IsCertStatusError(int status) { | 33 static inline bool IsCertStatusError(int status) { |
| 33 return (CERT_STATUS_ALL_ERRORS & status) != 0; | 34 return (CERT_STATUS_ALL_ERRORS & status) != 0; |
| 34 } | 35 } |
| 35 | 36 |
| 36 // Maps a network error code to the equivalent certificate status flag. If | 37 // Maps a network error code to the equivalent certificate status flag. If |
| 37 // the error code is not a certificate error, it is mapped to 0. | 38 // the error code is not a certificate error, it is mapped to 0. |
| 38 int MapNetErrorToCertStatus(int error); | 39 int MapNetErrorToCertStatus(int error); |
| 39 | 40 |
| 40 // Maps the most serious certificate error in the certificate status flags | 41 // Maps the most serious certificate error in the certificate status flags |
| 41 // to the equivalent network error code. | 42 // to the equivalent network error code. |
| 42 int MapCertStatusToNetError(int cert_status); | 43 int MapCertStatusToNetError(int cert_status); |
| 43 | 44 |
| 44 } // namespace net | 45 } // namespace net |
| 45 | 46 |
| 46 #endif // NET_BASE_CERT_STATUS_FLAGS_H_ | 47 #endif // NET_BASE_CERT_STATUS_FLAGS_H_ |
| OLD | NEW |