OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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/host/support_access_verifier.h" | 5 #include "remoting/host/support_access_verifier.h" |
6 | 6 |
7 #include <stdlib.h> | 7 #include <stdlib.h> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/rand_util.h" | 11 #include "base/rand_util.h" |
12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
13 #include "remoting/host/host_config.h" | 13 #include "remoting/host/host_config.h" |
14 #include "remoting/protocol/auth_token_utils.h" | 14 #include "remoting/protocol/auth_token_utils.h" |
15 | 15 |
16 namespace remoting { | 16 namespace remoting { |
17 | 17 |
18 namespace { | 18 namespace { |
19 // 5 characters long from 34-letter alphabet gives 4.5M possible | 19 // 8 characters long from 10-letter alphabet gives 100M possible |
20 // host secrets with uniform distribution, which should be enough | 20 // host secrets with uniform distribution, which should be enough |
21 // for short-term passwords. | 21 // for short-term passwords. |
22 const int kHostSecretLength = 5; | 22 const int kHostSecretLength = 8; |
23 | 23 const char kHostSecretAlphabet[] = "0123456789"; |
Jamie
2011/05/20 22:37:55
I think this wants to be 7, since the support id i
Sergey Ulanov
2011/05/20 22:42:41
Length of support ids generated by directory is no
| |
24 // The following set includes 10 digits and Latin alphabet except I | |
25 // and O. I and O are not used to avoid confusion with 1 and 0. | |
26 const char kHostSecretAlphabet[] = "ABCDEFGHJKLMNPQRSTUVWXYZ0123456789"; | |
27 | 24 |
28 // Generates cryptographically strong random number in the range [0, max). | 25 // Generates cryptographically strong random number in the range [0, max). |
29 int CryptoRandomInt(int max) { | 26 int CryptoRandomInt(int max) { |
30 uint32 random_int32; | 27 uint32 random_int32; |
31 base::RandBytes(&random_int32, sizeof(random_int32)); | 28 base::RandBytes(&random_int32, sizeof(random_int32)); |
32 return random_int32 % max; | 29 return random_int32 % max; |
33 } | 30 } |
34 | 31 |
35 std::string GenerateRandomHostSecret() { | 32 std::string GenerateRandomHostSecret() { |
36 std::vector<char> result; | 33 std::vector<char> result; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
70 void SupportAccessVerifier::OnMe2MomHostRegistered( | 67 void SupportAccessVerifier::OnMe2MomHostRegistered( |
71 bool successful, const std::string& support_id) { | 68 bool successful, const std::string& support_id) { |
72 if (successful) { | 69 if (successful) { |
73 support_id_ = support_id; | 70 support_id_ = support_id; |
74 } else { | 71 } else { |
75 LOG(ERROR) << "Failed to register support host"; | 72 LOG(ERROR) << "Failed to register support host"; |
76 } | 73 } |
77 } | 74 } |
78 | 75 |
79 } // namespace remoting | 76 } // namespace remoting |
OLD | NEW |