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/base/rsa_key_pair.h" | 5 #include "remoting/base/rsa_key_pair.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 } | 56 } |
57 | 57 |
58 std::string RsaKeyPair::ToString() const { | 58 std::string RsaKeyPair::ToString() const { |
59 // Check that the key initialized. | 59 // Check that the key initialized. |
60 DCHECK(key_.get() != NULL); | 60 DCHECK(key_.get() != NULL); |
61 | 61 |
62 std::vector<uint8> key_buf; | 62 std::vector<uint8> key_buf; |
63 CHECK(key_->ExportPrivateKey(&key_buf)); | 63 CHECK(key_->ExportPrivateKey(&key_buf)); |
64 std::string key_str(key_buf.begin(), key_buf.end()); | 64 std::string key_str(key_buf.begin(), key_buf.end()); |
65 std::string key_base64; | 65 std::string key_base64; |
66 if (!base::Base64Encode(key_str, &key_base64)) { | 66 base::Base64Encode(key_str, &key_base64); |
67 LOG(FATAL) << "Base64Encode failed"; | |
68 } | |
69 return key_base64; | 67 return key_base64; |
70 } | 68 } |
71 | 69 |
72 std::string RsaKeyPair::GetPublicKey() const { | 70 std::string RsaKeyPair::GetPublicKey() const { |
73 std::vector<uint8> public_key; | 71 std::vector<uint8> public_key; |
74 CHECK(key_->ExportPublicKey(&public_key)); | 72 CHECK(key_->ExportPublicKey(&public_key)); |
75 std::string public_key_str(public_key.begin(), public_key.end()); | 73 std::string public_key_str(public_key.begin(), public_key.end()); |
76 std::string public_key_base64; | 74 std::string public_key_base64; |
77 base::Base64Encode(public_key_str, &public_key_base64); | 75 base::Base64Encode(public_key_str, &public_key_base64); |
78 return public_key_base64; | 76 return public_key_base64; |
(...skipping 22 matching lines...) Expand all Loading... |
101 net::x509_util::DIGEST_SHA1, | 99 net::x509_util::DIGEST_SHA1, |
102 "CN=chromoting", | 100 "CN=chromoting", |
103 base::RandInt(1, std::numeric_limits<int>::max()), | 101 base::RandInt(1, std::numeric_limits<int>::max()), |
104 base::Time::Now(), | 102 base::Time::Now(), |
105 base::Time::Now() + base::TimeDelta::FromDays(1), | 103 base::Time::Now() + base::TimeDelta::FromDays(1), |
106 &der_cert); | 104 &der_cert); |
107 return der_cert; | 105 return der_cert; |
108 } | 106 } |
109 | 107 |
110 } // namespace remoting | 108 } // namespace remoting |
OLD | NEW |