diff options
-rw-r--r-- | net/base/dns_util.h | 1 | ||||
-rw-r--r-- | net/base/dnssec_chain_verifier.cc | 89 | ||||
-rw-r--r-- | net/base/dnssec_chain_verifier.h | 9 | ||||
-rw-r--r-- | net/base/dnssec_unittest.cc | 205 | ||||
-rw-r--r-- | net/net.gyp | 10 | ||||
-rw-r--r-- | net/socket/ssl_client_socket_nss.cc | 10 | ||||
-rw-r--r-- | net/tools/dnssec_chain_verify/dnssec_chain_verify.cc | 108 |
7 files changed, 399 insertions, 33 deletions
diff --git a/net/base/dns_util.h b/net/base/dns_util.h index 78dca47..c91587d 100644 --- a/net/base/dns_util.h +++ b/net/base/dns_util.h @@ -29,6 +29,7 @@ std::string TrimEndingDot(const std::string& host); // DNS resource record types. See // http://www.iana.org/assignments/dns-parameters +static const uint16 kDNS_CNAME = 5; static const uint16 kDNS_TXT = 16; static const uint16 kDNS_CERT = 37; static const uint16 kDNS_DS = 43; diff --git a/net/base/dnssec_chain_verifier.cc b/net/base/dnssec_chain_verifier.cc index 711c17e..a32c683 100644 --- a/net/base/dnssec_chain_verifier.cc +++ b/net/base/dnssec_chain_verifier.cc @@ -146,6 +146,7 @@ DNSSECChainVerifier::DNSSECChainVerifier(const std::string& target, chain_(chain), ignore_timestamps_(false), valid_(false), + already_entered_zone_(false), rrtype_(0) { } @@ -184,9 +185,13 @@ DNSSECChainVerifier::Error DNSSECChainVerifier::Verify() { break; } - err = EnterZone(next_name); - if (err != OK) - return err; + if (already_entered_zone_) { + already_entered_zone_ = false; + } else { + err = EnterZone(next_name); + if (err != OK) + return err; + } } return OK; @@ -453,6 +458,19 @@ DNSSECChainVerifier::Error DNSSECChainVerifier::EnterZone( return OK; } +// CountLabels returns the number of DNS labels in |a|, which must be in DNS, +// length-prefixed form. +static unsigned CountLabels(base::StringPiece a) { + for (unsigned c = 0;; c++) { + if (!a.size()) + return c; + uint8 label_len = a.data()[0]; + a.remove_prefix(1); + DCHECK_GE(a.size(), label_len); + a.remove_prefix(label_len); + } +} + // LeaveZone transitions out of the current zone, either by following DS // records to validate the entry key of the next zone, or because the final // resource records are given. @@ -472,10 +490,11 @@ DNSSECChainVerifier::Error DNSSECChainVerifier::LeaveZone( if (rrtype == kDNS_DS) { err = ReadDSSet(&rrdatas, *next_name); - } else if (rrtype == kDNS_CERT) { - err = ReadCERTs(&rrdatas); + } else if (rrtype == kDNS_CERT || rrtype == kDNS_TXT) { + err = ReadGenericRRs(&rrdatas); + } else if (rrtype == kDNS_CNAME) { + err = ReadCNAME(&rrdatas); } else { - // TODO(agl): add CNAME support. return UNKNOWN_TERMINAL_RRTYPE; } if (err != OK) @@ -491,7 +510,7 @@ DNSSECChainVerifier::Error DNSSECChainVerifier::LeaveZone( // 'closer' to the target than the current zone. if (MatchingLabels(target_, *next_name) <= current_zone_->matching_labels) return OFF_COURSE; - } else if (rrtype == kDNS_CERT) { + } else if (rrtype == kDNS_CERT || rrtype == kDNS_TXT) { // If this is the final entry in the chain then the name must match target_ if (next_name->size() != target_.size() || memcmp(next_name->data(), target_.data(), target_.size())) { @@ -500,6 +519,28 @@ DNSSECChainVerifier::Error DNSSECChainVerifier::LeaveZone( rrdatas_ = rrdatas; valid_ = true; rrtype_ = rrtype; + } else if (rrtype == kDNS_CNAME) { + // A CNAME must match the current target. Then we update the current target + // and unwind the chain to the closest common ancestor. + if (next_name->size() != target_.size() || + memcmp(next_name->data(), target_.data(), target_.size())) { + return BAD_TARGET; + } + DCHECK_EQ(1u, rrdatas.size()); + target_ = rrdatas[0].as_string(); + // We unwind the zones until the current zone is a (non-strict) subset of + // the new target. + while (MatchingLabels(target_, current_zone_->name) < + CountLabels(current_zone_->name)) { + Zone* prev = current_zone_->prev; + delete current_zone_; + current_zone_ = prev; + if (!current_zone_) { + NOTREACHED(); + return BAD_DATA; + } + } + already_entered_zone_ = true; } else { NOTREACHED(); return UNKNOWN_TERMINAL_RRTYPE; @@ -581,14 +622,14 @@ DNSSECChainVerifier::Error DNSSECChainVerifier::ReadDSSet( return OK; } -DNSSECChainVerifier::Error DNSSECChainVerifier::ReadCERTs( +DNSSECChainVerifier::Error DNSSECChainVerifier::ReadGenericRRs( std::vector<base::StringPiece>* rrdatas) { - uint8 num_certs; - if (!U8(&num_certs)) + uint8 num_rrs; + if (!U8(&num_rrs)) return BAD_DATA; - rrdatas->resize(num_certs); + rrdatas->resize(num_rrs); - for (unsigned i = 0; i < num_certs; i++) { + for (unsigned i = 0; i < num_rrs; i++) { base::StringPiece rrdata; if (!VariableLength16(&rrdata)) return BAD_DATA; @@ -598,6 +639,17 @@ DNSSECChainVerifier::Error DNSSECChainVerifier::ReadCERTs( return OK; } +DNSSECChainVerifier::Error DNSSECChainVerifier::ReadCNAME( + std::vector<base::StringPiece>* rrdatas) { + base::StringPiece name; + if (!ReadName(&name)) + return BAD_DATA; + + rrdatas->resize(1); + (*rrdatas)[0] = name; + return OK; +} + // static std::map<std::string, std::string> DNSSECChainVerifier::ParseTLSTXTRecord(base::StringPiece rrdata) { @@ -687,19 +739,6 @@ DNSSECChainVerifier::ParseTLSTXTRecord(base::StringPiece rrdata) { return ret; } -// CountLabels returns the number of DNS labels in |a|, which must be in DNS, -// length-prefixed form. -static unsigned CountLabels(base::StringPiece a) { - for (unsigned c = 0;; c++) { - if (!a.size()) - return c; - uint8 label_len = a.data()[0]; - a.remove_prefix(1); - DCHECK_GE(a.size(), label_len); - a.remove_prefix(label_len); - } -} - // RemoveLeadingLabel removes the first label from |a|, which must be in DNS, // length-prefixed form. static void RemoveLeadingLabel(base::StringPiece* a) { diff --git a/net/base/dnssec_chain_verifier.h b/net/base/dnssec_chain_verifier.h index 096dea1..d896c6c 100644 --- a/net/base/dnssec_chain_verifier.h +++ b/net/base/dnssec_chain_verifier.h @@ -96,14 +96,17 @@ class DNSSECChainVerifier { Error LeaveZone(base::StringPiece* next_name); Error ReadDSSet(std::vector<base::StringPiece>*, const base::StringPiece& next_name); - Error ReadCERTs(std::vector<base::StringPiece>*); - + Error ReadGenericRRs(std::vector<base::StringPiece>*); + Error ReadCNAME(std::vector<base::StringPiece>*); Zone* current_zone_; - const std::string target_; + std::string target_; base::StringPiece chain_; bool ignore_timestamps_; bool valid_; + // already_entered_zone_ is set to true when we unwind a Zone chain and start + // off from a point where we have already entered a zone. + bool already_entered_zone_; uint16 rrtype_; std::vector<base::StringPiece> rrdatas_; // A list of pointers which need to be free()ed on destruction. diff --git a/net/base/dnssec_unittest.cc b/net/base/dnssec_unittest.cc index 4181e09..f95c771 100644 --- a/net/base/dnssec_unittest.cc +++ b/net/base/dnssec_unittest.cc @@ -359,6 +359,202 @@ static const unsigned char kChain[] = { 0xeb, 0xdd, 0xe5, 0xc7, 0x1d, 0x16, 0xa2, 0x45, 0x1c, }; +// kCNAMEChain is a chain which proves that www.dnssec-exp.org is a CNAME to +// dnssec-exp.org and then proves a TXT record on dnssec-exp.org. +static const unsigned char kCNAMEChain[] = { + 0x4a, 0x5c, 0x01, 0x01, 0x10, 0x08, 0x00, 0x00, 0x01, 0x51, 0x80, 0x4c, 0x8e, + 0xba, 0xff, 0x4c, 0x7a, 0xf4, 0x80, 0x4a, 0x5c, 0x6d, 0xe6, 0xa7, 0xaa, 0x97, + 0xca, 0x48, 0x4a, 0x49, 0xbb, 0xff, 0x91, 0x1a, 0xd8, 0xc2, 0x55, 0x0d, 0x80, + 0x1c, 0x83, 0x41, 0x2b, 0x89, 0x70, 0x87, 0xd9, 0x3a, 0x23, 0x9f, 0xdc, 0xa4, + 0xb6, 0x0c, 0xe3, 0x3a, 0x5a, 0xbe, 0xfc, 0x2b, 0xcb, 0xb7, 0x14, 0xbd, 0xbf, + 0x43, 0xaa, 0x03, 0x34, 0xe8, 0x84, 0x18, 0x2e, 0x95, 0x0e, 0x77, 0xb1, 0xe2, + 0x74, 0x86, 0xd8, 0xc3, 0x9c, 0xdc, 0x00, 0x80, 0x8c, 0x92, 0xfc, 0x92, 0xfe, + 0x25, 0xe3, 0x6d, 0x94, 0xe5, 0xc4, 0x08, 0x18, 0xf7, 0xc2, 0x96, 0xde, 0x8c, + 0x85, 0x73, 0x22, 0x0d, 0x03, 0x7a, 0xe0, 0xa9, 0x51, 0x27, 0x24, 0xbc, 0xf8, + 0xbf, 0x63, 0x52, 0xef, 0xbd, 0xb8, 0x07, 0xe8, 0xf6, 0xaa, 0x3d, 0x02, 0x28, + 0xfe, 0x44, 0xd4, 0xe4, 0x04, 0x10, 0x61, 0x95, 0x6c, 0x87, 0x06, 0x2a, 0x5c, + 0xdb, 0x67, 0x0d, 0xac, 0x1a, 0x02, 0x2e, 0x66, 0x35, 0x08, 0x28, 0x29, 0x24, + 0x8e, 0xad, 0x4c, 0x3b, 0x6a, 0x99, 0x88, 0xd6, 0x32, 0xa6, 0x7d, 0xc3, 0x0c, + 0x3d, 0xbc, 0x0b, 0xff, 0x86, 0x8d, 0xc6, 0x50, 0x8b, 0xad, 0x1f, 0x1f, 0xf7, + 0x06, 0xc5, 0x9e, 0x0c, 0x6f, 0xbb, 0x3c, 0x02, 0x5c, 0x67, 0xa7, 0xaf, 0x53, + 0x63, 0x5a, 0xae, 0x99, 0x47, 0x93, 0x61, 0xc8, 0x4f, 0xfb, 0x03, 0xec, 0xfe, + 0xa3, 0xc1, 0xee, 0x45, 0xf8, 0x56, 0x73, 0x88, 0xf4, 0x14, 0x6d, 0x96, 0x7c, + 0xdc, 0x88, 0x01, 0x99, 0x04, 0x18, 0x3d, 0x42, 0x56, 0x57, 0x54, 0xd7, 0xed, + 0xf8, 0x6b, 0x46, 0xff, 0x01, 0xe6, 0x1a, 0x75, 0x37, 0xd4, 0xf6, 0xb2, 0x57, + 0x61, 0x6b, 0xbf, 0x24, 0x99, 0x6d, 0xcd, 0x63, 0xc6, 0x45, 0xd0, 0x0a, 0x93, + 0x5c, 0xbb, 0xd3, 0x36, 0xac, 0xfa, 0x57, 0x51, 0xa0, 0xcf, 0x32, 0x0e, 0xb3, + 0x57, 0xf3, 0x02, 0x77, 0x02, 0x00, 0x88, 0x01, 0x00, 0x03, 0x08, 0x03, 0x01, +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x80, 0xb6, 0x9e, 0xa9, 0xd9, 0x31, 0x61, 0xb9, 0x69, 0x9c, 0xf2, 0xe8, 0xc5, + 0xa0, 0xfd, 0x07, 0x59, 0x87, 0x38, 0xff, 0x25, 0x04, 0x00, 0x88, 0x01, 0x00, + 0x03, 0x07, 0x03, 0x01, 0x00, 0x01, 0x80, 0x97, 0x87, 0xf6, 0x40, 0x06, 0x2f, + 0x24, 0x88, 0x92, 0x03, 0x5d, 0x89, 0xb2, 0x52, 0x51, 0xf3, 0x0b, 0x40, 0x87, + 0x78, 0x1c, 0xea, 0x72, 0x9c, 0x99, 0x00, 0x88, 0xc2, 0xed, 0xd2, 0xb5, 0xc2, + 0x44, 0x58, 0x55, 0xc5, 0x2f, 0x22, 0x5a, 0x53, 0x3a, 0x99, 0xce, 0x55, 0x57, + 0xdc, 0x0b, 0x73, 0xf2, 0xf5, 0x48, 0xbf, 0xc7, 0x8e, 0x6a, 0x29, 0xbd, 0x0b, + 0xca, 0xdb, 0xca, 0xed, 0x66, 0x00, 0x7b, 0x75, 0xb2, 0x38, 0xec, 0x24, 0xe6, + 0x49, 0x70, 0x22, 0xa4, 0x42, 0xff, 0x4a, 0x78, 0x96, 0xe6, 0x9f, 0x6d, 0xdd, + 0xb2, 0x85, 0x13, 0x05, 0xee, 0xab, 0x8e, 0x05, 0x5a, 0x98, 0xac, 0xba, 0x07, + 0xc2, 0xff, 0x22, 0xf4, 0xba, 0xd5, 0xfa, 0xbf, 0x1d, 0x84, 0x1e, 0xeb, 0x5e, + 0xff, 0xe5, 0x91, 0x34, 0x88, 0xea, 0x61, 0x19, 0xb2, 0x0e, 0x6b, 0x0d, 0xf7, + 0x9e, 0xf1, 0x8c, 0xb5, 0x00, 0x88, 0x01, 0x00, 0x03, 0x07, 0x03, 0x01, 0x00, + 0x01, 0xc9, 0x06, 0x00, 0x53, 0x45, 0x4a, 0x0b, 0xb8, 0xe2, 0xb0, 0x4e, 0x29, + 0xc8, 0x19, 0xb4, 0xa3, 0x63, 0x27, 0xe2, 0xcd, 0xc7, 0xc7, 0x6d, 0x60, 0x31, + 0xeb, 0xc0, 0x82, 0x5f, 0x44, 0x14, 0x96, 0x60, 0x4e, 0xc8, 0x62, 0xf4, 0xcc, + 0xb9, 0x99, 0x7a, 0x19, 0xf0, 0xaf, 0x34, 0xd9, 0x63, 0xca, 0x40, 0xe3, 0x7b, + 0xb6, 0xbc, 0xfa, 0x40, 0x08, 0x1d, 0xe7, 0xc3, 0xa4, 0xd2, 0x73, 0x3a, 0x32, + 0xf2, 0xa4, 0x4c, 0x3c, 0x4f, 0xd6, 0x52, 0x52, 0xc8, 0x6d, 0xa5, 0xf6, 0xd9, + 0x4d, 0x0c, 0xfd, 0xb4, 0x93, 0x8b, 0x61, 0x72, 0xdb, 0x6e, 0x5f, 0x2d, 0xd9, + 0x2d, 0xab, 0x18, 0x2f, 0x87, 0x2d, 0xbf, 0x8d, 0x42, 0x37, 0x93, 0x41, 0x18, + 0xf6, 0x93, 0x97, 0xda, 0x27, 0x31, 0xdc, 0xda, 0xec, 0x21, 0x16, 0x61, 0xe1, + 0xe0, 0x7a, 0x53, 0x26, 0x82, 0xc7, 0x62, 0x99, 0x18, 0x81, 0x6a, 0x65, 0x01, + 0x08, 0x01, 0x01, 0x03, 0x07, 0x03, 0x01, 0x00, 0x01, 0x8a, 0x58, 0x7e, 0x3d, + 0xda, 0x69, 0x1c, 0xf3, 0x93, 0x15, 0x90, 0xa8, 0xc7, 0x65, 0xed, 0x81, 0x31, + 0x63, 0xcd, 0x4d, 0x75, 0x84, 0xaf, 0xfa, 0xa6, 0xb2, 0xb9, 0x90, 0xe8, 0x76, + 0x76, 0x7d, 0x20, 0xc8, 0x74, 0x6f, 0x03, 0x1c, 0x61, 0xa5, 0x54, 0x77, 0x33, + 0x40, 0x6d, 0x57, 0x89, 0xf2, 0x07, 0x7a, 0x8e, 0xad, 0x6c, 0x47, 0x75, 0x6f, + 0x3f, 0xf4, 0x91, 0xdf, 0xa9, 0xa6, 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e, 0x21, 0x2f, 0x58, 0xc8, 0x47, 0x67, 0x89, + 0x63, 0x25, 0xe5, 0xac, 0x0a, 0x16, 0xc5, 0xdc, 0xf1, 0x71, 0x6f, 0xff, 0xe7, + 0x27, 0x8b, 0xe5, 0x15, 0x56, 0xba, 0x14, 0x71, 0x7a, 0x39, 0xa7, 0x49, 0x59, + 0xc2, 0xbb, 0x19, 0x1f, 0x4b, 0x80, 0x10, 0xe3, 0xce, 0x4a, 0x1f, 0x6b, 0x69, + 0x75, 0xb5, 0x9c, 0x0a, 0x8a, 0x4b, 0x25, 0x9b, 0x3a, 0xb7, 0x0f, 0x2a, 0xde, + 0x35, 0x9c, 0xa5, 0x31, 0xb3, 0x76, 0x1f, 0xef, 0xdf, 0x17, 0x58, 0x7c, 0xda, + 0x50, 0x35, 0xc3, 0xc8, 0x98, 0x59, 0x71, 0x02, 0xe9, 0xf7, 0x06, 0xd3, 0x91, + 0x3c, 0x0d, 0xab, 0xf2, 0xd8, 0xba, 0x30, 0xda, 0x09, 0x10, 0x75, 0x0a, 0x64, + 0x6e, 0x73, 0x73, 0x65, 0x63, 0x2d, 0x65, 0x78, 0x70, 0x03, 0x6f, 0x72, 0x67, + 0x00, 0x00, 0x2b, 0x00, 0x90, 0x07, 0x02, 0x00, 0x01, 0x51, 0x80, 0x4c, 0x90, + 0xea, 0x0d, 0x4c, 0x7e, 0x66, 0xfd, 0x93, 0xb4, 0x39, 0xee, 0x27, 0x29, 0x54, + 0x9e, 0x57, 0x41, 0x12, 0x60, 0x19, 0xf6, 0x3f, 0xa6, 0xba, 0xd6, 0x41, 0x98, + 0x57, 0xec, 0x30, 0x9e, 0x96, 0x08, 0x8c, 0x13, 0xa9, 0x76, 0x95, 0x74, 0xcd, + 0xcd, 0x2e, 0xa6, 0x22, 0x21, 0x44, 0x3f, 0x13, 0xdf, 0x7a, 0x33, 0xf1, 0x8c, + 0x4c, 0xf9, 0xa3, 0x6d, 0x50, 0x38, 0xfa, 0x71, 0x7b, 0x7a, 0xfe, 0x54, 0xa9, + 0x44, 0x81, 0x8c, 0xd5, 0x04, 0x9e, 0x46, 0x89, 0xda, 0x26, 0x43, 0x40, 0xf6, + 0xd7, 0x23, 0x48, 0x07, 0x0e, 0x48, 0x2e, 0x19, 0x0d, 0x41, 0x27, 0x85, 0x75, + 0x1e, 0xa0, 0xa9, 0xad, 0x39, 0xaf, 0x8d, 0xc1, 0xed, 0xc5, 0x93, 0x73, 0x05, + 0x09, 0x7a, 0x8f, 0xf0, 0x97, 0xc3, 0x98, 0xab, 0xcc, 0x7c, 0xbf, 0x48, 0xef, + 0xea, 0x34, 0xf3, 0xe6, 0x5d, 0x8d, 0x1b, 0xbe, 0x43, 0x97, 0x56, 0x4e, 0x60, + 0x9f, 0xdd, 0x1b, 0xf5, 0x15, 0x6c, 0x01, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x00, 0xa8, 0x01, 0x00, 0x03, 0x05, 0x03, 0x01, 0x00, 0x01, 0xd0, 0x0a, + 0x64, 0x8e, 0xb5, 0x90, 0x0b, 0x75, 0xc2, 0xeb, 0x52, 0x5f, 0xa4, 0xcb, 0xeb, + 0x1d, 0x77, 0x8d, 0x84, 0x2c, 0xef, 0xb6, 0x88, 0xd4, 0x7c, 0x50, 0x4c, 0x52, + 0x7b, 0x9d, 0x37, 0x31, 0x36, 0xb2, 0x5b, 0x6c, 0x47, 0xb4, 0x21, 0x80, 0x61, + 0x46, 0xfa, 0x5b, 0x44, 0x50, 0x91, 0x9d, 0xf8, 0xc1, 0x78, 0x00, 0x78, 0x29, + 0xfe, 0xe2, 0x08, 0x65, 0xf8, 0xc9, 0xdf, 0x69, 0x0b, 0x59, 0x6b, 0xf4, 0x93, + 0x9f, 0x8b, 0x25, 0x0b, 0x6b, 0x93, 0x12, 0x06, 0x57, 0xc8, 0x04, 0x9d, 0x3f, + 0x33, 0xbd, 0x2b, 0x35, 0x54, 0xb9, 0x98, 0x75, 0xe4, 0xb0, 0x49, 0x3c, 0x29, + 0xc1, 0xfb, 0x74, 0xbc, 0x91, 0x82, 0x9e, 0xc5, 0x61, 0xa6, 0x16, 0xe1, 0xf0, + 0x8f, 0xe9, 0xe1, 0x23, 0x55, 0x5e, 0xfb, 0xf1, 0xcc, 0x8a, 0x75, 0x5d, 0xf2, + 0x86, 0x89, 0x0a, 0x29, 0xcb, 0xca, 0x33, 0xde, 0x9d, 0x74, 0x43, 0x0d, 0xde, + 0x67, 0xde, 0x71, 0x0f, 0x7f, 0xa3, 0xbb, 0x22, 0x82, 0x81, 0x66, 0xd1, 0xbd, + 0x49, 0x0d, 0x89, 0x45, 0xd7, 0x18, 0xcf, 0x98, 0x2c, 0x19, 0xaf, 0x63, 0x16, + 0x20, 0x91, 0x03, 0x77, 0x77, 0x77, 0x0a, 0x64, 0x6e, 0x73, 0x73, 0x65, 0x63, + 0x2d, 0x65, 0x78, 0x70, 0x03, 0x6f, 0x72, 0x67, 0x00, 0x00, 0x05, 0x00, 0xb0, + 0x05, 0x03, 0x00, 0x00, 0x00, 0x3c, 0x4c, 0xae, 0xeb, 0xfc, 0x4c, 0x87, 0x59, + 0xf6, 0x83, 0x7f, 0x01, 0x90, 0xde, 0x40, 0xa3, 0x42, 0x73, 0x59, 0xb7, 0xc7, + 0x3a, 0xe1, 0x01, 0xae, 0x5c, 0x0f, 0xd4, 0x22, 0x9d, 0xb5, 0x88, 0xb8, 0xbb, + 0x14, 0x95, 0x7f, 0xfa, 0xa7, 0xff, 0x48, 0x30, 0x90, 0x4c, 0x1b, 0x71, 0x33, + 0x1c, 0x36, 0xbc, 0xaf, 0xae, 0x1d, 0x97, 0xec, 0xee, 0x71, 0xb8, 0xb1, 0x2a, + 0x19, 0xd7, 0xf3, 0x25, 0x78, 0x94, 0x59, 0x54, 0xbb, 0x2b, 0xac, 0xe6, 0x3c, + 0x3e, 0x7e, 0x43, 0x7c, 0x2d, 0xc0, 0x72, 0x58, 0xe8, 0x4a, 0xa2, 0xed, 0x1f, + 0x39, 0x5f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x83, 0xda, 0x7d, 0xcd, 0x2d, 0x4d, 0x9b, 0xe3, 0x66, 0x92, 0xb9, + 0x21, 0x96, 0xbf, 0xea, 0x70, 0x55, 0xbf, 0xb3, 0xb0, 0x85, 0x90, 0x72, 0x5f, + 0x09, 0xd1, 0x7c, 0x49, 0x25, 0x07, 0x79, 0x34, 0x48, 0xe7, 0x1c, 0xaa, 0x53, + 0x33, 0xcb, 0x62, 0xb9, 0x9f, 0x42, 0x6e, 0x36, 0x00, 0x31, 0xab, 0x9f, 0xcc, + 0xf5, 0xa9, 0x02, 0x2f, 0x75, 0x4c, 0xf1, 0xd6, 0x86, 0x3a, 0x7f, 0x08, 0xe4, + 0x72, 0x7d, 0x34, 0xe0, 0x40, 0x76, 0xd1, 0xf0, 0xe3, 0x98, 0x37, 0xe7, 0x93, + 0x94, 0x57, 0x95, 0x6c, 0xde, 0x9e, 0x17, 0x57, 0x3a, 0x78, 0xe9, 0x8b, 0x57, + 0x7f, 0x74, 0xe2, 0xaf, 0xf8, 0xaf, 0x11, 0x64, 0xa9, 0xe9, 0xdb, 0xb2, 0x58, + 0xda, 0x7c, 0xfe, 0x3f, 0x52, 0x06, 0x39, 0xfc, 0xdd, 0x1c, 0x1c, 0x01, 0x00, + 0x3a, 0x39, 0x76, 0x3d, 0x74, 0x6c, 0x73, 0x31, 0x20, 0x68, 0x61, 0x3d, 0x73, + 0x68, 0x61, 0x31, 0x20, 0x68, 0x3d, 0x31, 0x30, 0x39, 0x63, 0x38, 0x31, 0x34, + 0x36, 0x33, 0x30, 0x34, 0x64, 0x65, 0x37, 0x63, 0x34, 0x63, 0x38, 0x37, 0x30, + 0x35, 0x62, 0x63, 0x63, 0x31, 0x64, 0x38, 0x61, 0x32, 0x63, 0x32, 0x33, 0x37, + 0x66, 0x30, 0x35, 0x35, 0x38, 0x64, 0x37, +}; + TEST(DNSSECChainVerifierTest, TestChain) { base::StringPiece chain(reinterpret_cast<const char*>(kChain), sizeof(kChain)); @@ -384,6 +580,15 @@ TEST(DNSSECChainVerifierTest, BadTarget) { ASSERT_EQ(net::DNSSECChainVerifier::BAD_TARGET, verifier.Verify()); } +TEST(DNSSECChainVerifierTest, TestCNAMEChain) { + base::StringPiece chain(reinterpret_cast<const char*>(kCNAMEChain), + sizeof(kCNAMEChain)); + net::DNSSECChainVerifier verifier(FromDNSName("www.dnssec-exp.org"), chain); + verifier.IgnoreTimestamps(); + ASSERT_EQ(net::DNSSECChainVerifier::OK, verifier.Verify()); + ASSERT_EQ(net::kDNS_TXT, verifier.rrtype()); +} + // This is too slow to run all the time. TEST(DNSSECChainVerifierTest, DISABLED_Fuzz) { uint8 copy[sizeof(kChain)]; diff --git a/net/net.gyp b/net/net.gyp index d781fb3..a967a35 100644 --- a/net/net.gyp +++ b/net/net.gyp @@ -1137,6 +1137,16 @@ ], }, { + 'target_name': 'dnssec_chain_verify', + 'type': 'executable', + 'dependencies': [ + 'net_base', + ], + 'sources': [ + 'tools/dnssec_chain_verify/dnssec_chain_verify.cc', + ] + }, + { 'target_name': 'ssl_false_start_blacklist_process', 'type': 'executable', 'toolsets': ['host'], diff --git a/net/socket/ssl_client_socket_nss.cc b/net/socket/ssl_client_socket_nss.cc index 5da49cf..f9f36af 100644 --- a/net/socket/ssl_client_socket_nss.cc +++ b/net/socket/ssl_client_socket_nss.cc @@ -1613,14 +1613,14 @@ static DNSValidationResult VerifyTXTRecords( SECStatus rv; j = m.find("hr"); - if (j == m.end() || j->second == "cert") { - rv = HASH_HashBuf(hash_algorithm, calculated_hash, - server_cert_nss->derCert.data, - server_cert_nss->derCert.len); - } else if (j->second == "pubkey") { + if (j == m.end() || j->second == "pubkey") { rv = HASH_HashBuf(hash_algorithm, calculated_hash, server_cert_nss->derPublicKey.data, server_cert_nss->derPublicKey.len); + } else if (j->second == "cert") { + rv = HASH_HashBuf(hash_algorithm, calculated_hash, + server_cert_nss->derCert.data, + server_cert_nss->derCert.len); } else { continue; } diff --git a/net/tools/dnssec_chain_verify/dnssec_chain_verify.cc b/net/tools/dnssec_chain_verify/dnssec_chain_verify.cc new file mode 100644 index 0000000..a1c5270 --- /dev/null +++ b/net/tools/dnssec_chain_verify/dnssec_chain_verify.cc @@ -0,0 +1,108 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include <errno.h> +#include <stdio.h> + +#include "base/at_exit.h" +#include "net/base/dns_util.h" +#include "net/base/dnssec_chain_verifier.h" + +static int usage(const char* argv0) { + fprintf(stderr, "Usage: %s [--ignore-timestamps] <target domain> " + "<input file>\n", argv0); + return 1; +} + +int main(int argc, char** argv) { + base::AtExitManager at_exit_manager; + + if (argc < 3) + return usage(argv[0]); + + const char* target = NULL; + const char* infilename = NULL; + bool ignore_timestamps = false; + + for (int i = 1; i < argc; i++) { + if (strcmp(argv[i], "--ignore-timestamps") == 0) { + ignore_timestamps = true; + } else if (!target) { + target = argv[i]; + } else if (!infilename) { + infilename = argv[i]; + } else { + return usage(argv[0]); + } + } + + if (!target || !infilename) + return usage(argv[0]); + + FILE* infile = fopen(infilename, "r"); + if (!infile) { + perror("open"); + return usage(argv[0]); + } + + fseek(infile, 0, SEEK_END); + unsigned long inlen = ftell(infile); + fseek(infile, 0, SEEK_SET); + + char* const input = (char *) malloc(inlen); + if (fread(input, inlen, 1, infile) != 1) { + perror("read"); + return 1; + } + + std::string target_dns; + if (!net::DNSDomainFromDot(target, &target_dns)) { + fprintf(stderr, "Not a valid DNS name: %s\n", target); + return usage(argv[0]); + } + + net::DNSSECChainVerifier verifier(target_dns, + base::StringPiece(input, inlen)); + if (ignore_timestamps) + verifier.IgnoreTimestamps(); + net::DNSSECChainVerifier::Error err = verifier.Verify(); + const char* err_str; + switch (err) { + case net::DNSSECChainVerifier::BAD_DATA: + err_str = "Bad data"; + break; + case net::DNSSECChainVerifier::UNKNOWN_ROOT_KEY: + err_str = "Unknown root key"; + break; + case net::DNSSECChainVerifier::UNKNOWN_DIGEST: + err_str = "Unknown digest"; + break; + case net::DNSSECChainVerifier::UNKNOWN_TERMINAL_RRTYPE: + err_str = "Unknown terminal RR type"; + break; + case net::DNSSECChainVerifier::BAD_SIGNATURE: + err_str = "Bad signature"; + break; + case net::DNSSECChainVerifier::NO_DS_LINK: + err_str = "No DS link"; + break; + case net::DNSSECChainVerifier::OFF_COURSE: + err_str = "Off course"; + break; + case net::DNSSECChainVerifier::BAD_TARGET: + err_str = "Bad target"; + break; + default: + err_str = "Unknown"; + break; + } + + if (err != net::DNSSECChainVerifier::OK) { + fprintf(stderr, "Chain error: %s (%d)\n", err_str, (int) err); + return 1; + } + + fprintf(stderr, "Chain good: rrtype:%d\n", verifier.rrtype()); + return 0; +} |