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

Side by Side Diff: net/ssl/ssl_connection_status_flags.h

Issue 291093002: Fail the SPDY transaction if it does not meet TLS base requirements. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address forgotten comment. Created 6 years, 7 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) 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_SSL_SSL_CONNECTION_STATUS_FLAGS_H_ 5 #ifndef NET_SSL_SSL_CONNECTION_STATUS_FLAGS_H_
6 #define NET_SSL_SSL_CONNECTION_STATUS_FLAGS_H_ 6 #define NET_SSL_SSL_CONNECTION_STATUS_FLAGS_H_
7 7
8 #include "base/logging.h"
9 #include "base/macros.h"
10
8 namespace net { 11 namespace net {
9 12
10 // Status flags for SSLInfo::connection_status. 13 // Status flags for SSLInfo::connection_status.
11 enum { 14 enum {
12 // The lower 16 bits are reserved for the TLS ciphersuite id. 15 // The lower 16 bits are reserved for the TLS ciphersuite id.
13 SSL_CONNECTION_CIPHERSUITE_SHIFT = 0, 16 SSL_CONNECTION_CIPHERSUITE_SHIFT = 0,
14 SSL_CONNECTION_CIPHERSUITE_MASK = 0xffff, 17 SSL_CONNECTION_CIPHERSUITE_MASK = 0xffff,
15 18
16 // The next two bits are reserved for the compression used. 19 // The next two bits are reserved for the compression used.
17 SSL_CONNECTION_COMPRESSION_SHIFT = 16, 20 SSL_CONNECTION_COMPRESSION_SHIFT = 16,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 inline int SSLConnectionStatusToCipherSuite(int connection_status) { 56 inline int SSLConnectionStatusToCipherSuite(int connection_status) {
54 return (connection_status >> SSL_CONNECTION_CIPHERSUITE_SHIFT) & 57 return (connection_status >> SSL_CONNECTION_CIPHERSUITE_SHIFT) &
55 SSL_CONNECTION_CIPHERSUITE_MASK; 58 SSL_CONNECTION_CIPHERSUITE_MASK;
56 } 59 }
57 60
58 inline int SSLConnectionStatusToVersion(int connection_status) { 61 inline int SSLConnectionStatusToVersion(int connection_status) {
59 return (connection_status >> SSL_CONNECTION_VERSION_SHIFT) & 62 return (connection_status >> SSL_CONNECTION_VERSION_SHIFT) &
60 SSL_CONNECTION_VERSION_MASK; 63 SSL_CONNECTION_VERSION_MASK;
61 } 64 }
62 65
66 inline void SSLConnectionStatusSetCipherSuite(int cipher_suite,
67 int* connection_status) {
68 // Clear out the old ciphersuite.
69 *connection_status &=
70 ~(SSL_CONNECTION_CIPHERSUITE_MASK << SSL_CONNECTION_CIPHERSUITE_SHIFT);
71 // Set the new ciphersuite.
72 *connection_status |= ((cipher_suite & SSL_CONNECTION_CIPHERSUITE_MASK)
73 << SSL_CONNECTION_CIPHERSUITE_SHIFT);
74 }
75
76 inline void SSLConnectionStatusSetVersion(int version, int* connection_status) {
77 DCHECK_GT(version, 0);
78 DCHECK_LT(version, SSL_CONNECTION_VERSION_MAX);
79
80 // Clear out the old version.
81 *connection_status &=
82 ~(SSL_CONNECTION_VERSION_MASK << SSL_CONNECTION_VERSION_SHIFT);
83 // Set the new version.
84 *connection_status |=
85 ((version & SSL_CONNECTION_VERSION_MASK) << SSL_CONNECTION_VERSION_SHIFT);
86 }
87
63 } // namespace net 88 } // namespace net
64 89
65 #endif // NET_SSL_SSL_CONNECTION_STATUS_FLAGS_H_ 90 #endif // NET_SSL_SSL_CONNECTION_STATUS_FLAGS_H_
OLDNEW
« no previous file with comments | « net/ssl/ssl_cipher_suite_names_unittest.cc ('k') | net/ssl/ssl_connection_status_flags_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698