Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(275)

Side by Side Diff: remoting/base/rsa_key_pair.h

Issue 12316083: Move HostKeyPair into protocol::KeyPair. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebase Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | remoting/base/rsa_key_pair.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 // Generates a new (random) private key.
22 static scoped_refptr<RsaKeyPair> Generate();
23
24 // Loads a private key from a base64-encoded string. Returns true on success.
25 static scoped_refptr<RsaKeyPair> FromString(const std::string& key_base64);
26
27 // Returns a base64 encoded string representing the private key.
28 std::string ToString() const;
29
30 // Generates a DER-encoded self-signed certificate using the key pair. Returns
31 // empty string if cert generation fails (e.g. it may happen when the system
32 // clock is off).
33 std::string GenerateCertificate() const;
34
35 // Returns a base64-encoded string representing the public key.
36 std::string GetPublicKey() const;
37
38 // Returns a base64-encoded signature for the message.
39 std::string SignMessage(const std::string& message) const;
40
41 crypto::RSAPrivateKey* private_key() { return key_.get(); }
42
43 private:
44 friend class base::RefCountedThreadSafe<RsaKeyPair>;
45 RsaKeyPair(scoped_ptr<crypto::RSAPrivateKey> key);
46 virtual ~RsaKeyPair();
47
48 scoped_ptr<crypto::RSAPrivateKey> key_;
49
50 DISALLOW_COPY_AND_ASSIGN(RsaKeyPair);
51 };
52
53 } // namespace remoting
54
55 #endif // REMOTING_BASE_RSA_KEY_PAIR_H_
OLDNEW
« no previous file with comments | « no previous file | remoting/base/rsa_key_pair.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698