NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.3: NDN, CCN, CCNx, content centric networks
API Documentation
back-end-osx.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2013-2017 Regents of the University of California.
4  *
5  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
6  *
7  * ndn-cxx library is free software: you can redistribute it and/or modify it under the
8  * terms of the GNU Lesser General Public License as published by the Free Software
9  * Foundation, either version 3 of the License, or (at your option) any later version.
10  *
11  * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
12  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13  * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
14  *
15  * You should have received copies of the GNU General Public License and GNU Lesser
16  * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
17  * <http://www.gnu.org/licenses/>.
18  *
19  * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
20  */
21 
22 #ifndef NDN_SECURITY_TPM_BACK_END_OSX_HPP
23 #define NDN_SECURITY_TPM_BACK_END_OSX_HPP
24 
25 #include "back-end.hpp"
26 #include "key-ref-osx.hpp"
27 
28 #ifndef NDN_CXX_HAVE_OSX_FRAMEWORKS
29 #error "This file should not be compiled ..."
30 #endif
31 
32 namespace ndn {
33 namespace security {
34 namespace tpm {
35 
39 class BackEndOsx : public BackEnd
40 {
41 public:
42  class Error : public BackEnd::Error
43  {
44  public:
45  explicit
46  Error(const std::string& what)
47  : BackEnd::Error(what)
48  {
49  }
50  };
51 
52 public:
57  explicit
58  BackEndOsx(const std::string& location = "");
59 
60  ~BackEndOsx() override;
61 
62  static const std::string&
63  getScheme();
64 
65 public: // management
66  bool
67  isTerminalMode() const final;
68 
69  void
70  setTerminalMode(bool isTerminal) const final;
71 
72  bool
73  isTpmLocked() const final;
74 
75  bool
76  unlockTpm(const char* pw, size_t pwLen) const final;
77 
78 public: // crypto transformation
82  static ConstBufferPtr
83  sign(const KeyRefOsx& key, DigestAlgorithm digestAlgorithm, const uint8_t* buf, size_t size);
84 
85  static ConstBufferPtr
86  decrypt(const KeyRefOsx& key, const uint8_t* cipherText, size_t cipherSize);
87 
88  static ConstBufferPtr
89  derivePublicKey(const KeyRefOsx& key);
90 
91 private: // inherited from tpm::BackEnd
95  bool
96  doHasKey(const Name& keyName) const final;
97 
101  unique_ptr<KeyHandle>
102  doGetKeyHandle(const Name& keyName) const final;
103 
112  unique_ptr<KeyHandle>
113  doCreateKey(const Name& identityName, const KeyParams& params) final;
114 
120  void
121  doDeleteKey(const Name& keyName) final;
122 
128  doExportKey(const Name& keyName, const char* pw, size_t pwLen) final;
129 
140  void
141  doImportKey(const Name& keyName, const uint8_t* buf, size_t size, const char* pw, size_t pwLen) final;
142 
143 private:
144  class Impl;
145  const unique_ptr<Impl> m_impl;
146 };
147 
148 } // namespace tpm
149 } // namespace security
150 } // namespace ndn
151 
152 #endif // NDN_SECURITY_TPM_BACK_END_OSX_HPP
static ConstBufferPtr decrypt(const KeyRefOsx &key, const uint8_t *cipherText, size_t cipherSize)
bool isTpmLocked() const final
Copyright (c) 2011-2015 Regents of the University of California.
The back-end implementation of TPM based on macOS Keychain Services.
Error(const std::string &what)
Abstraction of Tpm back-end.
Definition: back-end.hpp:41
Catch-all error for security policy errors that don&#39;t fit in other categories.
Definition: base.hpp:79
static const std::string & getScheme()
bool isTerminalMode() const final
Check if TPM is in terminal mode.
void setTerminalMode(bool isTerminal) const final
Set the terminal mode of TPM.
static ConstBufferPtr derivePublicKey(const KeyRefOsx &key)
BackEndOsx(const std::string &location="")
Create TPM backed based on macOS KeyChain service.
bool unlockTpm(const char *pw, size_t pwLen) const final
Unlock TPM.
Represents an absolute name.
Definition: name.hpp:42
static ConstBufferPtr sign(const KeyRefOsx &key, DigestAlgorithm digestAlgorithm, const uint8_t *buf, size_t size)
Sign buf with key using digestAlgorithm.
Base class of key parameters.
Definition: key-params.hpp:35
shared_ptr< const Buffer > ConstBufferPtr
Definition: buffer.hpp:89