OLD | NEW |
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/me2me_host_authenticator_factory.h" | 5 #include "remoting/protocol/me2me_host_authenticator_factory.h" |
6 | 6 |
7 #include "base/base64.h" | 7 #include "base/base64.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "crypto/rsa_private_key.h" | 9 #include "crypto/rsa_private_key.h" |
10 #include "remoting/protocol/channel_authenticator.h" | 10 #include "remoting/protocol/channel_authenticator.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 NOTREACHED(); | 50 NOTREACHED(); |
51 return scoped_ptr<ChannelAuthenticator>(NULL); | 51 return scoped_ptr<ChannelAuthenticator>(NULL); |
52 } | 52 } |
53 | 53 |
54 protected: | 54 protected: |
55 State state_; | 55 State state_; |
56 }; | 56 }; |
57 | 57 |
58 } // namespace | 58 } // namespace |
59 | 59 |
60 bool SharedSecretHash::Parse(const std::string& as_string) { | |
61 size_t separator = as_string.find(':'); | |
62 if (separator == std::string::npos) | |
63 return false; | |
64 | |
65 std::string function_name = as_string.substr(0, separator); | |
66 if (function_name == "plain") { | |
67 hash_function = AuthenticationMethod::NONE; | |
68 } else if (function_name == "hmac") { | |
69 hash_function = AuthenticationMethod::HMAC_SHA256; | |
70 } else { | |
71 return false; | |
72 } | |
73 | |
74 if (!base::Base64Decode(as_string.substr(separator + 1), &value)) { | |
75 return false; | |
76 } | |
77 | |
78 return true; | |
79 } | |
80 | |
81 Me2MeHostAuthenticatorFactory::Me2MeHostAuthenticatorFactory( | 60 Me2MeHostAuthenticatorFactory::Me2MeHostAuthenticatorFactory( |
82 const std::string& local_jid, | 61 const std::string& local_jid, |
83 const std::string& local_cert, | 62 const std::string& local_cert, |
84 const crypto::RSAPrivateKey& local_private_key, | 63 const crypto::RSAPrivateKey& local_private_key, |
85 const SharedSecretHash& shared_secret_hash) | 64 const SharedSecretHash& shared_secret_hash) |
86 : local_cert_(local_cert), | 65 : local_cert_(local_cert), |
87 local_private_key_(local_private_key.Copy()), | 66 local_private_key_(local_private_key.Copy()), |
88 shared_secret_hash_(shared_secret_hash) { | 67 shared_secret_hash_(shared_secret_hash) { |
89 // Verify that |local_jid| is bare. | 68 // Verify that |local_jid| is bare. |
90 DCHECK_EQ(local_jid.find('/'), std::string::npos); | 69 DCHECK_EQ(local_jid.find('/'), std::string::npos); |
(...skipping 26 matching lines...) Expand all Loading... |
117 } | 96 } |
118 } | 97 } |
119 | 98 |
120 return NegotiatingAuthenticator::CreateForHost( | 99 return NegotiatingAuthenticator::CreateForHost( |
121 local_cert_, *local_private_key_, shared_secret_hash_.value, | 100 local_cert_, *local_private_key_, shared_secret_hash_.value, |
122 shared_secret_hash_.hash_function); | 101 shared_secret_hash_.hash_function); |
123 } | 102 } |
124 | 103 |
125 } // namespace protocol | 104 } // namespace protocol |
126 } // namespace remoting | 105 } // namespace remoting |
OLD | NEW |