summaryrefslogtreecommitdiffstats
path: root/remoting/host/pairing_registry_delegate_win.h
blob: 93ce5cb4c9b2f889fafdd1b563471896ebf07945 (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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// Copyright 2013 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_PROTOCOL_PAIRING_REGISTRY_DELEGATE_WIN_H_
#define REMOTING_PROTOCOL_PAIRING_REGISTRY_DELEGATE_WIN_H_

#include <string>

#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
#include "base/win/registry.h"
#include "remoting/protocol/pairing_registry.h"

namespace base {
class ListValue;
}  // namespace base

namespace remoting {

#if defined(OFFICIAL_BUILD)
const wchar_t kPairingRegistryKeyName[] =
    L"SOFTWARE\\Google\\Chrome Remote Desktop\\paired-clients";
#else
const wchar_t kPairingRegistryKeyName[] =
    L"SOFTWARE\\Chromoting\\paired-clients";
#endif

const wchar_t kPairingRegistryClientsKeyName[] = L"secrets";
const wchar_t kPairingRegistrySecretsKeyName[] = L"clients";

// Stores client pairing information in Windows registry. Two separate registry
// keys are used:
//  - |privileged| - contains the shared secrets of all pairings. This key must
//                   be protected by a strong ACL denying access to unprivileged
//                   code.
//  - |unprivileged| - contains the rest of pairing state.
//
// Creator of this object is responsible for passing the registry key handles
// with appropriate access. |privileged| may be NULL if read-only access is
// sufficient. Shared secrets will not be returned in such a case.
class PairingRegistryDelegateWin
    : public protocol::PairingRegistry::Delegate {
 public:
  PairingRegistryDelegateWin();
  virtual ~PairingRegistryDelegateWin();

  // Passes the root keys to be used to access the pairing registry store.
  // |privileged| is optional and may be NULL. The caller retains ownership of
  // the passed handles.
  bool SetRootKeys(HKEY privileged, HKEY unprivileged);

  // PairingRegistry::Delegate interface
  virtual scoped_ptr<base::ListValue> LoadAll() OVERRIDE;
  virtual bool DeleteAll() OVERRIDE;
  virtual protocol::PairingRegistry::Pairing Load(
      const std::string& client_id) OVERRIDE;
  virtual bool Save(const protocol::PairingRegistry::Pairing& pairing) OVERRIDE;
  virtual bool Delete(const std::string& client_id) OVERRIDE;

 private:
  base::win::RegKey privileged_;
  base::win::RegKey unprivileged_;

  DISALLOW_COPY_AND_ASSIGN(PairingRegistryDelegateWin);
};

}  // namespace remoting

#endif  // REMOTING_PROTOCOL_PAIRING_REGISTRY_DELEGATE_WIN_H_