OLD | NEW |
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 #include "base/base64.h" | 5 #include "base/base64.h" |
6 #include "base/format_macros.h" | 6 #include "base/format_macros.h" |
7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
11 #include "base/stringprintf.h" | 11 #include "base/stringprintf.h" |
| 12 #include "base/time.h" |
12 #include "base/values.h" | 13 #include "base/values.h" |
13 #include "crypto/sha2.h" | 14 #include "crypto/sha2.h" |
14 #include "net/base/crl_set.h" | 15 #include "net/base/crl_set.h" |
15 | 16 |
16 #if defined(USE_SYSTEM_ZLIB) | 17 #if defined(USE_SYSTEM_ZLIB) |
17 #include <zlib.h> | 18 #include <zlib.h> |
18 #else | 19 #else |
19 #include "third_party/zlib/zlib.h" | 20 #include "third_party/zlib/zlib.h" |
20 #endif | 21 #endif |
21 | 22 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 // byte[32] parent_spki_sha256 | 65 // byte[32] parent_spki_sha256 |
65 // uint32le num_serials | 66 // uint32le num_serials |
66 // [num_serials] { | 67 // [num_serials] { |
67 // uint8 serial_length; | 68 // uint8 serial_length; |
68 // byte[serial_length] serial; | 69 // byte[serial_length] serial; |
69 // } | 70 // } |
70 // | 71 // |
71 // header_bytes consists of a JSON dictionary with the following keys: | 72 // header_bytes consists of a JSON dictionary with the following keys: |
72 // Version (int): currently 0 | 73 // Version (int): currently 0 |
73 // ContentType (string): "CRLSet" or "CRLSetDelta" (magic value) | 74 // ContentType (string): "CRLSet" or "CRLSetDelta" (magic value) |
74 // DeltaFrom (int32): if this is a delta update (see below), then this contain
s | 75 // DeltaFrom (int32): if this is a delta update (see below), then this |
75 // the sequence number of the base CRLSet. | 76 // contains the sequence number of the base CRLSet. |
76 // Sequence (int32): the monotonic sequence number of this CRL set. | 77 // Sequence (int32): the monotonic sequence number of this CRL set. |
77 // | 78 // |
78 // A delta CRLSet is similar to a CRLSet: | 79 // A delta CRLSet is similar to a CRLSet: |
79 // | 80 // |
80 // struct CompressedChanges { | 81 // struct CompressedChanges { |
81 // uint32le uncompressed_size | 82 // uint32le uncompressed_size |
82 // uint32le compressed_size | 83 // uint32le compressed_size |
83 // byte[compressed_size] zlib_data | 84 // byte[compressed_size] zlib_data |
84 // } | 85 // } |
85 // | 86 // |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 return false; | 435 return false; |
435 if (i != crls_.size()) | 436 if (i != crls_.size()) |
436 return false; | 437 return false; |
437 | 438 |
438 *out_crl_set = crl_set; | 439 *out_crl_set = crl_set; |
439 return true; | 440 return true; |
440 } | 441 } |
441 | 442 |
442 // static | 443 // static |
443 bool CRLSet::GetIsDeltaUpdate(const base::StringPiece& in_data, | 444 bool CRLSet::GetIsDeltaUpdate(const base::StringPiece& in_data, |
444 bool *is_delta) { | 445 bool* is_delta) { |
445 base::StringPiece data(in_data); | 446 base::StringPiece data(in_data); |
446 scoped_ptr<base::DictionaryValue> header_dict(ReadHeader(&data)); | 447 scoped_ptr<base::DictionaryValue> header_dict(ReadHeader(&data)); |
447 if (!header_dict.get()) | 448 if (!header_dict.get()) |
448 return false; | 449 return false; |
449 | 450 |
450 std::string contents; | 451 std::string contents; |
451 if (!header_dict->GetString("ContentType", &contents)) | 452 if (!header_dict->GetString("ContentType", &contents)) |
452 return false; | 453 return false; |
453 | 454 |
454 if (contents == "CRLSet") { | 455 if (contents == "CRLSet") { |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
588 return new CRLSet; | 589 return new CRLSet; |
589 } | 590 } |
590 | 591 |
591 CRLSet* CRLSet::ExpiredCRLSetForTesting() { | 592 CRLSet* CRLSet::ExpiredCRLSetForTesting() { |
592 CRLSet* crl_set = new CRLSet; | 593 CRLSet* crl_set = new CRLSet; |
593 crl_set->not_after_ = 1; | 594 crl_set->not_after_ = 1; |
594 return crl_set; | 595 return crl_set; |
595 } | 596 } |
596 | 597 |
597 } // namespace net | 598 } // namespace net |
OLD | NEW |