x509_certificate.cc revision 94ea77830f08742eaf1760a8ccc858530cb1c36e
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
3// found in the LICENSE file.
4
5#include "net/base/x509_certificate.h"
6
7#include <stdlib.h>
8
9#include <map>
10#include <string>
11#include <vector>
12
13#include "base/lazy_instance.h"
14#include "base/logging.h"
15#include "base/memory/singleton.h"
16#include "base/metrics/histogram.h"
17#include "base/pickle.h"
18#include "base/sha1.h"
19#include "base/string_piece.h"
20#include "base/string_util.h"
21#include "base/time.h"
22#include "net/base/pem_tokenizer.h"
23
24namespace net {
25
26namespace {
27
28// Returns true if this cert fingerprint is the null (all zero) fingerprint.
29// We use this as a bogus fingerprint value.
30bool IsNullFingerprint(const SHA1Fingerprint& fingerprint) {
31  for (size_t i = 0; i < arraysize(fingerprint.data); ++i) {
32    if (fingerprint.data[i] != 0)
33      return false;
34  }
35  return true;
36}
37
38// Indicates the order to use when trying to decode binary data, which is
39// based on (speculation) as to what will be most common -> least common
40const X509Certificate::Format kFormatDecodePriority[] = {
41  X509Certificate::FORMAT_SINGLE_CERTIFICATE,
42  X509Certificate::FORMAT_PKCS7
43};
44
45// The PEM block header used for DER certificates
46const char kCertificateHeader[] = "CERTIFICATE";
47// The PEM block header used for PKCS#7 data
48const char kPKCS7Header[] = "PKCS7";
49
50// A thread-safe cache for X509Certificate objects.
51//
52// The cache does not hold a reference to the certificate objects.  The objects
53// must |Remove| themselves from the cache upon destruction (or else the cache
54// will be holding dead pointers to the objects).
55// TODO(rsleevi): There exists a chance of a use-after-free, due to a race
56// between Find() and Remove(). See http://crbug.com/49377
57class X509CertificateCache {
58 public:
59  void Insert(X509Certificate* cert);
60  void Remove(X509Certificate* cert);
61  X509Certificate* Find(const SHA1Fingerprint& fingerprint);
62
63 private:
64  typedef std::map<SHA1Fingerprint, X509Certificate*, SHA1FingerprintLessThan>
65      CertMap;
66
67  // Obtain an instance of X509CertificateCache via a LazyInstance.
68  X509CertificateCache() {}
69  ~X509CertificateCache() {}
70  friend struct base::DefaultLazyInstanceTraits<X509CertificateCache>;
71
72  // You must acquire this lock before using any private data of this object.
73  // You must not block while holding this lock.
74  base::Lock lock_;
75
76  // The certificate cache.  You must acquire |lock_| before using |cache_|.
77  CertMap cache_;
78
79  DISALLOW_COPY_AND_ASSIGN(X509CertificateCache);
80};
81
82base::LazyInstance<X509CertificateCache,
83                   base::LeakyLazyInstanceTraits<X509CertificateCache> >
84    g_x509_certificate_cache(base::LINKER_INITIALIZED);
85
86// Insert |cert| into the cache.  The cache does NOT AddRef |cert|.
87// Any existing certificate with the same fingerprint will be replaced.
88void X509CertificateCache::Insert(X509Certificate* cert) {
89  base::AutoLock lock(lock_);
90
91  DCHECK(!IsNullFingerprint(cert->fingerprint())) <<
92      "Only insert certs with real fingerprints.";
93  cache_[cert->fingerprint()] = cert;
94};
95
96// Remove |cert| from the cache.  The cache does not assume that |cert| is
97// already in the cache.
98void X509CertificateCache::Remove(X509Certificate* cert) {
99  base::AutoLock lock(lock_);
100
101  CertMap::iterator pos(cache_.find(cert->fingerprint()));
102  if (pos == cache_.end())
103    return;  // It is not an error to remove a cert that is not in the cache.
104  cache_.erase(pos);
105};
106
107// Find a certificate in the cache with the given fingerprint.  If one does
108// not exist, this method returns NULL.
109X509Certificate* X509CertificateCache::Find(
110    const SHA1Fingerprint& fingerprint) {
111  base::AutoLock lock(lock_);
112
113  CertMap::iterator pos(cache_.find(fingerprint));
114  if (pos == cache_.end())
115    return NULL;
116
117  return pos->second;
118};
119
120// CompareSHA1Hashes is a helper function for using bsearch() with an array of
121// SHA1 hashes.
122static int CompareSHA1Hashes(const void* a, const void* b) {
123  return memcmp(a, b, base::SHA1_LENGTH);
124}
125
126}  // namespace
127
128bool X509Certificate::LessThan::operator()(X509Certificate* lhs,
129                                           X509Certificate* rhs) const {
130  if (lhs == rhs)
131    return false;
132
133  SHA1FingerprintLessThan fingerprint_functor;
134  return fingerprint_functor(lhs->fingerprint_, rhs->fingerprint_);
135}
136
137X509Certificate::X509Certificate(const std::string& subject,
138                                 const std::string& issuer,
139                                 base::Time start_date,
140                                 base::Time expiration_date)
141    : subject_(subject),
142      issuer_(issuer),
143      valid_start_(start_date),
144      valid_expiry_(expiration_date),
145      cert_handle_(NULL),
146      source_(SOURCE_UNUSED) {
147  memset(fingerprint_.data, 0, sizeof(fingerprint_.data));
148}
149
150// static
151X509Certificate* X509Certificate::CreateFromHandle(
152    OSCertHandle cert_handle,
153    Source source,
154    const OSCertHandles& intermediates) {
155  DCHECK(cert_handle);
156  DCHECK(source != SOURCE_UNUSED);
157
158  // Check if we already have this certificate in memory.
159  X509CertificateCache* cache = g_x509_certificate_cache.Pointer();
160  X509Certificate* cached_cert =
161      cache->Find(CalculateFingerprint(cert_handle));
162  if (cached_cert) {
163    DCHECK(cached_cert->source_ != SOURCE_UNUSED);
164    if (cached_cert->source_ > source ||
165        (cached_cert->source_ == source &&
166         cached_cert->HasIntermediateCertificates(intermediates))) {
167      // Return the certificate with the same fingerprint from our cache.
168      DHISTOGRAM_COUNTS("X509CertificateReuseCount", 1);
169      return cached_cert;
170    }
171    // Else the new cert is better and will replace the old one in the cache.
172  }
173
174  // Otherwise, allocate and cache a new object.
175  X509Certificate* cert = new X509Certificate(cert_handle, source,
176                                              intermediates);
177  cache->Insert(cert);
178  return cert;
179}
180
181#if defined(OS_WIN)
182static X509Certificate::OSCertHandle CreateOSCert(base::StringPiece der_cert) {
183  X509Certificate::OSCertHandle cert_handle = NULL;
184  BOOL ok = CertAddEncodedCertificateToStore(
185      X509Certificate::cert_store(), X509_ASN_ENCODING | PKCS_7_ASN_ENCODING,
186      reinterpret_cast<const BYTE*>(der_cert.data()), der_cert.size(),
187      CERT_STORE_ADD_USE_EXISTING, &cert_handle);
188  return ok ? cert_handle : NULL;
189}
190#else
191static X509Certificate::OSCertHandle CreateOSCert(base::StringPiece der_cert) {
192  return X509Certificate::CreateOSCertHandleFromBytes(
193      const_cast<char*>(der_cert.data()), der_cert.size());
194}
195#endif
196
197// static
198X509Certificate* X509Certificate::CreateFromDERCertChain(
199    const std::vector<base::StringPiece>& der_certs) {
200  if (der_certs.empty())
201    return NULL;
202
203  X509Certificate::OSCertHandles intermediate_ca_certs;
204  for (size_t i = 1; i < der_certs.size(); i++) {
205    OSCertHandle handle = CreateOSCert(der_certs[i]);
206    DCHECK(handle);
207    intermediate_ca_certs.push_back(handle);
208  }
209
210  OSCertHandle handle = CreateOSCert(der_certs[0]);
211  DCHECK(handle);
212  X509Certificate* cert =
213      CreateFromHandle(handle, SOURCE_FROM_NETWORK, intermediate_ca_certs);
214  FreeOSCertHandle(handle);
215  for (size_t i = 0; i < intermediate_ca_certs.size(); i++)
216    FreeOSCertHandle(intermediate_ca_certs[i]);
217
218  return cert;
219}
220
221// static
222X509Certificate* X509Certificate::CreateFromBytes(const char* data,
223                                                  int length) {
224  OSCertHandle cert_handle = CreateOSCertHandleFromBytes(data, length);
225  if (!cert_handle)
226    return NULL;
227
228  X509Certificate* cert = CreateFromHandle(cert_handle,
229                                           SOURCE_LONE_CERT_IMPORT,
230                                           OSCertHandles());
231  FreeOSCertHandle(cert_handle);
232  return cert;
233}
234
235// static
236X509Certificate* X509Certificate::CreateFromPickle(const Pickle& pickle,
237                                                   void** pickle_iter,
238                                                   PickleType type) {
239  OSCertHandle cert_handle = ReadCertHandleFromPickle(pickle, pickle_iter);
240  OSCertHandles intermediates;
241
242  // Even if a certificate fails to parse, whether the server certificate in
243  // |cert_handle| or one of the optional intermediates, continue reading
244  // the data from |pickle| so that |pickle_iter| is kept in sync for any
245  // other reads the caller may perform after this method returns.
246  if (type == PICKLETYPE_CERTIFICATE_CHAIN) {
247    size_t num_intermediates;
248    if (!pickle.ReadSize(pickle_iter, &num_intermediates)) {
249      FreeOSCertHandle(cert_handle);
250      return NULL;
251    }
252
253    bool ok = !!cert_handle;
254    for (size_t i = 0; i < num_intermediates; ++i) {
255      OSCertHandle intermediate = ReadCertHandleFromPickle(pickle,
256                                                           pickle_iter);
257      // If an intermediate fails to load, it and any certificates after it
258      // will not be added. However, any intermediates that were successfully
259      // parsed before the failure can be safely returned.
260      ok &= !!intermediate;
261      if (ok) {
262        intermediates.push_back(intermediate);
263      } else if (intermediate) {
264        FreeOSCertHandle(intermediate);
265      }
266    }
267  }
268
269  if (!cert_handle)
270    return NULL;
271  X509Certificate* cert = CreateFromHandle(cert_handle, SOURCE_FROM_CACHE,
272                                           intermediates);
273  FreeOSCertHandle(cert_handle);
274  for (size_t i = 0; i < intermediates.size(); ++i)
275    FreeOSCertHandle(intermediates[i]);
276
277  return cert;
278}
279
280// static
281CertificateList X509Certificate::CreateCertificateListFromBytes(
282    const char* data, int length, int format) {
283  OSCertHandles certificates;
284
285  // Check to see if it is in a PEM-encoded form. This check is performed
286  // first, as both OS X and NSS will both try to convert if they detect
287  // PEM encoding, except they don't do it consistently between the two.
288  base::StringPiece data_string(data, length);
289  std::vector<std::string> pem_headers;
290
291  // To maintain compatibility with NSS/Firefox, CERTIFICATE is a universally
292  // valid PEM block header for any format.
293  pem_headers.push_back(kCertificateHeader);
294  if (format & FORMAT_PKCS7)
295    pem_headers.push_back(kPKCS7Header);
296
297  PEMTokenizer pem_tok(data_string, pem_headers);
298  while (pem_tok.GetNext()) {
299    std::string decoded(pem_tok.data());
300
301    OSCertHandle handle = NULL;
302    if (format & FORMAT_PEM_CERT_SEQUENCE)
303      handle = CreateOSCertHandleFromBytes(decoded.c_str(), decoded.size());
304    if (handle != NULL) {
305      // Parsed a DER encoded certificate. All PEM blocks that follow must
306      // also be DER encoded certificates wrapped inside of PEM blocks.
307      format = FORMAT_PEM_CERT_SEQUENCE;
308      certificates.push_back(handle);
309      continue;
310    }
311
312    // If the first block failed to parse as a DER certificate, and
313    // formats other than PEM are acceptable, check to see if the decoded
314    // data is one of the accepted formats.
315    if (format & ~FORMAT_PEM_CERT_SEQUENCE) {
316      for (size_t i = 0; certificates.empty() &&
317           i < arraysize(kFormatDecodePriority); ++i) {
318        if (format & kFormatDecodePriority[i]) {
319          certificates = CreateOSCertHandlesFromBytes(decoded.c_str(),
320              decoded.size(), kFormatDecodePriority[i]);
321        }
322      }
323    }
324
325    // Stop parsing after the first block for any format but a sequence of
326    // PEM-encoded DER certificates. The case of FORMAT_PEM_CERT_SEQUENCE
327    // is handled above, and continues processing until a certificate fails
328    // to parse.
329    break;
330  }
331
332  // Try each of the formats, in order of parse preference, to see if |data|
333  // contains the binary representation of a Format, if it failed to parse
334  // as a PEM certificate/chain.
335  for (size_t i = 0; certificates.empty() &&
336       i < arraysize(kFormatDecodePriority); ++i) {
337    if (format & kFormatDecodePriority[i])
338      certificates = CreateOSCertHandlesFromBytes(data, length,
339                                                  kFormatDecodePriority[i]);
340  }
341
342  CertificateList results;
343  // No certificates parsed.
344  if (certificates.empty())
345    return results;
346
347  for (OSCertHandles::iterator it = certificates.begin();
348       it != certificates.end(); ++it) {
349    X509Certificate* result = CreateFromHandle(*it, SOURCE_LONE_CERT_IMPORT,
350                                               OSCertHandles());
351    results.push_back(scoped_refptr<X509Certificate>(result));
352    FreeOSCertHandle(*it);
353  }
354
355  return results;
356}
357
358void X509Certificate::Persist(Pickle* pickle) {
359  DCHECK(cert_handle_);
360  if (!WriteCertHandleToPickle(cert_handle_, pickle)) {
361    NOTREACHED();
362    return;
363  }
364
365  if (!pickle->WriteSize(intermediate_ca_certs_.size())) {
366    NOTREACHED();
367    return;
368  }
369
370  for (size_t i = 0; i < intermediate_ca_certs_.size(); ++i) {
371    if (!WriteCertHandleToPickle(intermediate_ca_certs_[i], pickle)) {
372      NOTREACHED();
373      return;
374    }
375  }
376}
377
378bool X509Certificate::HasExpired() const {
379  return base::Time::Now() > valid_expiry();
380}
381
382bool X509Certificate::Equals(const X509Certificate* other) const {
383  return IsSameOSCert(cert_handle_, other->cert_handle_);
384}
385
386bool X509Certificate::HasIntermediateCertificate(OSCertHandle cert) {
387  for (size_t i = 0; i < intermediate_ca_certs_.size(); ++i) {
388    if (IsSameOSCert(cert, intermediate_ca_certs_[i]))
389      return true;
390  }
391  return false;
392}
393
394bool X509Certificate::HasIntermediateCertificates(const OSCertHandles& certs) {
395  for (size_t i = 0; i < certs.size(); ++i) {
396    if (!HasIntermediateCertificate(certs[i]))
397      return false;
398  }
399  return true;
400}
401
402// static
403bool X509Certificate::VerifyHostname(
404    const std::string& hostname,
405    const std::vector<std::string>& cert_names) {
406  DCHECK(!hostname.empty());
407
408  // Simple host name validation. A valid domain name must only contain
409  // alpha, digits, hyphens, and dots. An IP address may have digits and dots,
410  // and also square braces and colons for IPv6 addresses.
411  std::string reference_name;
412  reference_name.reserve(hostname.length());
413
414  bool found_alpha = false;
415  bool found_ip6_chars = false;
416  bool found_hyphen = false;
417  int dot_count = 0;
418
419  size_t first_dot_index = std::string::npos;
420  for (std::string::const_iterator it = hostname.begin();
421       it != hostname.end(); ++it) {
422    char c = *it;
423    if (IsAsciiAlpha(c)) {
424      found_alpha = true;
425      c = base::ToLowerASCII(c);
426    } else if (c == '.') {
427      ++dot_count;
428      if (first_dot_index == std::string::npos)
429        first_dot_index = reference_name.length();
430    } else if (c == ':') {
431      found_ip6_chars = true;
432    } else if (c == '-') {
433      found_hyphen = true;
434    } else if (!IsAsciiDigit(c)) {
435      LOG(WARNING) << "Invalid char " << c << " in hostname " << hostname;
436      return false;
437    }
438    reference_name.push_back(c);
439  }
440  DCHECK(!reference_name.empty());
441
442  if (found_ip6_chars || !found_alpha) {
443    // For now we just do simple localhost IP address support, primarily as
444    // it's needed by the test server. TODO(joth): Replace this with full IP
445    // address support. See http://crbug.com/62973
446    if (hostname == "127.0.0.1") {
447      for (size_t index = 0; index < cert_names.size(); ++index) {
448        if (cert_names[index] == hostname) {
449          DVLOG(1) << "Allowing localhost IP certificate: " << hostname;
450          return true;
451        }
452      }
453    }
454    NOTIMPLEMENTED() << hostname;  // See comment above.
455    return false;
456  }
457
458  // |wildcard_domain| is the remainder of |host| after the leading host
459  // component is stripped off, but includes the leading dot e.g.
460  // "www.f.com" -> ".f.com".
461  // If there is no meaningful domain part to |host| (e.g. it is an IP address
462  // or contains no dots) then |wildcard_domain| will be empty.
463  // We required at least 3 components (i.e. 2 dots) as a basic protection
464  // against too-broad wild-carding.
465  base::StringPiece wildcard_domain;
466  if (found_alpha && !found_ip6_chars && dot_count >= 2) {
467    DCHECK(first_dot_index != std::string::npos);
468    wildcard_domain = reference_name;
469    wildcard_domain.remove_prefix(first_dot_index);
470    DCHECK(wildcard_domain.starts_with("."));
471  }
472
473  for (std::vector<std::string>::const_iterator it = cert_names.begin();
474       it != cert_names.end(); ++it) {
475    // Catch badly corrupt cert names up front.
476    if (it->empty() || it->find('\0') != std::string::npos) {
477      LOG(WARNING) << "Bad name in cert: " << *it;
478      continue;
479    }
480    const std::string cert_name_string(StringToLowerASCII(*it));
481    base::StringPiece cert_match(cert_name_string);
482
483    // Remove trailing dot, if any.
484    if (cert_match.ends_with("."))
485      cert_match.remove_suffix(1);
486
487    // The hostname must be at least as long as the cert name it is matching,
488    // as we require the wildcard (if present) to match at least one character.
489    if (cert_match.length() > reference_name.length())
490      continue;
491
492    if (cert_match == reference_name)
493      return true;
494
495    // Next see if this cert name starts with a wildcard, so long as the
496    // hostname we're matching against has a valid 'domain' part to match.
497    // Note the "-10" version of draft-saintandre-tls-server-id-check allows
498    // the wildcard to appear anywhere in the leftmost label, rather than
499    // requiring it to be the only character. See also http://crbug.com/60719
500    if (wildcard_domain.empty() || !cert_match.starts_with("*"))
501      continue;
502
503    // Erase the * but not the . from the domain, as we need to include the dot
504    // in the comparison.
505    cert_match.remove_prefix(1);
506
507    // Do character by character comparison on the remainder to see
508    // if we have a wildcard match. This intentionally does no special handling
509    // for any other wildcard characters in |domain|; alternatively it could
510    // detect these and skip those candidate cert names.
511    if (cert_match == wildcard_domain)
512      return true;
513  }
514  DVLOG(1) << "Could not find any match for " << hostname
515           << " (canonicalized as " << reference_name
516           << ") in cert names " << JoinString(cert_names, '|');
517  return false;
518}
519
520#if !defined(USE_NSS)
521bool X509Certificate::VerifyNameMatch(const std::string& hostname) const {
522  std::vector<std::string> dns_names;
523  GetDNSNames(&dns_names);
524  return VerifyHostname(hostname, dns_names);
525}
526#endif
527
528X509Certificate::X509Certificate(OSCertHandle cert_handle,
529                                 Source source,
530                                 const OSCertHandles& intermediates)
531    : cert_handle_(DupOSCertHandle(cert_handle)),
532      source_(source) {
533  // Copy/retain the intermediate cert handles.
534  for (size_t i = 0; i < intermediates.size(); ++i)
535    intermediate_ca_certs_.push_back(DupOSCertHandle(intermediates[i]));
536  // Platform-specific initialization.
537  Initialize();
538}
539
540X509Certificate::~X509Certificate() {
541  // We might not be in the cache, but it is safe to remove ourselves anyway.
542  g_x509_certificate_cache.Get().Remove(this);
543  if (cert_handle_)
544    FreeOSCertHandle(cert_handle_);
545  for (size_t i = 0; i < intermediate_ca_certs_.size(); ++i)
546    FreeOSCertHandle(intermediate_ca_certs_[i]);
547}
548
549bool X509Certificate::IsBlacklisted() const {
550  static const unsigned kNumSerials = 256;
551  static const unsigned kSerialBytes = 16;
552  static const uint8 kSerials[kNumSerials][kSerialBytes] = {
553    // Not a real certificate. For testing only.
554    {0x07,0x7a,0x59,0xbc,0xd5,0x34,0x59,0x60,0x1c,0xa6,0x90,0x72,0x67,0xa6,0xdd,0x1c},
555
556    // The next nine certificates all expire on Fri Mar 14 23:59:59 2014.
557    // Some serial numbers actually have a leading 0x00 byte required to
558    // encode a positive integer in DER if the most significant bit is 0.
559    // We omit the leading 0x00 bytes to make all serial numbers 16 bytes.
560
561    // Subject: CN=mail.google.com
562    // subjectAltName dNSName: mail.google.com, www.mail.google.com
563    {0x04,0x7e,0xcb,0xe9,0xfc,0xa5,0x5f,0x7b,0xd0,0x9e,0xae,0x36,0xe1,0x0c,0xae,0x1e},
564    // Subject: CN=global trustee
565    // subjectAltName dNSName: global trustee
566    // Note: not a CA certificate.
567    {0xd8,0xf3,0x5f,0x4e,0xb7,0x87,0x2b,0x2d,0xab,0x06,0x92,0xe3,0x15,0x38,0x2f,0xb0},
568    // Subject: CN=login.live.com
569    // subjectAltName dNSName: login.live.com, www.login.live.com
570    {0xb0,0xb7,0x13,0x3e,0xd0,0x96,0xf9,0xb5,0x6f,0xae,0x91,0xc8,0x74,0xbd,0x3a,0xc0},
571    // Subject: CN=addons.mozilla.org
572    // subjectAltName dNSName: addons.mozilla.org, www.addons.mozilla.org
573    {0x92,0x39,0xd5,0x34,0x8f,0x40,0xd1,0x69,0x5a,0x74,0x54,0x70,0xe1,0xf2,0x3f,0x43},
574    // Subject: CN=login.skype.com
575    // subjectAltName dNSName: login.skype.com, www.login.skype.com
576    {0xe9,0x02,0x8b,0x95,0x78,0xe4,0x15,0xdc,0x1a,0x71,0x0a,0x2b,0x88,0x15,0x44,0x47},
577    // Subject: CN=login.yahoo.com
578    // subjectAltName dNSName: login.yahoo.com, www.login.yahoo.com
579    {0xd7,0x55,0x8f,0xda,0xf5,0xf1,0x10,0x5b,0xb2,0x13,0x28,0x2b,0x70,0x77,0x29,0xa3},
580    // Subject: CN=www.google.com
581    // subjectAltName dNSName: www.google.com, google.com
582    {0xf5,0xc8,0x6a,0xf3,0x61,0x62,0xf1,0x3a,0x64,0xf5,0x4f,0x6d,0xc9,0x58,0x7c,0x06},
583    // Subject: CN=login.yahoo.com
584    // subjectAltName dNSName: login.yahoo.com
585    {0x39,0x2a,0x43,0x4f,0x0e,0x07,0xdf,0x1f,0x8a,0xa3,0x05,0xde,0x34,0xe0,0xc2,0x29},
586    // Subject: CN=login.yahoo.com
587    // subjectAltName dNSName: login.yahoo.com
588    {0x3e,0x75,0xce,0xd4,0x6b,0x69,0x30,0x21,0x21,0x88,0x30,0xae,0x86,0xa8,0x2a,0x71},
589
590    // Bad DigiNotar leaf certificates for non-Google sites.
591    {0x95,0x32,0x18,0xb7,0x04,0xcc,0x62,0xb2,0x40,0xa4,0xd0,0x18,0x0e,0x81,0x93,0xf2},
592    {0x5f,0x41,0xfe,0x52,0x93,0x75,0xb1,0x4b,0xd1,0x56,0x37,0x53,0xa2,0xc9,0xc6,0x49},
593    {0x22,0xec,0x36,0x83,0x9f,0x44,0x65,0xe7,0xa1,0x34,0x7b,0xae,0x69,0x2f,0x5d,0x2a},
594    {0x46,0xaf,0xa2,0x75,0x58,0x2e,0x27,0x34,0xe2,0xa5,0x22,0xfc,0x6c,0x2e,0x80,0x55},
595    {0xc8,0x63,0x14,0x89,0xc3,0xa6,0xaf,0xde,0xdc,0x70,0xd6,0xc1,0xb5,0x81,0xc0,0x19},
596    {0x26,0xf6,0x2a,0xee,0x2b,0xae,0x06,0xee,0x71,0xe7,0xc4,0x8a,0x2b,0x4d,0x60,0xfe},
597    {0xb6,0x73,0x9c,0x1a,0xdd,0x2b,0x52,0x19,0x6c,0x53,0x36,0xef,0xb6,0x7b,0x26,0x0f},
598    {0x9e,0x4e,0x87,0x07,0x55,0xd9,0x4c,0xf5,0xc4,0x67,0x81,0xe6,0x83,0x49,0xe3,0xd3},
599    {0x7e,0x82,0x25,0xf6,0xb4,0xbe,0x3d,0x1c,0x13,0x72,0xbb,0xc3,0x65,0xf5,0xf6,0xb6},
600    {0xff,0x2e,0x1b,0xda,0xa2,0xf4,0xc9,0x51,0x02,0x65,0xf7,0x26,0x11,0xdd,0x0c,0x44},
601    {0x1f,0xe8,0x4c,0xbe,0x99,0xe5,0xd2,0x68,0x4c,0x67,0x8d,0xef,0x7f,0xc0,0xbd,0xaa},
602    {0x4b,0x72,0xe8,0x49,0x97,0x38,0x82,0x99,0xf5,0x83,0xcb,0x37,0x60,0xab,0x1b,0x20},
603    {0xcf,0x61,0x90,0x78,0xde,0x6c,0x9d,0x9a,0x50,0x72,0xb5,0xe3,0xb1,0x3c,0xa9,0x9f},
604    {0xa8,0x22,0xeb,0x37,0xb7,0x35,0xa6,0x3e,0x6c,0xa9,0xa9,0x96,0x80,0x08,0x21,0xfc},
605    {0xe3,0xb6,0x00,0xb1,0x07,0x39,0xb0,0x94,0xab,0x47,0x4c,0x88,0x8d,0x97,0x25,0x0d},
606    {0x36,0xe8,0x57,0x1d,0x39,0x46,0x34,0x2c,0x74,0x20,0x81,0xc0,0xfa,0xab,0x34,0x3a},
607    {0x77,0x17,0x07,0x87,0x3d,0xa4,0x91,0xa8,0xd5,0xcc,0x5b,0x07,0xdc,0x50,0x8c,0x72},
608    {0x1e,0x94,0xcf,0x79,0x06,0x58,0x7b,0xdf,0x45,0xc4,0x61,0xfb,0xdd,0x74,0x3e,0x25},
609    {0x58,0x7c,0xd9,0xe3,0xd9,0xa8,0xab,0x10,0xfd,0xb0,0xc7,0x0b,0xcd,0x8a,0xe7,0x28},
610    {0x7e,0xd8,0x0b,0x93,0x20,0x50,0x8d,0xa6,0xcf,0x5d,0x96,0xba,0x53,0x30,0x43,0xd7},
611    {0xf8,0x6d,0x1e,0x22,0xbd,0x20,0x68,0x47,0x1e,0x20,0x13,0x6b,0x30,0x21,0x0e,0xae},
612    {0x2c,0x86,0x94,0x86,0xec,0x04,0x75,0x97,0x82,0x91,0x6e,0x68,0x04,0xdb,0x48,0xfd},
613    {0x35,0x19,0x81,0x98,0xd1,0xbc,0xaf,0xcf,0x43,0x86,0xe6,0xb8,0x87,0xba,0xe6,0x1b},
614    {0x4a,0x66,0x2b,0xa9,0xe4,0x5d,0x06,0xff,0xc5,0x0d,0x1d,0xbb,0xe2,0x25,0xa8,0xbb},
615    {0x89,0x9a,0xe1,0x20,0xcd,0x44,0xfc,0xec,0x0f,0xfc,0xd6,0x2f,0x6f,0xc4,0xbb,0x81},
616    {0x7d,0xd1,0x6c,0x03,0xdf,0x04,0x38,0xb2,0xbe,0x5f,0xc1,0xd3,0xe1,0x9f,0x13,0x8b},
617    {0xaf,0xe2,0x66,0x30,0x8f,0x50,0x1d,0x49,0x37,0xc1,0xaa,0xf0,0x00,0xc5,0x68,0x97},
618    {0x53,0xd9,0xf7,0x50,0x84,0xf2,0x62,0xfb,0x40,0x91,0x27,0xab,0x1e,0x04,0x44,0x2e},
619    {0x35,0xec,0x66,0x4c,0xbd,0x19,0x42,0xa2,0x36,0xc3,0xba,0x0e,0xb2,0xc6,0x81,0x3f},
620    {0x5c,0x94,0xc8,0xbd,0x9d,0x50,0x4a,0xd8,0x8d,0x96,0x59,0x36,0xef,0x5f,0xa0,0x21},
621    {0x88,0x82,0xc0,0xa1,0xd6,0x4b,0xab,0xb7,0xdb,0x82,0x07,0x3e,0xcd,0x77,0x72,0x2f},
622    {0x81,0xc4,0x84,0x5a,0x97,0x2f,0x37,0x4d,0x1c,0xe5,0x83,0x08,0x44,0x54,0xdd,0x50},
623    {0x04,0x1d,0x36,0xbb,0x4d,0xd3,0x9e,0x4a,0xce,0x8c,0x5b,0x4e,0x72,0x27,0x79,0xa4},
624    {0xe6,0xc0,0xb6,0x11,0xb2,0x84,0x0a,0xac,0xc4,0x00,0xd0,0x3f,0xf2,0x7c,0x86,0xb7},
625    {0xb5,0x94,0xa1,0x02,0xf8,0x9a,0xe2,0x9a,0xf6,0x2d,0x68,0x96,0x5f,0x49,0x0d,0x65},
626    {0xa5,0xbe,0x65,0x4d,0xcc,0xf8,0xaa,0x3b,0xd3,0x15,0x64,0x8d,0x95,0x79,0x12,0x29},
627    {0x5b,0x1d,0xd6,0x43,0xb9,0x80,0xa8,0x17,0xf7,0x86,0x71,0x16,0x97,0xd2,0x84,0x0d},
628    {0x4c,0x06,0x16,0x26,0x9a,0x64,0xa3,0xe5,0x7b,0xe9,0xd0,0xeb,0x9d,0x1b,0x59,0x97},
629    {0x10,0x2c,0x47,0x9d,0x70,0x61,0xdb,0x7e,0xf1,0x55,0xba,0xa6,0x41,0x0b,0x11,0x20},
630    {0xd1,0x62,0x65,0x70,0x77,0x9a,0x69,0x32,0x66,0x28,0x2f,0x9f,0xdc,0x5a,0x72,0x3f},
631    {0x0f,0x50,0x0a,0xe6,0x0b,0xf8,0x69,0x67,0x16,0xf2,0x67,0xc8,0x0e,0x13,0xdc,0x09},
632    {0x8b,0x22,0xbf,0xf4,0x66,0xe4,0x15,0x26,0x65,0x8a,0x56,0x8d,0x40,0x00,0x70,0xfd},
633    {0x4e,0xf7,0x05,0xc3,0x1e,0xff,0xc8,0x5a,0x0f,0x6f,0x74,0x52,0x8c,0x84,0xa7,0x72},
634    {0x77,0x1d,0x89,0xbc,0xa1,0xd2,0x53,0xd1,0xb5,0x6a,0x61,0x41,0xcf,0x29,0xe1,0xbb},
635    {0x33,0x73,0x97,0x6f,0xb7,0xe8,0x21,0xdc,0x3d,0x68,0xf9,0x47,0xfa,0xed,0xb2,0xb0},
636    {0x30,0xc2,0x0f,0xff,0x9b,0xe7,0xc3,0xd5,0x82,0xc8,0x0b,0xc2,0xcb,0xeb,0x04,0x62},
637    {0xc5,0x2e,0xde,0x8f,0x68,0xb3,0x98,0x38,0x83,0x34,0x44,0x25,0x2c,0xb6,0x4f,0x73},
638    {0x94,0x53,0x95,0x11,0x88,0x67,0x56,0x53,0x13,0xa2,0x66,0x98,0xb9,0x5f,0x1e,0x3e},
639    {0xc3,0xac,0x62,0x96,0xff,0x90,0xf0,0x9b,0xf1,0x82,0xfb,0x81,0xf8,0x65,0x00,0xda},
640    {0x92,0x72,0xf9,0x8c,0xfe,0x35,0x00,0x00,0xd6,0xbc,0xaf,0x30,0x63,0x74,0x72,0x98},
641    {0x36,0x9a,0xaa,0x6a,0x97,0x3d,0x0f,0x76,0x32,0x1c,0x53,0x2d,0xed,0xb3,0xbf,0xc6},
642    {0x73,0x02,0x4e,0x7c,0x99,0x8b,0x3d,0xdd,0x24,0x4c,0xfd,0x31,0x3d,0x5e,0x43,0xb6},
643    {0xd7,0xfb,0x96,0xe0,0x29,0x1e,0xbe,0x3e,0x01,0x5e,0x93,0xe5,0x86,0xcf,0xc7,0xd1},
644    {0xb0,0x1d,0x8c,0x6f,0x2d,0x53,0x73,0xea,0xbf,0x0c,0x00,0x31,0x9e,0x92,0xae,0x95},
645    {0xd7,0x06,0x98,0xd2,0x7e,0x7c,0xfa,0xfd,0x81,0x8d,0xe7,0xe2,0xea,0x31,0x9f,0x7f},
646    {0x96,0x43,0x10,0xa7,0xec,0x83,0x47,0x6c,0xcd,0x99,0xd8,0x89,0x63,0x6a,0xc2,0xba},
647    {0x54,0x17,0x57,0xb5,0x43,0x6f,0x1d,0x0b,0x3e,0xea,0x7d,0xce,0x49,0x8f,0x8a,0x0a},
648    {0x89,0x86,0xa0,0xfc,0x6f,0xd1,0xe6,0x1b,0xef,0x2f,0xc7,0x45,0x64,0xa7,0x0b,0x18},
649    {0x57,0x38,0x70,0x4f,0x75,0xa3,0xff,0x3b,0x86,0xa6,0x0a,0x55,0x96,0xed,0x09,0xb3},
650    {0x09,0xe1,0xc3,0xd2,0x6b,0xaf,0x74,0xe6,0xf9,0xa1,0x2f,0x9f,0x3f,0x2d,0xe9,0xa5},
651    {0x81,0xf7,0xb1,0x28,0xcd,0x71,0xbd,0x1a,0x59,0x50,0x74,0x45,0x00,0xc7,0x25,0xd4},
652    {0x26,0xc6,0x83,0xa0,0x88,0x71,0x2b,0x79,0x3f,0xf4,0x1d,0x8a,0x0c,0x0e,0xc0,0x45},
653    {0xd0,0x37,0xe2,0x1b,0x2f,0xe6,0xf1,0x9c,0x00,0x74,0x6e,0xb5,0xd6,0x32,0x9a,0xa2},
654    {0x06,0xdb,0x21,0x87,0x57,0x84,0xe5,0x35,0x6a,0x5b,0x97,0x99,0x15,0x0f,0x84,0x4c},
655    {0x2b,0x33,0xcb,0x52,0xae,0xff,0xb2,0x2e,0x23,0x30,0x9d,0x8b,0xc1,0x97,0x66,0x85},
656    {0xb9,0xb4,0x53,0x1c,0xf7,0x1c,0xb2,0x60,0x72,0x8e,0x42,0x43,0x85,0xcd,0x5c,0x7e},
657    {0xc4,0xfb,0xd4,0xa1,0x4c,0x59,0x5a,0xdf,0xb3,0xd2,0x44,0xfd,0x6d,0x46,0x9a,0x53},
658    {0xe6,0x56,0xed,0x4a,0xa2,0x98,0xed,0xb4,0x91,0xb0,0xb7,0x20,0x86,0x8a,0x11,0x2b},
659    {0x75,0x07,0x6e,0xc6,0xa2,0x1d,0x7e,0x4d,0xa8,0x7a,0x30,0x4e,0x9e,0xdd,0x02,0x62},
660    {0x27,0xdf,0x84,0xc1,0x2b,0xf8,0x37,0xac,0x68,0x1f,0xfd,0x26,0x63,0x93,0x88,0xf7},
661    {0x94,0xc7,0x5f,0x32,0xf1,0x00,0xa3,0xc3,0x2d,0x47,0xd0,0x1a,0xa9,0x8c,0xf9,0xa8},
662    {0x83,0x51,0x2c,0xc6,0x89,0x5b,0x44,0x15,0x14,0xa0,0xa4,0x15,0xf3,0x14,0x2a,0x6c},
663    {0x37,0x47,0xfe,0x8b,0x81,0xcb,0x6e,0x65,0x29,0x87,0x2d,0xe5,0x07,0x5c,0x3b,0xcb},
664    {0x33,0x87,0x0a,0xc7,0x1c,0x7a,0x8e,0xc6,0x68,0xcd,0x68,0x65,0xb1,0x15,0x84,0xb6},
665    {0x8a,0xa4,0x4a,0x11,0x84,0xdc,0x25,0xf9,0xa5,0x44,0x2c,0xd6,0xe1,0x39,0x16,0x5d},
666    {0xdc,0x7e,0x23,0xb3,0x8c,0x34,0xea,0x5c,0xd1,0x24,0xc6,0x74,0x00,0x46,0xd4,0x3c},
667    {0xdb,0x8f,0x84,0x41,0x38,0x05,0x89,0xf4,0x49,0xef,0xb9,0xe8,0xf0,0x8e,0x21,0x0c},
668    {0x86,0x63,0x3b,0x95,0x72,0x80,0xbc,0x65,0xa5,0xad,0xfd,0x1d,0x15,0x3b,0xde,0x52},
669    {0xb0,0x62,0x55,0xfa,0xe2,0x88,0xba,0xa6,0x6c,0x83,0xcb,0xf0,0x3f,0x5d,0x16,0x09},
670    {0x1a,0x07,0xd8,0xd6,0xdd,0xc7,0xe6,0x23,0xe7,0x12,0x05,0x07,0x4a,0x05,0xce,0xa2},
671    {0x97,0x00,0x4b,0x3d,0x85,0x6f,0x36,0x2c,0x3d,0x7c,0xd6,0x46,0xf6,0x05,0xcf,0xa5},
672    {0x2c,0xd3,0xaa,0x47,0x3e,0x64,0x48,0x1a,0xbd,0x68,0xe0,0xb1,0x0d,0x28,0x70,0xdf},
673    {0x3e,0x83,0x78,0xf1,0xe2,0x48,0x4c,0xe2,0x31,0x91,0x06,0x16,0xe4,0xb9,0x10,0x30},
674    {0xd4,0x48,0x44,0xe3,0x38,0xa1,0x02,0x53,0x6c,0x0c,0x23,0x8f,0x76,0xe0,0x7e,0xd2},
675    {0xed,0x52,0x13,0x57,0xb7,0x34,0x2f,0xb6,0xb5,0x6e,0x6b,0x7e,0x03,0xec,0xec,0x21},
676    {0x7f,0x3d,0x39,0x52,0x19,0xc7,0xb9,0xb8,0xc6,0x0e,0x4f,0x52,0xd9,0x33,0x50,0xb2},
677    {0xbe,0x69,0x1e,0x23,0x68,0x70,0xd9,0x01,0x4e,0xda,0x67,0xd3,0x9b,0x3f,0x80,0xa9},
678    {0x4b,0xf3,0x02,0x0d,0x00,0xff,0xb8,0x31,0xf3,0x8a,0xf3,0x1e,0x26,0xb9,0x04,0x9a},
679    {0x44,0x0e,0xea,0x70,0x5a,0x9f,0x79,0x15,0x35,0x60,0xbf,0xc4,0x4a,0x13,0x5d,0x99},
680    {0xe9,0x92,0x00,0x82,0x28,0x03,0xad,0x53,0x65,0x27,0xb5,0x90,0x4d,0xac,0x04,0x6f},
681    {0x63,0xf8,0x79,0x61,0x7a,0x3d,0x48,0xc0,0xc9,0x39,0x06,0xb6,0xa5,0xc9,0x99,0x8f},
682    {0xd6,0xbe,0x78,0x3f,0x1f,0x34,0x35,0x79,0x63,0x0a,0xa4,0xbe,0x60,0xc8,0xb4,0xc8},
683    {0xbb,0x83,0x3b,0x51,0xa8,0x2f,0x7e,0xb9,0xab,0x5c,0xff,0x4b,0x6f,0x0a,0x58,0x9e},
684    {0x85,0x36,0x66,0x57,0x3c,0xdb,0xc6,0x80,0x74,0x0c,0xad,0x26,0x25,0x05,0x4a,0x22},
685    {0xd6,0x2c,0x3d,0x36,0xc3,0xa9,0xa5,0xd8,0xcf,0xcb,0x76,0x0d,0x5b,0xcb,0xb1,0xf2},
686    {0x46,0x0c,0x33,0x8e,0x89,0xba,0xa1,0x45,0x26,0x1f,0x2a,0x06,0x6c,0x56,0x86,0x2e},
687    {0x5d,0x27,0x8c,0x8f,0xcd,0x78,0x9e,0xda,0x9d,0xef,0x09,0x6c,0x91,0xe1,0x15,0xe1},
688    {0xcb,0xae,0xad,0xd5,0x76,0x4b,0x56,0x91,0xa1,0xb0,0xef,0x87,0xae,0x2b,0xb7,0xc6},
689    {0x33,0x1e,0x3c,0x0b,0x5b,0x8e,0xd3,0xac,0xbf,0x72,0x7a,0x27,0x4c,0xf9,0xd4,0x32},
690    {0xe5,0x66,0xe1,0x8a,0x28,0xc6,0xc4,0x4c,0xb1,0x29,0x55,0x23,0x9a,0x38,0x08,0xe3},
691    {0x51,0x68,0xf4,0x42,0xbd,0xd4,0xc4,0x24,0x95,0xdb,0xb1,0xd5,0xaf,0x23,0xf5,0xf1},
692    {0xb8,0x05,0x89,0x79,0xa8,0x42,0x6d,0x1b,0xbc,0x23,0x3d,0xa0,0xf7,0x6d,0x59,0x88},
693    {0x88,0x60,0xfc,0xbf,0xda,0x75,0xf4,0x3e,0x6f,0x9a,0x1c,0x57,0x6b,0x27,0x23,0x3a},
694    {0x39,0x83,0xdf,0x8b,0x4f,0xc3,0x30,0xb5,0x87,0x32,0x9f,0x62,0xab,0x8a,0xbb,0x13},
695    {0x79,0xc8,0xe8,0xb7,0xde,0x36,0x53,0x9f,0xfc,0x4b,0x2b,0x58,0x25,0x30,0x53,0x24},
696    {0x06,0xcb,0xb1,0xcc,0x51,0x15,0x6c,0x6d,0x46,0x5f,0x14,0x82,0x94,0x53,0xdd,0x68},
697    {0x51,0x49,0xe0,0xbb,0xa2,0xc4,0x69,0x3b,0xde,0xe4,0xfe,0x90,0xc1,0x22,0x76,0x27},
698    {0xf8,0xe5,0xe0,0xe2,0x02,0x50,0x9a,0x1a,0x21,0x7e,0x72,0x2f,0x14,0xd9,0x0e,0xf2},
699    {0x8b,0x10,0x97,0x63,0xa2,0xc5,0x2b,0x0f,0x86,0x04,0x6d,0x18,0xf1,0xba,0x97,0x81},
700    {0x49,0x68,0xf4,0xbd,0x42,0x6a,0x68,0xfa,0xd9,0xde,0x67,0x63,0x9c,0xcc,0x63,0x9a},
701    {0x09,0xf7,0x2a,0x16,0xcf,0x28,0xd8,0x20,0xb5,0x34,0x8f,0x22,0x9e,0x1b,0x9e,0x51},
702    {0x39,0x1d,0xde,0x64,0x85,0x6b,0xee,0xe6,0x9d,0x3b,0x39,0x16,0xcc,0x9a,0x00,0xdb},
703    {0x50,0x6f,0xc2,0xc4,0x67,0x9a,0x8f,0x41,0x07,0x19,0x85,0x1b,0xa5,0xaf,0x10,0x6c},
704    {0xfa,0x8d,0x23,0xab,0x7f,0x1d,0x4e,0x6b,0xbf,0xd5,0x1b,0x11,0x23,0x62,0x8b,0xe0},
705    {0xb0,0xf8,0x09,0xbe,0x90,0xab,0xad,0xb2,0x49,0x64,0x5b,0x46,0x33,0x4d,0x46,0xcf},
706    {0x35,0xab,0x29,0xcc,0x8d,0xd8,0xf9,0x5a,0x04,0x75,0x16,0xec,0xbe,0x30,0xa0,0x4f},
707    {0x95,0x59,0xb1,0x04,0x8c,0xcd,0x7f,0xf7,0xbe,0x62,0xb7,0xad,0xc2,0x3c,0xd4,0xf2},
708    {0x64,0xb2,0xfd,0xad,0x1c,0xd1,0xc7,0xcb,0x5a,0x07,0x87,0x4e,0x50,0xc8,0x44,0xf7},
709    {0x2b,0x37,0x47,0x59,0x3e,0x64,0xf7,0xf2,0xfc,0x71,0x37,0x6e,0x94,0x11,0x86,0xd5},
710    {0x94,0xcf,0xf9,0x1e,0x95,0x05,0xcb,0xfc,0x51,0x6c,0xcc,0x58,0xd6,0x7e,0x5c,0x5d},
711    {0x90,0x59,0x1a,0x1f,0xb8,0x9f,0x19,0x3e,0x47,0x5f,0x65,0xe8,0xbf,0x00,0x8e,0x4c},
712    {0xe7,0xd6,0x44,0x11,0xac,0x8d,0xc6,0x4c,0x98,0xaa,0x3b,0x50,0x2f,0xe9,0x11,0x37},
713    {0x41,0x5c,0xa8,0xd0,0xe2,0x87,0x10,0x04,0x51,0xc5,0x8e,0xa6,0xf1,0xa9,0xbe,0xb6},
714    {0x3f,0x1b,0x34,0xf0,0x9f,0x8b,0x4a,0x1e,0xad,0xb4,0x90,0xbe,0x47,0xa8,0xd0,0x62},
715    {0x89,0xdb,0xb9,0x5e,0x30,0xdd,0x1f,0xe8,0x37,0xed,0xc5,0x05,0x89,0x7b,0x65,0x02},
716    {0xa4,0x13,0xd7,0x25,0xf5,0x67,0xfa,0xc9,0x93,0x74,0xa6,0x89,0xb6,0xce,0xd8,0x68},
717    {0x8c,0xdd,0xef,0x7b,0x6b,0x7d,0x7c,0xc9,0x2f,0x87,0xee,0x79,0x98,0x10,0x13,0xc1},
718    {0x07,0xfc,0x7a,0x1e,0x11,0x5e,0x83,0xee,0x65,0xd5,0x8d,0x3d,0x81,0x9a,0xb4,0x1e},
719    {0x64,0xdc,0x17,0x7e,0x6d,0xf5,0x33,0x40,0x1e,0x74,0xff,0xe8,0xce,0x4a,0x9f,0x40},
720    {0x81,0x94,0xde,0x4d,0xbc,0xc9,0xe6,0x18,0x00,0x5e,0x5d,0x50,0x27,0x9f,0xfd,0xe9},
721    {0xfd,0x3e,0x6f,0x62,0xbe,0x93,0xf5,0x2a,0x34,0x39,0x67,0x47,0x7a,0x3c,0xe8,0x95},
722    {0xb7,0x28,0x7e,0x92,0x5d,0xae,0x57,0x1c,0xb5,0x3a,0xbb,0xa8,0x1c,0xd4,0x72,0x1b},
723    {0x1a,0xc1,0x24,0xbd,0xc1,0x67,0xce,0x45,0x55,0x50,0x40,0xe4,0xfe,0xc1,0x5a,0x85},
724    {0xe7,0x44,0xb2,0x33,0xa1,0xfb,0x1e,0x84,0x9b,0x58,0x73,0xca,0x2c,0x6d,0xcd,0x0b},
725    {0x96,0x17,0x8d,0x5a,0x67,0xb1,0x0a,0x91,0x62,0xb2,0x48,0x01,0x96,0x9f,0x21,0xf5},
726    {0x6b,0xcd,0x5f,0xf3,0x5a,0x6c,0x8f,0xbe,0xff,0x86,0x82,0x22,0xbf,0x93,0x93,0x3e},
727    {0x3f,0x2a,0x5e,0xd2,0x6d,0x98,0xd8,0x6b,0x0a,0xe7,0xe8,0x76,0x67,0x11,0xdb,0x80},
728    {0x7c,0x70,0x1a,0x08,0x98,0xd1,0xb2,0xbf,0xe9,0x10,0xde,0xb5,0xec,0x5f,0x90,0x95},
729    {0x4b,0x50,0x25,0xd8,0xdf,0xad,0x34,0x47,0xf1,0x47,0x41,0x9a,0x3f,0x91,0x56,0x1a},
730    {0x03,0x87,0x4a,0x58,0xe3,0x65,0xef,0x78,0x44,0xfb,0x92,0x42,0xb4,0x41,0xe9,0xea},
731    {0x94,0xaf,0xcb,0xaa,0xa3,0x65,0x5c,0xb1,0x4e,0x34,0xc9,0x2b,0xdd,0xa3,0xf7,0x86},
732    {0x13,0x22,0x01,0xd8,0x0c,0x07,0xe9,0xe2,0x99,0xb5,0x3b,0xc3,0x52,0xca,0x15,0x3b},
733    {0xc5,0x7f,0x2c,0x1e,0xc6,0xb1,0x34,0x9c,0x6a,0x7e,0x92,0x04,0x43,0xac,0x5e,0x3a},
734    {0x2d,0x2b,0xd9,0x79,0x3e,0xde,0x74,0x82,0x05,0x8d,0xb6,0xf7,0xdf,0xb1,0x25,0x90},
735    {0x6f,0xf9,0xc0,0x8b,0xfc,0x8c,0x81,0xe7,0x05,0x1e,0x07,0xef,0x4f,0xe7,0x26,0x7f},
736    {0x3a,0xa3,0x46,0xa0,0xa7,0xbb,0x0c,0x3d,0xce,0x13,0x16,0x19,0xb5,0x22,0x5d,0x8f},
737    {0x89,0xe6,0xdd,0xfa,0x63,0x34,0xd3,0x32,0xdd,0x7f,0x98,0x48,0xee,0xd8,0x2d,0xf5},
738    {0xed,0xd4,0xae,0x23,0xa3,0x34,0x95,0xcc,0x5d,0x77,0xae,0x7b,0xa7,0x99,0xc0,0x44},
739    {0xe4,0x19,0x5f,0x34,0xb8,0x7b,0x27,0xef,0x7e,0x24,0x45,0x67,0x01,0x84,0xb0,0xe9},
740    {0x8f,0x1a,0xf7,0xa6,0xb8,0xd3,0x3a,0x34,0x05,0xcb,0xd4,0x50,0xbd,0x13,0xad,0x75},
741    {0x67,0xd9,0xb8,0x1d,0xe5,0x2d,0x00,0x80,0x0a,0x41,0x9b,0x1f,0x0c,0xe7,0x2b,0x8a},
742    {0x18,0x09,0x91,0xac,0x8e,0xf5,0xbe,0x23,0x5f,0x14,0x5d,0xfb,0xf1,0xc1,0xe1,0x0f},
743    {0x24,0x70,0x94,0xde,0x01,0x5a,0xb4,0xd7,0x66,0xe2,0x09,0x1e,0x4d,0x28,0xfd,0xde},
744    {0x90,0x5d,0x96,0x0b,0xb9,0x2a,0x4e,0x49,0xd9,0xda,0xb2,0xba,0x00,0x85,0x0e,0x3e},
745    {0xce,0x48,0x54,0xb3,0x78,0xd4,0xc3,0xda,0xf0,0x96,0xa5,0xaf,0x24,0x67,0x47,0x6c},
746    {0xd7,0xf6,0x3e,0xf0,0x30,0x80,0x17,0x2a,0xd4,0x18,0x2c,0x6d,0xe1,0x18,0x54,0x19},
747    {0x1b,0x95,0x59,0x42,0x14,0x96,0x53,0xee,0xc3,0xf4,0xf0,0x94,0xfa,0x96,0x14,0xbe},
748    {0x4e,0xa9,0x43,0x41,0xaa,0x3f,0x59,0x09,0x10,0xc7,0x5d,0xca,0x63,0x2b,0x40,0x36},
749    {0x1b,0x67,0x00,0xb7,0xc6,0x1d,0x0b,0xe5,0x25,0x47,0xdb,0x19,0x19,0xb7,0xcc,0x0e},
750    {0x9b,0x2a,0x3b,0xaa,0xaa,0x00,0x5c,0xa4,0x8b,0xd1,0x39,0xc3,0xa4,0xb1,0xb9,0x39},
751    {0x88,0x6b,0x5a,0x1e,0x93,0x22,0x84,0xed,0x20,0x37,0x9d,0x37,0xf7,0xef,0x7a,0xa6},
752    {0x89,0x1e,0x8a,0xa7,0x40,0xe0,0x41,0xad,0xe3,0xa2,0xd2,0x20,0x9f,0x0f,0x6c,0x7e},
753    {0xb7,0x76,0x75,0x39,0x44,0x08,0x68,0x9d,0xb4,0xb0,0xb7,0x84,0x94,0x5c,0x0f,0xea},
754    {0xd6,0x32,0x73,0x2d,0xa5,0x5e,0x9a,0xc7,0x7f,0xfa,0xb9,0x46,0x11,0x35,0x8b,0x9d},
755    {0x12,0xf7,0x4f,0x60,0x7b,0x9a,0xdd,0x06,0x20,0x35,0x31,0xfa,0x47,0xfc,0x03,0xd6},
756    {0xc4,0x9b,0x60,0x13,0xc5,0x48,0xcc,0xdc,0x49,0x58,0x0a,0x79,0x55,0xfc,0x2a,0x7e},
757    {0x53,0x1d,0x22,0x6b,0x47,0x88,0x72,0xbd,0x69,0xc0,0xa6,0x5a,0x36,0x4e,0xb0,0x8c},
758    {0x53,0x82,0xcd,0x4c,0xfc,0xe9,0x97,0xc1,0xf4,0x55,0x5f,0x1a,0x08,0x04,0x4d,0x07},
759    {0x10,0x37,0x4c,0x98,0x9e,0x1d,0xf5,0x58,0x53,0x15,0x20,0x71,0x06,0x3e,0x3a,0x73},
760    {0x6c,0x12,0xb4,0x08,0xf7,0xf1,0x6d,0x2c,0x71,0x6b,0x67,0x02,0xd0,0x55,0x7b,0xcd},
761    {0x34,0xd5,0xd1,0x5d,0x36,0x44,0xf5,0x0e,0x0b,0x3e,0xea,0xf0,0x76,0xb5,0xe9,0xee},
762    {0xc8,0xa1,0x0c,0xf3,0x34,0xc2,0xae,0x63,0x60,0xb5,0xa3,0x0b,0x3d,0x86,0x41,0x7d},
763    {0xa3,0xdc,0x0f,0x15,0x87,0x65,0x4d,0x4b,0xc5,0x12,0x0f,0x91,0x49,0x64,0xdb,0x48},
764    {0xee,0x4d,0xcf,0xf5,0x83,0xab,0xba,0x8e,0xec,0x61,0x6e,0xaa,0x11,0x1f,0x86,0x0a},
765    {0xc3,0x10,0xca,0x83,0x40,0x19,0xf9,0xac,0xa7,0xce,0xad,0x19,0x75,0xc9,0x50,0xb5},
766    {0x79,0x89,0x76,0xb4,0x17,0x6e,0x91,0x66,0xc9,0xdf,0x6b,0xaf,0x07,0xdb,0x4c,0x85},
767    {0xf8,0x4e,0x88,0x6c,0xbc,0x5c,0xc3,0x24,0x27,0x16,0xf1,0xcf,0xb0,0x23,0x93,0xf3},
768    {0x79,0x51,0x2f,0x7c,0xd7,0x0c,0xe4,0xd7,0xb9,0x2e,0x0c,0x65,0xbd,0xda,0xae,0xa4},
769    {0xdb,0xea,0xda,0xdd,0x40,0x68,0x2f,0xb5,0x5d,0x81,0x84,0xfe,0x00,0x73,0xa2,0xd9},
770    {0xf5,0x88,0x10,0x6b,0xaf,0x63,0xc5,0x70,0x11,0xd4,0x63,0x93,0x58,0x71,0xba,0x1c},
771    {0x6f,0xed,0x44,0x67,0x7e,0x59,0x37,0xdc,0xda,0x85,0x57,0x9f,0xc9,0xdd,0x0e,0xb5},
772    {0x32,0x97,0x51,0x8c,0x51,0xd4,0x64,0x5a,0x73,0x50,0xfb,0x90,0xb9,0x3c,0x2d,0xd8},
773    {0xe5,0x08,0x0a,0x59,0xb3,0xc4,0xfc,0x10,0x15,0x38,0x35,0xdd,0x45,0xdc,0x55,0x52},
774    {0xfe,0xd3,0x7d,0xda,0xbb,0xb0,0xf5,0x07,0x05,0x1f,0x8d,0x86,0x46,0xf1,0x69,0x43},
775    {0xd1,0x60,0x46,0xdc,0x2e,0x78,0xcf,0x18,0xce,0xe0,0x1f,0x1d,0x97,0x0e,0xe4,0xb1},
776    {0x10,0xb0,0xec,0x09,0xea,0x45,0xe9,0xd1,0xd1,0xf8,0x73,0x72,0xe2,0xd4,0xc6,0x4a},
777    {0xf0,0x66,0x18,0xb2,0x79,0x00,0xab,0x31,0x5c,0x8a,0x24,0x6d,0x3c,0xfd,0x11,0x06},
778    {0xaf,0x77,0x28,0xb1,0x4d,0x47,0xa6,0xff,0x74,0x30,0x80,0x74,0xe6,0x7b,0x75,0xdc},
779    {0xab,0x9f,0xfc,0xb0,0xf7,0xc3,0xe2,0xb6,0xaa,0x06,0x32,0xde,0xe9,0x7f,0xf0,0x4e},
780    {0x67,0x91,0x59,0x6f,0x76,0x99,0x7f,0xe1,0xec,0x23,0x53,0xd3,0x21,0xe4,0x3a,0x4a},
781    {0xc2,0xfd,0x99,0x93,0x4b,0x0d,0x76,0x77,0x10,0xd1,0x03,0x9e,0x35,0xec,0xaf,0xc4},
782    {0x2c,0x26,0x15,0x2c,0xf9,0x93,0x38,0x9b,0x02,0x69,0xe5,0xf5,0xb7,0x63,0xc8,0x7d},
783    {0x97,0x6e,0x07,0x58,0xc6,0x22,0x62,0xf5,0x9e,0x97,0xf4,0x20,0x33,0xdc,0x8e,0x1d},
784    {0x8b,0x74,0x09,0xd0,0x97,0x91,0x51,0x4d,0x21,0xd4,0xa6,0xf6,0x91,0xeb,0x76,0x58},
785    {0x0c,0x01,0xdf,0x15,0xc2,0x9d,0xb4,0x8e,0xe2,0xc5,0xf1,0xda,0x3d,0xab,0x74,0x6d},
786    {0xa1,0x79,0x93,0x3b,0x61,0xe9,0x0e,0x45,0xf1,0x32,0xec,0x17,0x80,0x34,0x8f,0x8b},
787    {0x41,0x7d,0x99,0xce,0xab,0xbc,0x1a,0xad,0xe3,0x58,0xbf,0x53,0xe1,0x92,0xa6,0xb4},
788    {0xd6,0xf3,0x71,0x0a,0x57,0xac,0x0d,0xa9,0xae,0x72,0xf4,0xb8,0x29,0xbd,0x5f,0xe5},
789    {0xa0,0xae,0x10,0xca,0x41,0x0d,0x93,0x32,0x9b,0x19,0xb7,0x65,0x5a,0xa3,0x18,0xed},
790    {0x91,0xd0,0xa3,0x45,0x4e,0x9d,0xfc,0xeb,0xc4,0xa0,0x3d,0x4c,0xc6,0x67,0x62,0x3b},
791    {0x5a,0xa1,0xa1,0x13,0x62,0x69,0x19,0xbb,0x5b,0x62,0x37,0x08,0xc5,0xb2,0x34,0xca},
792    {0xd1,0x0c,0x08,0x0d,0xdf,0x1e,0xca,0xda,0x21,0xa0,0xb9,0xdd,0x4e,0x40,0x17,0x1c},
793    {0x0f,0x87,0x02,0x6f,0x9f,0x9e,0xa5,0xaa,0x24,0xda,0x79,0x18,0x4e,0x46,0xbe,0x95},
794    {0x54,0x32,0xfc,0x98,0x14,0x18,0x83,0xf7,0x80,0x89,0x7b,0xc8,0x29,0xeb,0x90,0x80},
795    {0x57,0x44,0x26,0xc4,0x44,0x01,0x25,0x44,0x6f,0xd2,0xd3,0x04,0xcf,0x13,0x37,0x99},
796    {0x70,0x71,0x2d,0x06,0x80,0x6d,0x26,0x93,0x60,0x7d,0xf9,0x69,0x79,0xa3,0x95,0xf2},
797    {0x0f,0xac,0x31,0x7d,0xd9,0xf9,0x58,0xce,0xac,0x7f,0x42,0xad,0x3c,0xde,0x3e,0x3e},
798    {0x23,0x30,0x77,0xd9,0xfd,0x64,0xf6,0xa7,0xff,0x4b,0xad,0x3f,0xa9,0x61,0xd1,0x4d},
799    {0x38,0x68,0x36,0x7a,0xd1,0x7a,0x77,0x07,0xed,0x7e,0x19,0xb3,0x71,0x56,0x7e,0xdb},
800    {0x0a,0x75,0x86,0x4a,0x93,0xb8,0xaf,0x71,0x09,0xae,0xa3,0x57,0xcc,0x45,0xb6,0x38},
801    {0xed,0x15,0xbc,0xce,0x02,0x64,0x46,0x8a,0x58,0xc2,0xef,0xdb,0xc4,0x57,0xa6,0x0f},
802    {0xd9,0x13,0xc8,0xae,0xf9,0x7a,0xc7,0x62,0x66,0x4f,0xe0,0x91,0xab,0xdb,0x0b,0x5b},
803    {0xa2,0xcb,0xd5,0x32,0xed,0x71,0x07,0x63,0x25,0x59,0xfb,0x06,0xfa,0xb0,0xbd,0x70},
804    {0x6e,0x23,0x5e,0x65,0x9c,0xc6,0xcd,0x89,0xba,0x68,0xa2,0x92,0x28,0xb3,0x74,0x10},
805    {0x50,0x0d,0x88,0x2a,0x93,0x19,0x9b,0xf0,0x97,0x0e,0x96,0x62,0xbe,0x94,0x6d,0x02},
806    {0x0c,0xc7,0x0a,0xc8,0xb1,0xad,0xbf,0xda,0xce,0x8b,0x51,0x34,0x16,0x85,0x8a,0xf2},
807    {0xff,0x78,0x96,0x32,0xb8,0xd4,0xae,0xcd,0x94,0xa0,0xaa,0xb3,0x30,0x74,0xa0,0x58},
808    {0x8a,0xd2,0x35,0xc1,0x09,0x65,0x23,0x39,0xbd,0xea,0x3a,0xc8,0x32,0x55,0xb2,0x88},
809    {0x45,0xcf,0x0b,0x3f,0x9d,0xa8,0xd2,0x17,0x6e,0x5c,0x53,0x0c,0xe2,0xa7,0x4e,0xe6},
810    {0xec,0x35,0x8a,0x4b,0xaa,0x38,0x45,0xeb,0x24,0xaf,0x6c,0x0c,0x34,0xef,0xb2,0xeb},
811    {0x73,0xfd,0xd6,0xc7,0x65,0x3c,0xde,0xdc,0x9a,0xda,0x88,0xc8,0xe9,0x7e,0x5e,0x77},
812    {0xf0,0x88,0x2a,0x36,0x10,0xa5,0xe8,0x5f,0x8a,0x17,0x49,0xb9,0x77,0x9d,0xb7,0x3c},
813    {0xfe,0x73,0x90,0xdb,0x0d,0x7f,0x6c,0x64,0xba,0x20,0xfa,0xb8,0x98,0x6b,0x07,0xac},
814    {0x87,0x07,0x70,0x09,0xd7,0x96,0xf7,0x0f,0xc1,0x79,0xf3,0x98,0xbc,0x94,0x7a,0x0d},
815    {0x44,0x08,0x71,0x99,0x1c,0xf0,0x1e,0x3d,0x7f,0x58,0xc4,0x5e,0x20,0x3e,0xa5,0xed},
816    {0x64,0xd2,0x35,0x96,0x94,0x7a,0xe5,0x1a,0xcb,0xc8,0xa2,0x4f,0xaf,0x22,0xd4,0x83},
817    {0x8b,0x01,0x1d,0xaa,0x9f,0x3b,0x72,0xda,0x93,0x67,0x03,0x6c,0x8a,0x89,0xe8,0x0d},
818    {0x61,0xd3,0x0f,0x6b,0x8a,0x2a,0x10,0x3d,0xcf,0x37,0x1d,0xa4,0xc0,0x04,0x60,0x02},
819    {0x66,0xe4,0x6e,0x5b,0x8d,0x57,0x42,0x81,0xc9,0x35,0xe6,0x34,0x03,0x8e,0x87,0x7b},
820    {0xf8,0x4b,0x75,0xfc,0xe8,0xbd,0x1f,0xf1,0x3f,0xa0,0x79,0xcc,0x39,0xd4,0x51,0x64},
821    {0x62,0xf0,0x91,0x47,0xb1,0xac,0x01,0x4d,0x88,0x92,0xc0,0xf8,0x29,0x4d,0x0b,0x66},
822    {0xe7,0xf5,0x86,0x83,0x06,0x61,0x12,0xdc,0x5e,0xb2,0x44,0xfc,0xf2,0x08,0xe8,0x50},
823    {0x97,0x0c,0x55,0xe7,0x2e,0x6a,0x7b,0xfc,0x51,0x12,0xd8,0xa0,0xb5,0x7f,0x2e,0x18},
824    {0x19,0xf1,0xf7,0xdf,0xba,0xfd,0xd3,0xf1,0x20,0x75,0xb0,0xa2,0xfa,0x78,0x84,0x8d},
825    {0x9e,0xaf,0xe6,0xd3,0x83,0x69,0x72,0x39,0x64,0xbe,0x9f,0x4f,0x19,0x8e,0x36,0x16},
826    {0x35,0x80,0x30,0xbc,0x92,0xa9,0x9b,0x61,0xe9,0x6a,0xee,0x63,0x0e,0x32,0xa9,0xc3},
827    {0x2e,0x34,0xe5,0x92,0xca,0xbd,0xe8,0x9b,0xde,0x01,0xe7,0xfb,0xd4,0x25,0xcc,0x93},
828    {0x83,0xef,0x75,0x79,0x05,0xde,0xcd,0x9f,0x97,0x3c,0x60,0x2f,0x4b,0x1e,0x1a,0x96},
829    {0x5b,0xec,0xea,0x91,0x8f,0x7a,0x1a,0xe9,0xe8,0xd7,0xc7,0xa4,0xc0,0x25,0x65,0xe1},
830    {0x32,0x50,0xb9,0xbe,0x0d,0xd0,0x0a,0x10,0x64,0xab,0xc9,0xbf,0xb3,0xba,0x56,0x92},
831    {0x31,0x4b,0xc4,0xfb,0x88,0x16,0x17,0xd7,0x5b,0x7f,0xcc,0x8a,0xbe,0xd1,0xf9,0x19},
832    {0x10,0x34,0x3e,0x96,0x72,0x69,0x92,0x7b,0x5d,0x8f,0x92,0xdc,0xae,0x4b,0xf6,0x55},
833    {0x65,0x7e,0xfa,0xec,0x2e,0xdf,0x76,0x0b,0x9d,0x59,0xe2,0xd0,0x0b,0x1b,0xb9,0x8a},
834    {0xb0,0x31,0x6b,0xd2,0x63,0xb0,0x28,0x79,0xb3,0x64,0x5f,0x45,0xdc,0x98,0x58,0xa0},
835    {0xed,0x1a,0x10,0x08,0x19,0x0a,0x5d,0x16,0x54,0xd1,0x38,0xeb,0x8f,0xd1,0x15,0x4a},
836    {0xad,0x7c,0x7f,0x0c,0xfe,0x66,0x6f,0xbe,0xde,0xf2,0x0a,0xa9,0x5f,0x22,0xf9,0x0b},
837  };
838
839  if (serial_number_.size() == kSerialBytes) {
840    for (unsigned i = 0; i < kNumSerials; i++) {
841      if (memcmp(kSerials[i], serial_number_.data(), kSerialBytes) == 0) {
842        UMA_HISTOGRAM_ENUMERATION("Net.SSLCertBlacklisted", i, kNumSerials + 1);
843        return true;
844      }
845    }
846  }
847
848  // Special case for DigiNotar: this serial number had a leading 0x00 byte
849  static const uint8 kDigiNotarLeadingZero[15] = {
850    0x17,0x7f,0xb6,0x53,0x6b,0x98,0xce,0x40,0xd5,0x4b,0x8b,0x24,0xe3,0x16,0x05
851  };
852
853  if (serial_number_.size() == sizeof(kDigiNotarLeadingZero) &&
854      memcmp(serial_number_.data(), kDigiNotarLeadingZero,
855             sizeof(kDigiNotarLeadingZero)) == 0) {
856    UMA_HISTOGRAM_ENUMERATION("Net.SSLCertBlacklisted", kNumSerials,
857        kNumSerials + 1);
858    return true;
859  }
860
861  return false;
862}
863
864// static
865bool X509Certificate::IsPublicKeyBlacklisted(
866    const std::vector<SHA1Fingerprint>& public_key_hashes) {
867  static const unsigned kNumHashes = 3;
868  static const uint8 kHashes[kNumHashes][base::SHA1_LENGTH] = {
869    // Subject: CN=DigiNotar Root CA
870    // Issuer: CN=Entrust.net x2 and self-signed
871    {0x41, 0x0f, 0x36, 0x36, 0x32, 0x58, 0xf3, 0x0b, 0x34, 0x7d,
872     0x12, 0xce, 0x48, 0x63, 0xe4, 0x33, 0x43, 0x78, 0x06, 0xa8},
873    // Subject: CN=DigiNotar Cyber CA
874    // Issuer: CN=GTE CyberTrust Global Root
875    {0xba, 0x3e, 0x7b, 0xd3, 0x8c, 0xd7, 0xe1, 0xe6, 0xb9, 0xcd,
876     0x4c, 0x21, 0x99, 0x62, 0xe5, 0x9d, 0x7a, 0x2f, 0x4e, 0x37},
877    // Subject: CN=DigiNotar Services 1024 CA
878    // Issuer: CN=Entrust.net
879    {0xe2, 0x3b, 0x8d, 0x10, 0x5f, 0x87, 0x71, 0x0a, 0x68, 0xd9,
880     0x24, 0x80, 0x50, 0xeb, 0xef, 0xc6, 0x27, 0xbe, 0x4c, 0xa6},
881  };
882
883  for (unsigned i = 0; i < kNumHashes; i++) {
884    for (std::vector<SHA1Fingerprint>::const_iterator
885        j = public_key_hashes.begin(); j != public_key_hashes.end(); ++j) {
886      if (memcmp(j->data, kHashes[i], base::SHA1_LENGTH) == 0)
887        return true;
888    }
889  }
890
891  return false;
892}
893
894// static
895bool X509Certificate::IsSHA1HashInSortedArray(const SHA1Fingerprint& hash,
896                                              const uint8* array,
897                                              size_t array_byte_len) {
898  DCHECK_EQ(0u, array_byte_len % base::SHA1_LENGTH);
899  const unsigned arraylen = array_byte_len / base::SHA1_LENGTH;
900  return NULL != bsearch(hash.data, array, arraylen, base::SHA1_LENGTH,
901                         CompareSHA1Hashes);
902}
903
904}  // namespace net
905