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 #ifndef REMOTING_HOST_HOST_KEY_PAIR_H_ | 5 #ifndef REMOTING_PROTOCOL_KEY_PAIR_H_ |
6 #define REMOTING_HOST_HOST_KEY_PAIR_H_ | 6 #define REMOTING_PROTOCOL_KEY_PAIR_H_ |
Wez
2013/02/23 03:43:20
remoting/base/ might be a better place for this, s
Sergey Ulanov
2013/02/26 00:14:13
+1 on putting it in remoting/base
rmsousa
2013/02/26 02:38:52
Done.
rmsousa
2013/02/26 02:38:52
Done.
| |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 | 12 |
13 namespace crypto { | 13 namespace crypto { |
14 class RSAPrivateKey; | 14 class RSAPrivateKey; |
15 } // namespace base | 15 } // namespace base |
16 | 16 |
17 namespace remoting { | 17 namespace remoting { |
18 namespace protocol { | |
18 | 19 |
19 class HostConfig; | 20 class KeyPair { |
Sergey Ulanov
2013/02/26 00:14:13
Maybe call it RsaKeyPair? Or do you think we may w
rmsousa
2013/02/26 02:38:52
Its API isn't tied to RSA specifically, but on of
| |
20 class MutableHostConfig; | |
21 | |
22 class HostKeyPair { | |
23 public: | 21 public: |
24 HostKeyPair(); | 22 KeyPair(); |
25 ~HostKeyPair(); | 23 ~KeyPair(); |
26 | 24 |
27 void Generate(); | 25 void Generate(); |
Wez
2013/02/23 03:43:20
Would you mind adding some comments to explain wha
rmsousa
2013/02/26 02:38:52
Done.
| |
28 bool LoadFromString(const std::string& key_base64); | 26 bool LoadFromString(const std::string& key_base64); |
29 bool Load(const HostConfig& host_config); | |
30 void Save(MutableHostConfig* host_config); | |
31 | 27 |
28 scoped_ptr<KeyPair> Copy(); | |
32 crypto::RSAPrivateKey* private_key() { return key_.get(); } | 29 crypto::RSAPrivateKey* private_key() { return key_.get(); } |
33 | 30 |
34 std::string GetAsString() const; | |
35 std::string GetPublicKey() const; | |
36 std::string GetSignature(const std::string& message) const; | |
37 | |
38 // Make a new copy of private key. Caller will own the generated private key. | 31 // Make a new copy of private key. Caller will own the generated private key. |
39 crypto::RSAPrivateKey* CopyPrivateKey() const; | 32 crypto::RSAPrivateKey* CopyPrivateKey() const; |
Wez
2013/02/23 03:43:20
Do we ever use this?
rmsousa
2013/02/26 02:38:52
Nope.
| |
40 | 33 |
41 // Generates self-signed certificate using the key pair. Returns empty string | 34 // Generates self-signed certificate using the key pair. Returns empty string |
42 // if cert generation fails (e.g. it may happen when the system clock is off). | 35 // if cert generation fails (e.g. it may happen when the system clock is off). |
43 std::string GenerateCertificate() const; | 36 std::string GenerateCertificate() const; |
44 | 37 |
38 std::string GetAsString() const; | |
Wez
2013/02/23 03:43:20
What does this get as a string? The private key?
Wez
2013/02/23 03:43:20
I'd move this back up to come after LoadFromString
rmsousa
2013/02/26 02:38:52
FromString() sounds a bit like a constructor, rath
rmsousa
2013/02/26 02:38:52
Done.
| |
39 std::string GetPublicKey() const; | |
40 std::string GetSignature(const std::string& message) const; | |
Wez
2013/02/23 03:43:20
nit: SignMessage
| |
41 | |
45 private: | 42 private: |
46 scoped_ptr<crypto::RSAPrivateKey> key_; | 43 scoped_ptr<crypto::RSAPrivateKey> key_; |
47 }; | 44 }; |
Wez
2013/02/23 03:43:20
DISALLOW_COPY...
rmsousa
2013/02/26 02:38:52
Done.
| |
48 | 45 |
46 } // namespace protocol | |
49 } // namespace remoting | 47 } // namespace remoting |
50 | 48 |
51 #endif // REMOTING_HOST_HOST_KEY_PAIR_H_ | 49 #endif // REMOTING_PROTOCOL_KEY_PAIR_H_ |
OLD | NEW |