NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
tpm.hpp
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2013-2022 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_CXX_SECURITY_TPM_TPM_HPP
23
#define NDN_CXX_SECURITY_TPM_TPM_HPP
24
25
#include "
ndn-cxx/name.hpp
"
26
#include "
ndn-cxx/security/key-params.hpp
"
27
#include "
ndn-cxx/security/tpm/key-handle.hpp
"
28
29
#include <unordered_map>
30
#include <boost/logic/tribool.hpp>
31
32
namespace
ndn
{
33
namespace
security
{
34
35
namespace
transform
{
36
class
PrivateKey;
37
}
// namespace transform
38
39
inline
namespace
v2 {
40
class
KeyChain
;
41
}
// inline namespace v2
42
43
namespace
tpm {
44
45
class
BackEnd;
46
65
class
Tpm
: noncopyable
66
{
67
public
:
68
class
Error
:
public
std::runtime_error
69
{
70
public
:
71
using
std::runtime_error::runtime_error;
72
};
73
74
~
Tpm
();
75
76
std::string
77
getTpmLocator()
const
;
78
85
bool
86
hasKey(
const
Name
& keyName)
const
;
87
94
ConstBufferPtr
95
getPublicKey(
const
Name
& keyName)
const
;
96
103
ConstBufferPtr
104
sign(
const
InputBuffers&
bufs
,
const
Name
& keyName,
DigestAlgorithm
digestAlgorithm)
const
;
105
114
NDN_CXX_NODISCARD
boost::logic::tribool
115
verify(
const
InputBuffers& bufs, span<const uint8_t>
sig
,
const
Name
& keyName,
116
DigestAlgorithm
digestAlgorithm)
const
;
117
123
ConstBufferPtr
124
decrypt(span<const uint8_t> buf,
const
Name
& keyName)
const
;
125
126
public
:
// Management
130
bool
131
isTerminalMode()
const
;
132
138
void
139
setTerminalMode(
bool
isTerminal)
const
;
140
144
bool
145
isTpmLocked()
const
;
146
153
NDN_CXX_NODISCARD
bool
154
unlockTpm(
const
char
* password,
size_t
passwordLength)
const
;
155
156
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE
:
164
Tpm
(
const
std::string& scheme,
const
std::string& location, unique_ptr<BackEnd> impl);
165
176
Name
177
createKey(
const
Name
& identityName,
const
KeyParams
& params);
178
182
void
183
deleteKey(
const
Name
& keyName);
184
197
ConstBufferPtr
198
exportPrivateKey(
const
Name
& keyName,
const
char
* pw,
size_t
pwLen)
const
;
199
212
void
213
importPrivateKey(
const
Name
& keyName, span<const uint8_t> pkcs8,
const
char
* pw,
size_t
pwLen);
214
218
void
219
importPrivateKey(
const
Name
& keyName, shared_ptr<transform::PrivateKey> key);
220
226
void
227
clearKeyCache
()
228
{
229
m_keys.clear();
230
}
231
232
private
:
238
const
KeyHandle
*
239
findKey(
const
Name
& keyName)
const
;
240
241
private
:
242
std::string m_scheme;
243
std::string m_location;
244
245
mutable
std::unordered_map<Name, unique_ptr<KeyHandle>> m_keys;
246
247
const
unique_ptr<BackEnd> m_backEnd;
248
249
friend
KeyChain
;
250
};
251
252
}
// namespace tpm
253
254
using
tpm::Tpm
;
255
256
}
// namespace security
257
}
// namespace ndn
258
259
#endif // NDN_CXX_SECURITY_TPM_TPM_HPP
key-handle.hpp
ndn
Copyright (c) 2011-2015 Regents of the University of California.
Definition:
ndn-strategy-choice-helper.hpp:34
ndn::security::v2::KeyChain
ndn security KeyChain
Definition:
key-chain.cpp:70
key-params.hpp
ndn::security::tpm::KeyHandle
Abstraction of TPM key handle.
Definition:
key-handle.hpp:37
ndn::security::tpm::Tpm
TPM front-end class.
Definition:
tpm.hpp:65
ndn::security::tpm::Tpm::clearKeyCache
void clearKeyCache()
Clear the key cache.
Definition:
tpm.hpp:227
NDN_CXX_NODISCARD
#define NDN_CXX_NODISCARD
Definition:
backports.hpp:68
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE
#define NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE
Definition:
common.hpp:48
ndn::Name
Represents an absolute name.
Definition:
name.hpp:41
transform
ndn::security
Definition:
dummy-keychain.cpp:28
ndn::KeyParams
Base class for key parameters.
Definition:
key-params.hpp:35
name.hpp
bufs
InputBuffers bufs
Definition:
verification-helpers.cpp:57
ndn::DigestAlgorithm
DigestAlgorithm
Definition:
security-common.hpp:106
ndn::security::tpm::Tpm::Error
Definition:
tpm.hpp:68
sig
span< const uint8_t > sig
Definition:
verification-helpers.cpp:58
ndn::ConstBufferPtr
shared_ptr< const Buffer > ConstBufferPtr
Definition:
buffer.hpp:139
ndnSIM
ndn-cxx
ndn-cxx
security
tpm
tpm.hpp
Generated on Fri May 6 2022 12:34:13 for ndnSIM by
1.8.13