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/browser/extensions/api/gcd_private/privet_v3_session.h" | 5 #include "chrome/browser/extensions/api/gcd_private/privet_v3_session.h" |
6 | 6 |
7 #include "base/base64.h" | 7 #include "base/base64.h" |
8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
9 #include "base/threading/thread_task_runner_handle.h" | 9 #include "base/threading/thread_task_runner_handle.h" |
10 #include "chrome/browser/extensions/api/gcd_private/privet_v3_context_getter.h" | 10 #include "chrome/browser/extensions/api/gcd_private/privet_v3_context_getter.h" |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 EXPECT_EQ(spake.ProcessMessage(commitment), | 225 EXPECT_EQ(spake.ProcessMessage(commitment), |
226 crypto::P224EncryptedKeyExchange::kResultPending); | 226 crypto::P224EncryptedKeyExchange::kResultPending); |
227 | 227 |
228 std::string fingerprint_base64; | 228 std::string fingerprint_base64; |
229 base::Base64Encode(fingerprint, &fingerprint_base64); | 229 base::Base64Encode(fingerprint, &fingerprint_base64); |
230 | 230 |
231 crypto::HMAC hmac(crypto::HMAC::SHA256); | 231 crypto::HMAC hmac(crypto::HMAC::SHA256); |
232 const std::string& key = spake.GetUnverifiedKey(); | 232 const std::string& key = spake.GetUnverifiedKey(); |
233 EXPECT_TRUE(hmac.Init(key)); | 233 EXPECT_TRUE(hmac.Init(key)); |
234 std::string signature(hmac.DigestLength(), ' '); | 234 std::string signature(hmac.DigestLength(), ' '); |
235 EXPECT_TRUE(hmac.Sign(fingerprint, reinterpret_cast<unsigned char*>( | 235 EXPECT_TRUE(hmac.Sign(fingerprint, |
236 string_as_array(&signature)), | 236 reinterpret_cast<unsigned char*>( |
| 237 base::string_as_array(&signature)), |
237 signature.size())); | 238 signature.size())); |
238 | 239 |
239 std::string signature_base64; | 240 std::string signature_base64; |
240 base::Base64Encode(signature, &signature_base64); | 241 base::Base64Encode(signature, &signature_base64); |
241 | 242 |
242 fetcher_factory_.SetFakeResponse( | 243 fetcher_factory_.SetFakeResponse( |
243 GURL("http://host:180/privet/v3/pairing/confirm"), | 244 GURL("http://host:180/privet/v3/pairing/confirm"), |
244 base::StringPrintf( | 245 base::StringPrintf( |
245 "{\"certFingerprint\":\"%s\",\"certSignature\":\"%s\"}", | 246 "{\"certFingerprint\":\"%s\",\"certSignature\":\"%s\"}", |
246 fingerprint_base64.c_str(), signature_base64.c_str()), | 247 fingerprint_base64.c_str(), signature_base64.c_str()), |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 | 332 |
332 base::DictionaryValue input; | 333 base::DictionaryValue input; |
333 input.SetString("id", id); | 334 input.SetString("id", id); |
334 session_->SendMessage( | 335 session_->SendMessage( |
335 "/privet/v3/commands/status", input, | 336 "/privet/v3/commands/status", input, |
336 base::Bind(&PrivetV3SessionTest::OnMessageSend, base::Unretained(this))); | 337 base::Bind(&PrivetV3SessionTest::OnMessageSend, base::Unretained(this))); |
337 base::RunLoop().RunUntilIdle(); | 338 base::RunLoop().RunUntilIdle(); |
338 } | 339 } |
339 | 340 |
340 } // namespace extensions | 341 } // namespace extensions |
OLD | NEW |