| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/cert/internal/name_constraints.h" | 5 #include "net/cert/internal/name_constraints.h" |
| 6 | 6 |
| 7 #include <limits.h> | 7 #include <limits.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 } | 80 } |
| 81 } | 81 } |
| 82 | 82 |
| 83 if (!base::EndsWith(name, dns_constraint, | 83 if (!base::EndsWith(name, dns_constraint, |
| 84 base::CompareCase::INSENSITIVE_ASCII)) { | 84 base::CompareCase::INSENSITIVE_ASCII)) { |
| 85 return false; | 85 return false; |
| 86 } | 86 } |
| 87 // Exact match. | 87 // Exact match. |
| 88 if (name.size() == dns_constraint.size()) | 88 if (name.size() == dns_constraint.size()) |
| 89 return true; | 89 return true; |
| 90 // If dNSName constraint starts with a dot, only subdomains should match. |
| 91 // (e.g., "foo.bar.com" matches constraint ".bar.com", but "bar.com" doesn't.) |
| 92 // RFC 5280 is ambiguous, but this matches the behavior of other platforms. |
| 93 if (!dns_constraint.empty() && dns_constraint[0] == '.') |
| 94 dns_constraint.remove_prefix(1); |
| 90 // Subtree match. | 95 // Subtree match. |
| 91 if (name.size() > dns_constraint.size() && | 96 if (name.size() > dns_constraint.size() && |
| 92 name[name.size() - dns_constraint.size() - 1] == '.') { | 97 name[name.size() - dns_constraint.size() - 1] == '.') { |
| 93 return true; | 98 return true; |
| 94 } | 99 } |
| 95 // Trailing text matches, but not in a subtree (e.g., "foobar.com" is not a | 100 // Trailing text matches, but not in a subtree (e.g., "foobar.com" is not a |
| 96 // match for "bar.com"). | 101 // match for "bar.com"). |
| 97 return false; | 102 return false; |
| 98 } | 103 } |
| 99 | 104 |
| (...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 543 | 548 |
| 544 return false; | 549 return false; |
| 545 } | 550 } |
| 546 | 551 |
| 547 int NameConstraints::ConstrainedNameTypes() const { | 552 int NameConstraints::ConstrainedNameTypes() const { |
| 548 return (permitted_subtrees_.present_name_types | | 553 return (permitted_subtrees_.present_name_types | |
| 549 excluded_subtrees_.present_name_types); | 554 excluded_subtrees_.present_name_types); |
| 550 } | 555 } |
| 551 | 556 |
| 552 } // namespace net | 557 } // namespace net |
| OLD | NEW |