Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(230)

Side by Side Diff: net/base/cert_status_flags.h

Issue 7819009: For the SSL cert status, convert anonymous enum that gives bit values into a typedefed uint32. Th... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #pragma once 7 #pragma once
8 8
9 #include "base/basictypes.h"
10
9 namespace net { 11 namespace net {
10 12
11 // Status flags, such as errors and extended validation. 13 // Status flags, such as errors and extended validation.
12 enum { 14 // NOTE: Because these names have appeared in bug reports, we preserve them as
13 // Bits 0 to 15 are for errors. 15 // MACRO_STYLE for continuity, instead of renaming them to kConstantStyle as
14 CERT_STATUS_ALL_ERRORS = 0xFFFF, 16 // befits most static consts.
15 CERT_STATUS_COMMON_NAME_INVALID = 1 << 0, 17 typedef uint32 CertStatus;
wtc 2011/09/21 23:54:25 The CertStatus type should be defined and document
Peter Kasting 2011/09/22 00:36:17 I don't understand what you're requesting that isn
wtc 2011/09/22 17:55:07 Yes. We need a comment to document that CertStatu
Peter Kasting 2011/09/22 18:25:50 Ah, thanks for the example. Added something.
16 CERT_STATUS_DATE_INVALID = 1 << 1, 18 static const CertStatus CERT_STATUS_NO_ERROR = 0;
wtc 2011/09/21 23:54:25 Please remove the NO_ERROR constant. It is obviou
Peter Kasting 2011/09/22 00:36:17 I looked up ERROR_IS_SET in code search and didn't
wtc 2011/09/22 17:55:07 Sorry I wasn't clear. What I meant is that if a p
Peter Kasting 2011/09/22 18:25:50 Ah. I think where I'm coming from is that it's no
17 CERT_STATUS_AUTHORITY_INVALID = 1 << 2,
18 // 1 << 3 is reserved for ERR_CERT_CONTAINS_ERRORS (not useful with WinHTTP).
19 CERT_STATUS_NO_REVOCATION_MECHANISM = 1 << 4,
20 CERT_STATUS_UNABLE_TO_CHECK_REVOCATION = 1 << 5,
21 CERT_STATUS_REVOKED = 1 << 6,
22 CERT_STATUS_INVALID = 1 << 7,
23 CERT_STATUS_WEAK_SIGNATURE_ALGORITHM = 1 << 8,
24 CERT_STATUS_NOT_IN_DNS = 1 << 9,
25 CERT_STATUS_NON_UNIQUE_NAME = 1 << 10,
26 19
27 // Bits 16 to 30 are for non-error statuses. 20 // Bits 0 to 15 are for errors.
28 CERT_STATUS_IS_EV = 1 << 16, 21 static const CertStatus CERT_STATUS_ALL_ERRORS = 0xFFFF;
29 CERT_STATUS_REV_CHECKING_ENABLED = 1 << 17, 22 static const CertStatus CERT_STATUS_COMMON_NAME_INVALID = 1 << 0;
30 CERT_STATUS_IS_DNSSEC = 1 << 18, 23 static const CertStatus CERT_STATUS_DATE_INVALID = 1 << 1;
24 static const CertStatus CERT_STATUS_AUTHORITY_INVALID = 1 << 2;
25 // 1 << 3 is reserved for ERR_CERT_CONTAINS_ERRORS (not useful with WinHTTP).
26 static const CertStatus CERT_STATUS_NO_REVOCATION_MECHANISM = 1 << 4;
27 static const CertStatus CERT_STATUS_UNABLE_TO_CHECK_REVOCATION = 1 << 5;
28 static const CertStatus CERT_STATUS_REVOKED = 1 << 6;
29 static const CertStatus CERT_STATUS_INVALID = 1 << 7;
30 static const CertStatus CERT_STATUS_WEAK_SIGNATURE_ALGORITHM = 1 << 8;
31 static const CertStatus CERT_STATUS_NOT_IN_DNS = 1 << 9;
32 static const CertStatus CERT_STATUS_NON_UNIQUE_NAME = 1 << 10;
31 33
32 // 1 << 31 (the sign bit) is reserved so that the cert status will never be 34 // Bits 16 to 31 are for non-error statuses.
33 // negative. 35 static const CertStatus CERT_STATUS_IS_EV = 1 << 16;
34 }; 36 static const CertStatus CERT_STATUS_REV_CHECKING_ENABLED = 1 << 17;
37 static const CertStatus CERT_STATUS_IS_DNSSEC = 1 << 18;
wtc 2011/09/21 23:54:25 Changing how these flags are defined has the downs
Peter Kasting 2011/09/22 00:36:17 This is true of any cleanup to anything in the cod
35 38
36 // Returns true if the specified cert status has an error set. 39 // Returns true if the specified cert status has an error set.
37 static inline bool IsCertStatusError(int status) { 40 static inline bool IsCertStatusError(CertStatus status) {
38 return (CERT_STATUS_ALL_ERRORS & status) != 0; 41 return (CERT_STATUS_ALL_ERRORS & status) != 0;
39 } 42 }
40 43
41 // Maps a network error code to the equivalent certificate status flag. If 44 // Maps a network error code to the equivalent certificate status flag. If
42 // the error code is not a certificate error, it is mapped to 0. 45 // the error code is not a certificate error, it is mapped to 0.
43 int MapNetErrorToCertStatus(int error); 46 CertStatus MapNetErrorToCertStatus(int error);
44 47
45 // Maps the most serious certificate error in the certificate status flags 48 // Maps the most serious certificate error in the certificate status flags
46 // to the equivalent network error code. 49 // to the equivalent network error code.
47 int MapCertStatusToNetError(int cert_status); 50 int MapCertStatusToNetError(CertStatus cert_status);
48 51
49 } // namespace net 52 } // namespace net
50 53
51 #endif // NET_BASE_CERT_STATUS_FLAGS_H_ 54 #endif // NET_BASE_CERT_STATUS_FLAGS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698