ndn-cxx: NDN C++ Library 0.9.0-34-ga362e65e
Loading...
Searching...
No Matches
back-end.hpp
Go to the documentation of this file.
1/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2013-2025 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_BACK_END_HPP
23#define NDN_CXX_SECURITY_TPM_BACK_END_HPP
24
26
27namespace ndn::security::tpm {
28
34class BackEnd : noncopyable
35{
36public:
38
39 virtual
41
42public: // key management
48 bool
49 hasKey(const Name& keyName) const;
50
59 unique_ptr<KeyHandle>
60 getKeyHandle(const Name& keyName) const;
61
69 unique_ptr<KeyHandle>
70 createKey(const Name& identityName, const KeyParams& params);
71
80 void
81 deleteKey(const Name& keyName);
82
94 exportKey(const Name& keyName, const char* pw, size_t pwLen);
95
106 void
107 importKey(const Name& keyName, span<const uint8_t> pkcs8, const char* pw, size_t pwLen);
108
114 void
115 importKey(const Name& keyName, shared_ptr<transform::PrivateKey> key);
116
117protected: // helper methods
121 Name
122 constructAsymmetricKeyName(const KeyHandle& key, const Name& identity,
123 const KeyParams& params) const;
124
128 Name
129 constructHmacKeyName(const transform::PrivateKey& key, const Name& identity,
130 const KeyParams& params) const;
131
132private: // pure virtual methods
133 virtual bool
134 doHasKey(const Name& keyName) const = 0;
135
136 virtual unique_ptr<KeyHandle>
137 doGetKeyHandle(const Name& keyName) const = 0;
138
139 virtual unique_ptr<KeyHandle>
140 doCreateKey(const Name& identity, const KeyParams& params) = 0;
141
142 virtual void
143 doDeleteKey(const Name& keyName) = 0;
144
145 virtual ConstBufferPtr
146 doExportKey(const Name& keyName, const char* pw, size_t pwLen) = 0;
147
148 virtual void
149 doImportKey(const Name& keyName, span<const uint8_t> pkcs8, const char* pw, size_t pwLen) = 0;
150
151 virtual void
152 doImportKey(const Name& keyName, shared_ptr<transform::PrivateKey> key) = 0;
153};
154
155} // namespace ndn::security::tpm
156
157#endif // NDN_CXX_SECURITY_TPM_BACK_END_HPP
Base class for key parameters.
Represents an absolute name.
Definition name.hpp:45
Abstract interface for a TPM backend implementation.
Definition back-end.hpp:35
unique_ptr< KeyHandle > createKey(const Name &identityName, const KeyParams &params)
Create a key for identityName according to params.
Definition back-end.cpp:51
void importKey(const Name &keyName, span< const uint8_t > pkcs8, const char *pw, size_t pwLen)
Import a private key in encrypted PKCS #8 format.
Definition back-end.cpp:94
bool hasKey(const Name &keyName) const
Check if the key with name keyName exists in the TPM.
Definition back-end.cpp:39
Name constructAsymmetricKeyName(const KeyHandle &key, const Name &identity, const KeyParams &params) const
Construct and return the name of a RSA or EC key, based on identity and params.
Definition back-end.cpp:112
void deleteKey(const Name &keyName)
Delete the key with name keyName.
Definition back-end.cpp:79
ConstBufferPtr exportKey(const Name &keyName, const char *pw, size_t pwLen)
Get the private key with name keyName in encrypted PKCS #8 format.
Definition back-end.cpp:85
unique_ptr< KeyHandle > getKeyHandle(const Name &keyName) const
Get the handle of the key with name keyName.
Definition back-end.cpp:45
Name constructHmacKeyName(const transform::PrivateKey &key, const Name &identity, const KeyParams &params) const
Construct and return the name of a HMAC key, based on identity and params.
Definition back-end.cpp:142
Abstraction of TPM key handle.
Abstraction of a private key in crypto transformations.
std::shared_ptr< const Buffer > ConstBufferPtr
Definition buffer.hpp:140