OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/browser/extensions/api/networking_private/networking_private_cr
ypto.h" | 5 #include "chrome/browser/extensions/api/networking_private/networking_private_cr
ypto.h" |
6 | 6 |
7 #include <cert.h> | 7 #include <cert.h> |
8 #include <cryptohi.h> | 8 #include <cryptohi.h> |
9 #include <keyhi.h> | 9 #include <keyhi.h> |
10 #include <keythi.h> | 10 #include <keythi.h> |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 // Something like evt_e161 001a11ffacdf | 121 // Something like evt_e161 001a11ffacdf |
122 char* common_name = CERT_GetCommonName(&cert->subject); | 122 char* common_name = CERT_GetCommonName(&cert->subject); |
123 if (!common_name) { | 123 if (!common_name) { |
124 LOG(ERROR) << "Certificate does not have common name."; | 124 LOG(ERROR) << "Certificate does not have common name."; |
125 return false; | 125 return false; |
126 } | 126 } |
127 | 127 |
128 std::string subject_name(common_name); | 128 std::string subject_name(common_name); |
129 PORT_Free(common_name); | 129 PORT_Free(common_name); |
130 std::string translated_mac; | 130 std::string translated_mac; |
131 RemoveChars(connected_mac, ":", &translated_mac); | 131 base::RemoveChars(connected_mac, ":", &translated_mac); |
132 if (!EndsWith(subject_name, translated_mac, false)) { | 132 if (!EndsWith(subject_name, translated_mac, false)) { |
133 LOG(ERROR) << "MAC addresses don't match."; | 133 LOG(ERROR) << "MAC addresses don't match."; |
134 return false; | 134 return false; |
135 } | 135 } |
136 | 136 |
137 // Make sure that the certificate matches the unsigned data presented. | 137 // Make sure that the certificate matches the unsigned data presented. |
138 // Verify that the |signature| matches |data|. | 138 // Verify that the |signature| matches |data|. |
139 crypto::ScopedSECKEYPublicKey public_key(CERT_ExtractPublicKey(cert.get())); | 139 crypto::ScopedSECKEYPublicKey public_key(CERT_ExtractPublicKey(cert.get())); |
140 if (!public_key.get()) { | 140 if (!public_key.get()) { |
141 LOG(ERROR) << "Unable to extract public key from certificate."; | 141 LOG(ERROR) << "Unable to extract public key from certificate."; |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 encrypted_data.length()); | 232 encrypted_data.length()); |
233 if (decrypted != SECSuccess) { | 233 if (decrypted != SECSuccess) { |
234 LOG(ERROR) << "Error during decryption."; | 234 LOG(ERROR) << "Error during decryption."; |
235 return false; | 235 return false; |
236 } | 236 } |
237 decrypted_output->assign(reinterpret_cast<char*>(rsa_output.get()), | 237 decrypted_output->assign(reinterpret_cast<char*>(rsa_output.get()), |
238 output_length); | 238 output_length); |
239 return true; | 239 return true; |
240 } | 240 } |
241 | 241 |
OLD | NEW |