blob: f7aa651a8d3d3f1db33e375fcb8ecfb957342ad3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef REMOTING_HOST_HOST_KEY_PAIR_H_
#define REMOTING_HOST_HOST_KEY_PAIR_H_
#include <string>
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
namespace crypto {
class RSAPrivateKey;
} // namespace base
namespace remoting {
class HostConfig;
class MutableHostConfig;
class HostKeyPair {
public:
HostKeyPair();
~HostKeyPair();
void Generate();
bool LoadFromString(const std::string& key_base64);
bool Load(const HostConfig& host_config);
void Save(MutableHostConfig* host_config);
crypto::RSAPrivateKey* private_key() { return key_.get(); }
std::string GetAsString() const;
std::string GetPublicKey() const;
std::string GetSignature(const std::string& message) const;
// Make a new copy of private key. Caller will own the generated private key.
crypto::RSAPrivateKey* CopyPrivateKey() const;
// Generates self-signed certificate using the key pair. Returns empty string
// if cert generation fails (e.g. it may happen when the system clock is off).
std::string GenerateCertificate() const;
private:
scoped_ptr<crypto::RSAPrivateKey> key_;
};
} // namespace remoting
#endif // REMOTING_HOST_HOST_KEY_PAIR_H_
|