OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_SSL_FALSE_START_BLACKLIST_H_ | 5 #ifndef NET_BASE_SSL_FALSE_START_BLACKLIST_H_ |
6 #define NET_BASE_SSL_FALSE_START_BLACKLIST_H_ | 6 #define NET_BASE_SSL_FALSE_START_BLACKLIST_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "net/base/net_api.h" | 9 #include "net/base/net_api.h" |
10 | 10 |
11 namespace net { | 11 namespace net { |
12 | 12 |
13 // SSLFalseStartBlacklist is a set of domains which we believe to be intolerant | 13 // SSLFalseStartBlacklist is a set of domains which we believe to be intolerant |
14 // to TLS False Start. Because this set is several hundred long, it's | 14 // to TLS False Start. Because this set is several hundred long, it's |
15 // precompiled by the code in ssl_false_start_blacklist_process.cc into a hash | 15 // precompiled by the code in ssl_false_start_blacklist_process.cc into a hash |
16 // table for fast lookups. | 16 // table for fast lookups. |
17 class SSLFalseStartBlacklist { | 17 class NET_TEST SSLFalseStartBlacklist { |
18 public: | 18 public: |
19 // IsMember returns true if the given host is in the blacklist. | 19 // IsMember returns true if the given host is in the blacklist. |
20 // host: a DNS name in dotted form (i.e. "www.example.com") | 20 // host: a DNS name in dotted form (i.e. "www.example.com") |
21 NET_TEST static bool IsMember(const char* host); | 21 static bool IsMember(const char* host); |
22 | 22 |
23 // Hash returns the modified djb2 hash of the given string. | 23 // Hash returns the modified djb2 hash of the given string. |
24 static unsigned Hash(const char* str) { | 24 static unsigned Hash(const char* str) { |
25 // This is inline because the code which generates the hash table needs to | 25 // This is inline because the code which generates the hash table needs to |
26 // use it. However, the generating code cannot link against | 26 // use it. However, the generating code cannot link against |
27 // ssl_false_start_blacklist.cc because that needs the tables which it | 27 // ssl_false_start_blacklist.cc because that needs the tables which it |
28 // generates. | 28 // generates. |
29 const unsigned char* in = reinterpret_cast<const unsigned char*>(str); | 29 const unsigned char* in = reinterpret_cast<const unsigned char*>(str); |
30 unsigned hash = 5381; | 30 unsigned hash = 5381; |
31 unsigned char c; | 31 unsigned char c; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 // assign a string to a hash bucket, the last two labels (not including the | 90 // assign a string to a hash bucket, the last two labels (not including the |
91 // root label) are hashed. Thus, the bucket for "www.example.com" is | 91 // root label) are hashed. Thus, the bucket for "www.example.com" is |
92 // Hash("example.com"). No names that are less than two labels long are | 92 // Hash("example.com"). No names that are less than two labels long are |
93 // included in the blacklist. | 93 // included in the blacklist. |
94 static const char kHashData[]; | 94 static const char kHashData[]; |
95 }; | 95 }; |
96 | 96 |
97 } // namespace net | 97 } // namespace net |
98 | 98 |
99 #endif // NET_BASE_SSL_FALSE_START_BLACKLIST_H_ | 99 #endif // NET_BASE_SSL_FALSE_START_BLACKLIST_H_ |
OLD | NEW |