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

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

Issue 14793021: PairingAuthenticator implementation and plumbing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed clang errors. Created 7 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « remoting/protocol/authentication_method.h ('k') | remoting/protocol/authenticator.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "remoting/protocol/authentication_method.h" 5 #include "remoting/protocol/authentication_method.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "crypto/hmac.h" 9 #include "crypto/hmac.h"
10 #include "remoting/protocol/auth_util.h" 10 #include "remoting/protocol/auth_util.h"
11 11
12 namespace remoting { 12 namespace remoting {
13 namespace protocol { 13 namespace protocol {
14 14
15 // static 15 // static
16 AuthenticationMethod AuthenticationMethod::Invalid() { 16 AuthenticationMethod AuthenticationMethod::Invalid() {
17 return AuthenticationMethod(); 17 return AuthenticationMethod();
18 } 18 }
19 19
20 // static 20 // static
21 AuthenticationMethod AuthenticationMethod::Spake2(HashFunction hash_function) { 21 AuthenticationMethod AuthenticationMethod::Spake2(HashFunction hash_function) {
22 return AuthenticationMethod(SPAKE2, hash_function); 22 return AuthenticationMethod(SPAKE2, hash_function);
23 } 23 }
24 24
25 // static 25 // static
26 AuthenticationMethod AuthenticationMethod::Spake2Pair() {
27 return AuthenticationMethod(SPAKE2_PAIR, HMAC_SHA256);
28 }
29
30 // static
26 AuthenticationMethod AuthenticationMethod::ThirdParty() { 31 AuthenticationMethod AuthenticationMethod::ThirdParty() {
27 return AuthenticationMethod(THIRD_PARTY, NONE); 32 return AuthenticationMethod(THIRD_PARTY, NONE);
28 } 33 }
29 34
30 // static 35 // static
31 AuthenticationMethod AuthenticationMethod::FromString( 36 AuthenticationMethod AuthenticationMethod::FromString(
32 const std::string& value) { 37 const std::string& value) {
33 if (value == "spake2_plain") { 38 if (value == "spake2_pair") {
39 return Spake2Pair();
40 } else if (value == "spake2_plain") {
34 return Spake2(NONE); 41 return Spake2(NONE);
35 } else if (value == "spake2_hmac") { 42 } else if (value == "spake2_hmac") {
36 return Spake2(HMAC_SHA256); 43 return Spake2(HMAC_SHA256);
37 } else if (value == "third_party") { 44 } else if (value == "third_party") {
38 return ThirdParty(); 45 return ThirdParty();
39 } else { 46 } else {
40 return AuthenticationMethod::Invalid(); 47 return AuthenticationMethod::Invalid();
41 } 48 }
42 } 49 }
43 50
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 } 90 }
84 91
85 AuthenticationMethod::HashFunction AuthenticationMethod::hash_function() const { 92 AuthenticationMethod::HashFunction AuthenticationMethod::hash_function() const {
86 DCHECK(is_valid()); 93 DCHECK(is_valid());
87 return hash_function_; 94 return hash_function_;
88 } 95 }
89 96
90 const std::string AuthenticationMethod::ToString() const { 97 const std::string AuthenticationMethod::ToString() const {
91 DCHECK(is_valid()); 98 DCHECK(is_valid());
92 99
93 if (type_ == THIRD_PARTY) 100 switch (type_) {
94 return "third_party"; 101 case INVALID:
102 NOTREACHED();
103 break;
95 104
96 DCHECK_EQ(type_, SPAKE2); 105 case SPAKE2_PAIR:
106 return "spake2_pair";
97 107
98 switch (hash_function_) { 108 case SPAKE2:
99 case NONE: 109 switch (hash_function_) {
100 return "spake2_plain"; 110 case NONE:
101 case HMAC_SHA256: 111 return "spake2_plain";
102 return "spake2_hmac"; 112 case HMAC_SHA256:
113 return "spake2_hmac";
114 }
115 break;
116
117 case THIRD_PARTY:
118 return "third_party";
103 } 119 }
104 120
105 return "invalid"; 121 return "invalid";
106 } 122 }
107 123
108 bool AuthenticationMethod::operator ==( 124 bool AuthenticationMethod::operator ==(
109 const AuthenticationMethod& other) const { 125 const AuthenticationMethod& other) const {
110 return type_ == other.type_ && 126 return type_ == other.type_ &&
111 hash_function_ == other.hash_function_; 127 hash_function_ == other.hash_function_;
112 } 128 }
(...skipping 14 matching lines...) Expand all
127 143
128 if (!base::Base64Decode(as_string.substr(separator + 1), &value)) { 144 if (!base::Base64Decode(as_string.substr(separator + 1), &value)) {
129 return false; 145 return false;
130 } 146 }
131 147
132 return true; 148 return true;
133 } 149 }
134 150
135 } // namespace protocol 151 } // namespace protocol
136 } // namespace remoting 152 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/protocol/authentication_method.h ('k') | remoting/protocol/authenticator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698