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

Unified Diff: remoting/protocol/authentication_method.cc

Issue 12326090: Third Party authentication protocol. (Closed) Base URL: http://git.chromium.org/chromium/src.git@host_key_pair
Patch Set: REviewer comments Created 7 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/protocol/authentication_method.h ('k') | remoting/protocol/authenticator_test_base.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/protocol/authentication_method.cc
diff --git a/remoting/protocol/authentication_method.cc b/remoting/protocol/authentication_method.cc
index ab60f399535289f9e5084b7d646519a85e91fd1d..71ec00880a9a88fecbca5d33c440f5e80572b59e 100644
--- a/remoting/protocol/authentication_method.cc
+++ b/remoting/protocol/authentication_method.cc
@@ -19,7 +19,12 @@ AuthenticationMethod AuthenticationMethod::Invalid() {
// static
AuthenticationMethod AuthenticationMethod::Spake2(HashFunction hash_function) {
- return AuthenticationMethod(hash_function);
+ return AuthenticationMethod(SPAKE2, hash_function);
+}
+
+// static
+AuthenticationMethod AuthenticationMethod::ThirdParty() {
+ return AuthenticationMethod(THIRD_PARTY, NONE);
}
// static
@@ -29,6 +34,8 @@ AuthenticationMethod AuthenticationMethod::FromString(
return Spake2(NONE);
} else if (value == "spake2_hmac") {
return Spake2(HMAC_SHA256);
+ } else if (value == "third_party") {
+ return ThirdParty();
} else {
return AuthenticationMethod::Invalid();
}
@@ -64,13 +71,15 @@ std::string AuthenticationMethod::ApplyHashFunction(
}
AuthenticationMethod::AuthenticationMethod()
- : invalid_(true),
+ : type_(INVALID),
hash_function_(NONE) {
}
-AuthenticationMethod::AuthenticationMethod(HashFunction hash_function)
- : invalid_(false),
+AuthenticationMethod::AuthenticationMethod(MethodType type,
+ HashFunction hash_function)
+ : type_(type),
hash_function_(hash_function) {
+ DCHECK_NE(type_, INVALID);
}
AuthenticationMethod::HashFunction AuthenticationMethod::hash_function() const {
@@ -81,6 +90,11 @@ AuthenticationMethod::HashFunction AuthenticationMethod::hash_function() const {
const std::string AuthenticationMethod::ToString() const {
DCHECK(is_valid());
+ if (type_ == THIRD_PARTY)
+ return "third_party";
+
+ DCHECK_EQ(type_, SPAKE2);
+
switch (hash_function_) {
case NONE:
return "spake2_plain";
@@ -88,17 +102,13 @@ const std::string AuthenticationMethod::ToString() const {
return "spake2_hmac";
}
- NOTREACHED();
- return "";
+ return "invalid";
}
bool AuthenticationMethod::operator ==(
const AuthenticationMethod& other) const {
- if (!is_valid())
- return !other.is_valid();
- if (!other.is_valid())
- return false;
- return hash_function_ == other.hash_function_;
+ return type_ == other.type_ &&
+ hash_function_ == other.hash_function_;
}
bool SharedSecretHash::Parse(const std::string& as_string) {
« no previous file with comments | « remoting/protocol/authentication_method.h ('k') | remoting/protocol/authenticator_test_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698