OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 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 | 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 "net/base/dnssec_chain_verifier.h" | 5 #include "net/base/dnssec_chain_verifier.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/scoped_ptr.h" | 8 #include "base/scoped_ptr.h" |
9 #include "base/sha1.h" | 9 #include "base/sha1.h" |
10 #include "base/sha2.h" | 10 #include "base/sha2.h" |
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
482 bool DNSSECChainVerifier::ReadDNSKEYs(std::vector<base::StringPiece>* out, | 482 bool DNSSECChainVerifier::ReadDNSKEYs(std::vector<base::StringPiece>* out, |
483 bool is_root) { | 483 bool is_root) { |
484 uint8 num_keys; | 484 uint8 num_keys; |
485 if (!U8(&num_keys)) | 485 if (!U8(&num_keys)) |
486 return false; | 486 return false; |
487 | 487 |
488 for (unsigned i = 0; i < num_keys; i++) { | 488 for (unsigned i = 0; i < num_keys; i++) { |
489 base::StringPiece key; | 489 base::StringPiece key; |
490 if (!VariableLength16(&key)) | 490 if (!VariableLength16(&key)) |
491 return false; | 491 return false; |
492 if (key.size() == 0) { | 492 if (key.empty()) { |
493 if (!is_root) | 493 if (!is_root) |
494 return false; | 494 return false; |
495 key = base::StringPiece(reinterpret_cast<const char*>(kRootKey), | 495 key = base::StringPiece(reinterpret_cast<const char*>(kRootKey), |
496 sizeof(kRootKey)); | 496 sizeof(kRootKey)); |
497 } | 497 } |
498 | 498 |
499 out->push_back(key); | 499 out->push_back(key); |
500 } | 500 } |
501 | 501 |
502 return true; | 502 return true; |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
590 base::StringPiece sig; | 590 base::StringPiece sig; |
591 if (!U8(&entry_key) || | 591 if (!U8(&entry_key) || |
592 !VariableLength16(&sig)) { | 592 !VariableLength16(&sig)) { |
593 return BAD_DATA; | 593 return BAD_DATA; |
594 } | 594 } |
595 | 595 |
596 base::StringPiece key; | 596 base::StringPiece key; |
597 if (!ReadAheadKey(&key, entry_key)) | 597 if (!ReadAheadKey(&key, entry_key)) |
598 return BAD_DATA; | 598 return BAD_DATA; |
599 | 599 |
600 if (zone.size() == 1 && key.size() == 0) { | 600 if (zone.size() == 1 && key.empty()) { |
601 // If a key is omitted in the root zone then it's the root key. | 601 // If a key is omitted in the root zone then it's the root key. |
602 key = base::StringPiece(reinterpret_cast<const char*>(kRootKey), | 602 key = base::StringPiece(reinterpret_cast<const char*>(kRootKey), |
603 sizeof(kRootKey)); | 603 sizeof(kRootKey)); |
604 } | 604 } |
605 if (!current_zone_->trusted_keys.AddKey(key)) | 605 if (!current_zone_->trusted_keys.AddKey(key)) |
606 return BAD_DATA; | 606 return BAD_DATA; |
607 | 607 |
608 std::vector<base::StringPiece> dnskeys; | 608 std::vector<base::StringPiece> dnskeys; |
609 if (!ReadDNSKEYs(&dnskeys, zone.size() == 1)) | 609 if (!ReadDNSKEYs(&dnskeys, zone.size() == 1)) |
610 return BAD_DATA; | 610 return BAD_DATA; |
611 | 611 |
612 if (sig.size() == 0) { | 612 if (sig.empty()) { |
613 // An omitted signature on the keys means that only the entry key is used. | 613 // An omitted signature on the keys means that only the entry key is used. |
614 if (dnskeys.size() > 1 || entry_key != 0) | 614 if (dnskeys.size() > 1 || entry_key != 0) |
615 return BAD_DATA; | 615 return BAD_DATA; |
616 return OK; | 616 return OK; |
617 } | 617 } |
618 | 618 |
619 if (!current_zone_->trusted_keys.CheckSignature( | 619 if (!current_zone_->trusted_keys.CheckSignature( |
620 zone, zone, sig, kDNS_DNSKEY, dnskeys)) { | 620 zone, zone, sig, kDNS_DNSKEY, dnskeys)) { |
621 return BAD_SIGNATURE; | 621 return BAD_SIGNATURE; |
622 } | 622 } |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
804 base::StringPiece name; | 804 base::StringPiece name; |
805 if (!ReadName(&name)) | 805 if (!ReadName(&name)) |
806 return BAD_DATA; | 806 return BAD_DATA; |
807 | 807 |
808 rrdatas->resize(1); | 808 rrdatas->resize(1); |
809 (*rrdatas)[0] = name; | 809 (*rrdatas)[0] = name; |
810 return OK; | 810 return OK; |
811 } | 811 } |
812 | 812 |
813 } // namespace net | 813 } // namespace net |
OLD | NEW |