| 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" |
| (...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 } else if (contents == "CRLSetDelta") { | 452 } else if (contents == "CRLSetDelta") { |
| 453 *is_delta = true; | 453 *is_delta = true; |
| 454 } else { | 454 } else { |
| 455 return false; | 455 return false; |
| 456 } | 456 } |
| 457 | 457 |
| 458 return true; | 458 return true; |
| 459 } | 459 } |
| 460 | 460 |
| 461 std::string CRLSet::Serialize() const { | 461 std::string CRLSet::Serialize() const { |
| 462 std::string header = StringPrintf( | 462 std::string header = base::StringPrintf( |
| 463 "{" | 463 "{" |
| 464 "\"Version\":0," | 464 "\"Version\":0," |
| 465 "\"ContentType\":\"CRLSet\"," | 465 "\"ContentType\":\"CRLSet\"," |
| 466 "\"Sequence\":%u," | 466 "\"Sequence\":%u," |
| 467 "\"DeltaFrom\":0," | 467 "\"DeltaFrom\":0," |
| 468 "\"NumParents\":%u," | 468 "\"NumParents\":%u," |
| 469 "\"BlockedSPKIs\":[", | 469 "\"BlockedSPKIs\":[", |
| 470 static_cast<unsigned>(sequence_), | 470 static_cast<unsigned>(sequence_), |
| 471 static_cast<unsigned>(crls_.size())); | 471 static_cast<unsigned>(crls_.size())); |
| 472 | 472 |
| 473 for (std::vector<std::string>::const_iterator i = blocked_spkis_.begin(); | 473 for (std::vector<std::string>::const_iterator i = blocked_spkis_.begin(); |
| 474 i != blocked_spkis_.end(); ++i) { | 474 i != blocked_spkis_.end(); ++i) { |
| 475 std::string spki_hash_base64; | 475 std::string spki_hash_base64; |
| 476 base::Base64Encode(*i, &spki_hash_base64); | 476 base::Base64Encode(*i, &spki_hash_base64); |
| 477 | 477 |
| 478 if (i != blocked_spkis_.begin()) | 478 if (i != blocked_spkis_.begin()) |
| 479 header += ","; | 479 header += ","; |
| 480 header += "\"" + spki_hash_base64 + "\""; | 480 header += "\"" + spki_hash_base64 + "\""; |
| 481 } | 481 } |
| 482 header += "]"; | 482 header += "]"; |
| 483 if (not_after_ != 0) | 483 if (not_after_ != 0) |
| 484 header += StringPrintf(",\"NotAfter\":%" PRIu64, not_after_); | 484 header += base::StringPrintf(",\"NotAfter\":%" PRIu64, not_after_); |
| 485 header += "}"; | 485 header += "}"; |
| 486 | 486 |
| 487 size_t len = 2 /* header len */ + header.size(); | 487 size_t len = 2 /* header len */ + header.size(); |
| 488 | 488 |
| 489 for (CRLList::const_iterator i = crls_.begin(); i != crls_.end(); ++i) { | 489 for (CRLList::const_iterator i = crls_.begin(); i != crls_.end(); ++i) { |
| 490 len += i->first.size() + 4 /* num serials */; | 490 len += i->first.size() + 4 /* num serials */; |
| 491 for (std::vector<std::string>::const_iterator j = i->second.begin(); | 491 for (std::vector<std::string>::const_iterator j = i->second.begin(); |
| 492 j != i->second.end(); ++j) { | 492 j != i->second.end(); ++j) { |
| 493 len += 1 /* serial length */ + j->size(); | 493 len += 1 /* serial length */ + j->size(); |
| 494 } | 494 } |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 584 return new CRLSet; | 584 return new CRLSet; |
| 585 } | 585 } |
| 586 | 586 |
| 587 CRLSet* CRLSet::ExpiredCRLSetForTesting() { | 587 CRLSet* CRLSet::ExpiredCRLSetForTesting() { |
| 588 CRLSet* crl_set = new CRLSet; | 588 CRLSet* crl_set = new CRLSet; |
| 589 crl_set->not_after_ = 1; | 589 crl_set->not_after_ = 1; |
| 590 return crl_set; | 590 return crl_set; |
| 591 } | 591 } |
| 592 | 592 |
| 593 } // namespace net | 593 } // namespace net |
| OLD | NEW |