NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
key-impl.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2013-2021 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_PIB_IMPL_KEY_IMPL_HPP
23 #define NDN_CXX_SECURITY_PIB_IMPL_KEY_IMPL_HPP
24 
27 
28 namespace ndn {
29 namespace security {
30 namespace pib {
31 
32 class PibImpl;
33 
34 namespace detail {
35 
44 class KeyImpl : noncopyable
45 {
46 public:
58  KeyImpl(const Name& keyName, span<const uint8_t> key, shared_ptr<PibImpl> pibImpl);
59 
67  KeyImpl(const Name& keyName, shared_ptr<PibImpl> pibImpl);
68 
72  const Name&
73  getName() const
74  {
75  return m_keyName;
76  }
77 
81  const Name&
82  getIdentity() const
83  {
84  return m_identity;
85  }
86 
90  KeyType
91  getKeyType() const
92  {
93  return m_keyType;
94  }
95 
99  span<const uint8_t>
100  getPublicKey() const
101  {
102  return m_key;
103  }
104 
116  void
117  addCertificate(const Certificate& certificate);
118 
123  void
124  removeCertificate(const Name& certName);
125 
131  Certificate
132  getCertificate(const Name& certName) const;
133 
137  const CertificateContainer&
138  getCertificates() const;
139 
146  const Certificate&
147  setDefaultCertificate(const Name& certName);
148 
158  const Certificate&
159  setDefaultCertificate(const Certificate& certificate);
160 
165  const Certificate&
166  getDefaultCertificate() const;
167 
168 private:
169  Name m_identity;
170  Name m_keyName;
171  Buffer m_key;
172  KeyType m_keyType;
173 
174  shared_ptr<PibImpl> m_pib;
175 
176  CertificateContainer m_certificates;
177  mutable bool m_isDefaultCertificateLoaded;
178  mutable Certificate m_defaultCertificate;
179 };
180 
181 } // namespace detail
182 } // namespace pib
183 } // namespace security
184 } // namespace ndn
185 
186 #endif // NDN_CXX_SECURITY_PIB_IMPL_KEY_IMPL_HPP
const Certificate & setDefaultCertificate(const Name &certName)
Set an existing certificate with name certName as the default certificate.
Definition: key-impl.cpp:103
Copyright (c) 2011-2015 Regents of the University of California.
const Certificate & getDefaultCertificate() const
Get the default certificate for this key.
Definition: key-impl.cpp:121
KeyType
The type of a cryptographic key.
Container of certificates of a key.
const Name & getName() const
Get the name of the key.
Definition: key-impl.hpp:73
KeyType getKeyType() const
Get key type.
Definition: key-impl.hpp:91
void addCertificate(const Certificate &certificate)
Add certificate.
Definition: key-impl.cpp:71
Represents an absolute name.
Definition: name.hpp:41
Certificate getCertificate(const Name &certName) const
Get a certificate with certName.
Definition: key-impl.cpp:89
void removeCertificate(const Name &certName)
Remove a certificate with certName.
Definition: key-impl.cpp:78
KeyImpl(const Name &keyName, span< const uint8_t > key, shared_ptr< PibImpl > pibImpl)
Create a KeyImpl with keyName.
Definition: key-impl.cpp:32
const Name & getIdentity() const
Get the name of the belonging identity.
Definition: key-impl.hpp:82
Backend instance of Key.
Definition: key-impl.hpp:44
General-purpose automatically managed/resized buffer.
Definition: buffer.hpp:41
span< const uint8_t > getPublicKey() const
Get public key bits.
Definition: key-impl.hpp:100
const CertificateContainer & getCertificates() const
Get all the certificates for this key.
Definition: key-impl.cpp:96