• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "net/base/ssl_false_start_blacklist.h"
6 
7 namespace net {
8 
9 // static
IsMember(const char * host)10 bool SSLFalseStartBlacklist::IsMember(const char* host) {
11   const char* last_two_labels = LastTwoLabels(host);
12   if (!last_two_labels)
13     return false;
14   const unsigned bucket = Hash(last_two_labels) & (kBuckets - 1);
15   const uint32 start = kHashTable[bucket];
16   const uint32 end = kHashTable[bucket + 1];
17   const size_t len = strlen(host);
18 
19   for (size_t i = start; i < end;) {
20     const size_t blacklist_entry_len = static_cast<uint8>(kHashData[i]);
21     if (len >= blacklist_entry_len &&
22         memcmp(&host[len - blacklist_entry_len], &kHashData[i + 1],
23                blacklist_entry_len) == 0 &&
24         (len == blacklist_entry_len ||
25          host[len - blacklist_entry_len - 1] == '.')) {
26       return true;
27     }
28     i += blacklist_entry_len + 1;
29   }
30 
31   return false;
32 }
33 
34 }  // namespace net
35