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-2018 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_PIB_IMPL_KEY_IMPL_HPP
23 #define NDN_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:
59  KeyImpl(const Name& keyName, const uint8_t* key, size_t keyLen, shared_ptr<PibImpl> pibImpl);
60 
68  KeyImpl(const Name& keyName, shared_ptr<PibImpl> pibImpl);
69 
73  const Name&
74  getName() const
75  {
76  return m_keyName;
77  }
78 
82  const Name&
83  getIdentity() const
84  {
85  return m_identity;
86  }
87 
91  KeyType
92  getKeyType() const
93  {
94  return m_keyType;
95  }
96 
100  const Buffer&
101  getPublicKey() const
102  {
103  return m_key;
104  }
105 
117  void
118  addCertificate(const v2::Certificate& certificate);
119 
124  void
125  removeCertificate(const Name& certName);
126 
133  getCertificate(const Name& certName) const;
134 
138  const CertificateContainer&
139  getCertificates() const;
140 
147  const v2::Certificate&
148  setDefaultCertificate(const Name& certName);
149 
159  const v2::Certificate&
160  setDefaultCertificate(const v2::Certificate& certificate);
161 
166  const v2::Certificate&
167  getDefaultCertificate() const;
168 
169 private:
170  Name m_identity;
171  Name m_keyName;
172  Buffer m_key;
173  KeyType m_keyType;
174 
175  shared_ptr<PibImpl> m_pib;
176 
177  CertificateContainer m_certificates;
178  mutable bool m_isDefaultCertificateLoaded;
179  mutable v2::Certificate m_defaultCertificate;
180 };
181 
182 } // namespace detail
183 } // namespace pib
184 } // namespace security
185 } // namespace ndn
186 
187 #endif // NDN_SECURITY_PIB_IMPL_KEY_IMPL_HPP
ndn::KeyType
KeyType
The type of a cryptographic key.
Definition: security-common.hpp:85
ndn::security::pib::detail::KeyImpl::getPublicKey
const Buffer & getPublicKey() const
Get public key bits.
Definition: key-impl.hpp:101
security-common.hpp
ndn::security::pib::detail::KeyImpl::KeyImpl
KeyImpl(const Name &keyName, const uint8_t *key, size_t keyLen, shared_ptr< PibImpl > pibImpl)
Create a KeyImpl with keyName.
Definition: key-impl.cpp:32
ndn::Buffer
General-purpose automatically managed/resized buffer.
Definition: buffer.hpp:41
ndn::security::pib::CertificateContainer
Container of certificates of a key.
Definition: certificate-container.hpp:48
ndn::security::pib::detail::KeyImpl::setDefaultCertificate
const v2::Certificate & setDefaultCertificate(const Name &certName)
Set an existing certificate with name certName as the default certificate.
Definition: key-impl.cpp:103
ndn::security::pib::detail::KeyImpl::getCertificate
v2::Certificate getCertificate(const Name &certName) const
Get a certificate with certName.
Definition: key-impl.cpp:89
ndn::security::pib::detail::KeyImpl::getKeyType
KeyType getKeyType() const
Get key type.
Definition: key-impl.hpp:92
ndn::Name
Represents an absolute name.
Definition: name.hpp:44
ndn::security::v2::Certificate
The certificate following the certificate format naming convention.
Definition: certificate.hpp:82
ndn::security::pib::detail::KeyImpl::removeCertificate
void removeCertificate(const Name &certName)
Remove a certificate with certName.
Definition: key-impl.cpp:78
certificate-container.hpp
ndn::security::pib::detail::KeyImpl::getDefaultCertificate
const v2::Certificate & getDefaultCertificate() const
Get the default certificate for this key.
Definition: key-impl.cpp:121
ndn::security::pib::detail::KeyImpl
Backend instance of Key.
Definition: key-impl.hpp:45
ndn::security::pib::detail::KeyImpl::getIdentity
const Name & getIdentity() const
Get the name of the belonging identity.
Definition: key-impl.hpp:83
ndn::security::pib::detail::KeyImpl::addCertificate
void addCertificate(const v2::Certificate &certificate)
Add certificate.
Definition: key-impl.cpp:71
ndn::security::pib::detail::KeyImpl::getName
const Name & getName() const
Get the name of the key.
Definition: key-impl.hpp:74
ndn::security::pib::detail::KeyImpl::getCertificates
const CertificateContainer & getCertificates() const
Get all the certificates for this key.
Definition: key-impl.cpp:96
ndn
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-strategy-choice-helper.hpp:34