| 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 (!EndsWith(common_name, translated_mac, false)) { | 68 if (!base::EndsWith(common_name, translated_mac, false)) { |
| 69 LOG(ERROR) << kErrorPrefix << "MAC addresses don't match."; | 69 LOG(ERROR) << kErrorPrefix << "MAC addresses don't match."; |
| 70 return false; | 70 return false; |
| 71 } | 71 } |
| 72 | 72 |
| 73 // Use the public key from verified certificate to verify |signature| over | 73 // Use the public key from verified certificate to verify |signature| over |
| 74 // |data|. | 74 // |data|. |
| 75 verification_result = | 75 verification_result = |
| 76 verification_context->VerifySignatureOverData(signature, data); | 76 verification_context->VerifySignatureOverData(signature, data); |
| 77 | 77 |
| 78 if (verification_result.Failure()) { | 78 if (verification_result.Failure()) { |
| 79 LOG(ERROR) << kErrorPrefix << verification_result.GetLogString(); | 79 LOG(ERROR) << kErrorPrefix << verification_result.GetLogString(); |
| 80 return false; | 80 return false; |
| 81 } | 81 } |
| 82 return true; | 82 return true; |
| 83 } | 83 } |
| 84 | 84 |
| 85 } // namespace networking_private_crypto | 85 } // namespace networking_private_crypto |
| OLD | NEW |