Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Side by Side Diff: chrome/browser/extensions/api/gcd_private/privet_v3_session.cc

Issue 2230203002: chrome: Use stl utilities from the base namespace (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed accidental components/ change Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/json/json_reader.h" 8 #include "base/json/json_reader.h"
9 #include "base/json/json_writer.h" 9 #include "base/json/json_writer.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 // Key will be verified below, using HMAC. 349 // Key will be verified below, using HMAC.
350 const std::string& key = spake_->GetUnverifiedKey(); 350 const std::string& key = spake_->GetUnverifiedKey();
351 if (!hmac.Init(reinterpret_cast<const unsigned char*>(key.c_str()), 351 if (!hmac.Init(reinterpret_cast<const unsigned char*>(key.c_str()),
352 key.size()) || 352 key.size()) ||
353 !hmac.Verify(fingerprint, signature)) { 353 !hmac.Verify(fingerprint, signature)) {
354 LOG(ERROR) << "Verification failed: " << response; 354 LOG(ERROR) << "Verification failed: " << response;
355 return callback.Run(Result::STATUS_BADPAIRINGCODEERROR); 355 return callback.Run(Result::STATUS_BADPAIRINGCODEERROR);
356 } 356 }
357 357
358 std::string auth_code(hmac.DigestLength(), ' '); 358 std::string auth_code(hmac.DigestLength(), ' ');
359 if (!hmac.Sign(session_id_, 359 if (!hmac.Sign(session_id_, reinterpret_cast<unsigned char*>(
360 reinterpret_cast<unsigned char*>(string_as_array(&auth_code)), 360 base::string_as_array(&auth_code)),
361 auth_code.size())) { 361 auth_code.size())) {
362 LOG(FATAL) << "Signing failed"; 362 LOG(FATAL) << "Signing failed";
363 return callback.Run(Result::STATUS_SESSIONERROR); 363 return callback.Run(Result::STATUS_SESSIONERROR);
364 } 364 }
365 365
366 VLOG(1) << "Expected certificate: " << fingerprint; 366 VLOG(1) << "Expected certificate: " << fingerprint;
367 context_getter_->AddPairedHost( 367 context_getter_->AddPairedHost(
368 host_port_.host(), hash, 368 host_port_.host(), hash,
369 base::Bind(&PrivetV3Session::OnPairedHostAddedToContext, 369 base::Bind(&PrivetV3Session::OnPairedHostAddedToContext,
370 weak_ptr_factory_.GetWeakPtr(), auth_code, callback)); 370 weak_ptr_factory_.GetWeakPtr(), auth_code, callback));
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 // Only session with pairing in process needs to be canceled. Paired sessions 507 // Only session with pairing in process needs to be canceled. Paired sessions
508 // (in https mode) does not need to be canceled. 508 // (in https mode) does not need to be canceled.
509 if (session_id_.empty() || use_https_) 509 if (session_id_.empty() || use_https_)
510 return; 510 return;
511 base::DictionaryValue input; 511 base::DictionaryValue input;
512 input.SetString(kPrivetV3KeySessionId, session_id_); 512 input.SetString(kPrivetV3KeySessionId, session_id_);
513 StartPostRequest(kPrivetV3PairingCancelPath, input, MessageCallback()); 513 StartPostRequest(kPrivetV3PairingCancelPath, input, MessageCallback());
514 } 514 }
515 515
516 } // namespace extensions 516 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698