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

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
Index: remoting/protocol/authentication_method.cc
diff --git a/remoting/protocol/authentication_method.cc b/remoting/protocol/authentication_method.cc
index ab60f399535289f9e5084b7d646519a85e91fd1d..ea420a6e8b556933dfeef8906d8044c622a65ec6 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,12 +71,13 @@ std::string AuthenticationMethod::ApplyHashFunction(
}
AuthenticationMethod::AuthenticationMethod()
- : invalid_(true),
+ : method_type_(INVALID),
hash_function_(NONE) {
}
-AuthenticationMethod::AuthenticationMethod(HashFunction hash_function)
- : invalid_(false),
+AuthenticationMethod::AuthenticationMethod(MethodType method_type,
+ HashFunction hash_function)
+ : method_type_(method_type),
hash_function_(hash_function) {
}
Sergey Ulanov 2013/03/22 05:58:43 DCHECK_NE(type_, INVALID);
rmsousa 2013/03/22 21:19:05 Done.
@@ -81,24 +89,27 @@ AuthenticationMethod::HashFunction AuthenticationMethod::hash_function() const {
const std::string AuthenticationMethod::ToString() const {
DCHECK(is_valid());
+ if (method_type_ == THIRD_PARTY)
+ return "third_party";
+
+ DCHECK(method_type_ == SPAKE2);
Sergey Ulanov 2013/03/22 05:58:43 nit: DCHECK_EQ
rmsousa 2013/03/22 21:19:05 Done.
+
switch (hash_function_) {
case NONE:
return "spake2_plain";
case HMAC_SHA256:
return "spake2_hmac";
+ default:
Sergey Ulanov 2013/03/22 05:58:43 You should not have default case when there is a c
rmsousa 2013/03/22 21:19:05 Done.
+ NOTREACHED();
}
- NOTREACHED();
- return "";
+ return "invalid";
Sergey Ulanov 2013/03/22 05:58:43 Why do we need to return non-empty string here?
rmsousa 2013/03/22 21:19:05 No functional reason, it just makes it slightly ea
}
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 method_type_ == other.method_type_ &&
+ hash_function_ == other.hash_function_;
}
bool SharedSecretHash::Parse(const std::string& as_string) {

Powered by Google App Engine
This is Rietveld 408576698