Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef REMOTING_BASE_RSA_KEY_PAIR_H_ | |
| 6 #define REMOTING_BASE_RSA_KEY_PAIR_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/memory/ref_counted.h" | |
| 11 #include "base/memory/scoped_ptr.h" | |
| 12 | |
| 13 namespace crypto { | |
| 14 class RSAPrivateKey; | |
| 15 } // namespace crypto | |
| 16 | |
| 17 namespace remoting { | |
| 18 | |
| 19 class RsaKeyPair : public base::RefCountedThreadSafe<RsaKeyPair> { | |
| 20 public: | |
| 21 RsaKeyPair(); | |
| 22 | |
| 23 // Generates a new (random) private key from scratch. | |
|
Wez
2013/03/06 00:43:25
nit: No need for both "from scratch" and "(random)
rmsousa
2013/03/06 04:36:49
Done.
| |
| 24 void Generate(); | |
| 25 | |
| 26 // Loads a private key from a base64-encoded string. Returns true on success. | |
| 27 bool LoadFromString(const std::string& key_base64); | |
|
Wez
2013/03/06 00:43:25
Looking at the call-sites, can this be static scop
rmsousa
2013/03/06 04:36:49
Done.
| |
| 28 // Returns a base64 encoded string representing the private key. | |
|
Wez
2013/03/06 00:43:25
Blank line before this comment.
rmsousa
2013/03/06 04:36:49
Done.
| |
| 29 std::string GetAsString() const; | |
|
Wez
2013/03/06 00:43:25
nit: ToString()
rmsousa
2013/03/06 04:36:49
Done.
| |
| 30 | |
| 31 // Generates a DER-encoded self-signed certificate using the key pair. Returns | |
| 32 // empty string if cert generation fails (e.g. it may happen when the system | |
| 33 // clock is off). | |
| 34 std::string GenerateCertificate() const; | |
| 35 // Returns a base64-encoded string representing the public key. | |
|
Wez
2013/03/06 00:43:25
nit: Blank line before this comment.
rmsousa
2013/03/06 04:36:49
Done.
| |
| 36 std::string GetPublicKey() const; | |
| 37 // Returns a base64-encoded signature for the message. | |
|
Wez
2013/03/06 00:43:25
nit: Blank line before this comment.
rmsousa
2013/03/06 04:36:49
Done.
| |
| 38 std::string GetSignature(const std::string& message) const; | |
| 39 | |
| 40 crypto::RSAPrivateKey* private_key() { return key_.get(); } | |
|
Wez
2013/03/06 00:43:25
nit: const?
rmsousa
2013/03/06 04:36:49
The SSL APIs don't take const parameters. I'm not
| |
| 41 | |
| 42 private: | |
| 43 friend class base::RefCountedThreadSafe<RsaKeyPair>; | |
| 44 virtual ~RsaKeyPair(); | |
| 45 | |
| 46 scoped_ptr<crypto::RSAPrivateKey> key_; | |
| 47 | |
| 48 DISALLOW_COPY_AND_ASSIGN(RsaKeyPair); | |
| 49 }; | |
| 50 | |
| 51 } // namespace remoting | |
| 52 | |
| 53 #endif // REMOTING_BASE_RSA_KEY_PAIR_H_ | |
| OLD | NEW |