NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
key.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_KEY_HPP
23 #define NDN_SECURITY_PIB_KEY_HPP
24 
27 
28 namespace ndn {
29 namespace security {
30 
31 namespace v2 {
32 class KeyChain;
33 } // namespace v2
34 
35 namespace pib {
36 
37 namespace detail {
38 class KeyImpl;
39 } // namespace detail
40 
49 class Key
50 {
51 public:
70  Key();
71 
77  explicit
78  Key(weak_ptr<detail::KeyImpl> impl);
79 
83  const Name&
84  getName() const;
85 
89  const Name&
90  getIdentity() const;
91 
95  KeyType
96  getKeyType() const;
97 
101  const Buffer&
102  getPublicKey() const;
103 
110  getCertificate(const Name& certName) const;
111 
115  const CertificateContainer&
116  getCertificates() const;
117 
122  const v2::Certificate&
123  getDefaultCertificate() const;
124 
128  explicit
129  operator bool() const;
130 
131 NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE: // write operations should be private
139  void
140  addCertificate(const v2::Certificate& certificate) const;
141 
146  void
147  removeCertificate(const Name& certName) const;
148 
155  const v2::Certificate&
156  setDefaultCertificate(const Name& certName) const;
157 
163  const v2::Certificate&
164  setDefaultCertificate(const v2::Certificate& certificate) const;
165 
166 private:
172  shared_ptr<detail::KeyImpl>
173  lock() const;
174 
175 private:
176  weak_ptr<detail::KeyImpl> m_impl;
177 
178  friend class v2::KeyChain;
179  friend bool operator!=(const Key&, const Key&);
180 };
181 
182 bool
183 operator!=(const Key& lhs, const Key& rhs);
184 
185 inline bool
186 operator==(const Key& lhs, const Key& rhs)
187 {
188  return !(lhs != rhs);
189 }
190 
191 std::ostream&
192 operator<<(std::ostream& os, const Key& key);
193 
194 } // namespace pib
195 
196 using pib::Key;
197 
198 namespace v2 {
199 
203 Name
204 constructKeyName(const Name& identity, const name::Component& keyId);
205 
209 bool
210 isValidKeyName(const Name& keyName);
211 
215 Name
216 extractIdentityFromKeyName(const Name& keyName);
217 
218 } // namespace v2
219 
220 } // namespace security
221 } // namespace ndn
222 
223 #endif // NDN_SECURITY_PIB_KEY_HPP
ndn::KeyType
KeyType
The type of a cryptographic key.
Definition: security-common.hpp:85
ndn::security::pib::Key::setDefaultCertificate
const v2::Certificate & setDefaultCertificate(const Name &certName) const
Set an existing certificate with certName as the default certificate.
Definition: key.cpp:86
ndn::security::pib::Key::getDefaultCertificate
const v2::Certificate & getDefaultCertificate() const
Get the default certificate for this Key.
Definition: key.cpp:98
security-common.hpp
ndn::security::v2::isValidKeyName
bool isValidKeyName(const Name &keyName)
Check if keyName follow the naming conventions for the key name.
Definition: key.cpp:153
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::v2::constructKeyName
Name constructKeyName(const Name &identity, const name::Component &keyId)
Construct key name based on the appropriate naming conventions.
Definition: key.cpp:143
ndn::security::pib::Key::getKeyType
KeyType getKeyType() const
Get key type.
Definition: key.cpp:50
ndn::security::v2::extractIdentityFromKeyName
Name extractIdentityFromKeyName(const Name &keyName)
Extract identity namespace from the key name keyName.
Definition: key.cpp:160
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::operator!=
bool operator!=(const Identity &lhs, const Identity &rhs)
Definition: identity.cpp:101
ndn::security::v2::KeyChain
The interface of signing key management.
Definition: key-chain.hpp:47
certificate-container.hpp
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE
#define NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE
Definition: common.hpp:48
ndn::security::pib::Key::removeCertificate
void removeCertificate(const Name &certName) const
Remove a certificate with certName.
Definition: key.cpp:68
ndn::security::pib::operator<<
std::ostream & operator<<(std::ostream &os, const Identity &id)
Definition: identity.cpp:107
ndn::security::pib::operator==
bool operator==(const Identity &lhs, const Identity &rhs)
Definition: identity.hpp:162
ndn::security::pib::Key::getCertificate
v2::Certificate getCertificate(const Name &certName) const
Get a certificate with certName.
Definition: key.cpp:74
ndn::security::pib::Key::getCertificates
const CertificateContainer & getCertificates() const
Get all certificates for this key.
Definition: key.cpp:80
ndn::name::Component
Represents a name component.
Definition: name-component.hpp:94
ndn::security::pib::Key::getName
const Name & getName() const
Get key name.
Definition: key.cpp:38
ndn::security::pib::Key
A frontend handle of a key instance.
Definition: key.hpp:50
ndn::security::pib::Key::getIdentity
const Name & getIdentity() const
Get the name of the belonging identity.
Definition: key.cpp:44
ndn::security::v2::KeyChain
ndn security v2 KeyChain
Definition: key-chain.cpp:68
ndn::security::pib::Key::getPublicKey
const Buffer & getPublicKey() const
Get public key bits.
Definition: key.cpp:56
ndn::security::pib::Key::Key
Key()
Default Constructor.
ndn::security::pib::Key::operator!=
friend bool operator!=(const Key &, const Key &)
Definition: key.cpp:121
ndn
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-strategy-choice-helper.hpp:34