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

Side by Side Diff: remoting/protocol/auth_token_utils.cc

Issue 8604001: Move SSL layer initialization into ChannelAuthenticator implementations. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: - Created 9 years, 1 month 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "remoting/protocol/auth_token_utils.h"
6
7 #include "base/base64.h"
8 #include "base/logging.h"
9 #include "base/string_util.h"
10 #include "crypto/sha2.h"
11
12 namespace remoting {
13 namespace protocol {
14
15 std::string GenerateSupportAuthToken(const std::string& jid,
16 const std::string& access_code) {
17 std::string sha256 = crypto::SHA256HashString(jid + " " + access_code);
18 std::string sha256_base64;
19 if (!base::Base64Encode(sha256, &sha256_base64)) {
20 LOG(FATAL) << "Failed to encode auth token";
21 }
22 return sha256_base64;
23 }
24
25 bool VerifySupportAuthToken(const std::string& jid,
26 const std::string& access_code,
27 const std::string& auth_token) {
28 std::string expected_token =
29 GenerateSupportAuthToken(jid, access_code);
30 return expected_token == auth_token;
31 }
32
33 } // namespace protocol
34 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698