OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/common/extensions/api/networking_private/networking_private_cry
pto.h" | 5 #include "chrome/common/extensions/api/networking_private/networking_private_cry
pto.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "extensions/common/cast/cast_cert_validator.h" | 10 #include "extensions/common/cast/cast_cert_validator.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 if (verification_result.Failure()) { | 58 if (verification_result.Failure()) { |
59 LOG(ERROR) << kErrorPrefix << verification_result.GetLogString(); | 59 LOG(ERROR) << kErrorPrefix << verification_result.GetLogString(); |
60 return false; | 60 return false; |
61 } | 61 } |
62 | 62 |
63 // Check that the device listed in the certificate is correct. | 63 // Check that the device listed in the certificate is correct. |
64 // Something like evt_e161 001a11ffacdf | 64 // Something like evt_e161 001a11ffacdf |
65 std::string common_name = verification_context->GetCommonName(); | 65 std::string common_name = verification_context->GetCommonName(); |
66 std::string translated_mac; | 66 std::string translated_mac; |
67 base::RemoveChars(connected_mac, ":", &translated_mac); | 67 base::RemoveChars(connected_mac, ":", &translated_mac); |
68 if (!base::EndsWith(common_name, translated_mac, | 68 if (!base::EndsWith(common_name, translated_mac, false)) { |
69 base::CompareCase::INSENSITIVE_ASCII)) { | |
70 LOG(ERROR) << kErrorPrefix << "MAC addresses don't match."; | 69 LOG(ERROR) << kErrorPrefix << "MAC addresses don't match."; |
71 return false; | 70 return false; |
72 } | 71 } |
73 | 72 |
74 // Use the public key from verified certificate to verify |signature| over | 73 // Use the public key from verified certificate to verify |signature| over |
75 // |data|. | 74 // |data|. |
76 verification_result = | 75 verification_result = |
77 verification_context->VerifySignatureOverData(signature, data); | 76 verification_context->VerifySignatureOverData(signature, data); |
78 | 77 |
79 if (verification_result.Failure()) { | 78 if (verification_result.Failure()) { |
80 LOG(ERROR) << kErrorPrefix << verification_result.GetLogString(); | 79 LOG(ERROR) << kErrorPrefix << verification_result.GetLogString(); |
81 return false; | 80 return false; |
82 } | 81 } |
83 return true; | 82 return true; |
84 } | 83 } |
85 | 84 |
86 } // namespace networking_private_crypto | 85 } // namespace networking_private_crypto |
OLD | NEW |