| OLD | NEW |
| (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 | |
| OLD | NEW |