NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.3: 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-2017 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 
26 #include "../security-common.hpp"
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
Copyright (c) 2011-2015 Regents of the University of California.
The certificate following the certificate format naming convention.
Definition: certificate.hpp:81
The interface of signing key management.
Definition: key-chain.hpp:46
#define NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE
Definition: common.hpp:43
bool operator!=(const Data &lhs, const Data &rhs)
Definition: data.hpp:259
bool isValidKeyName(const Name &keyName)
Check if keyName follow the naming conventions for the key name.
Definition: key.cpp:153
Catch-all error for security policy errors that don&#39;t fit in other categories.
Definition: base.hpp:79
KeyType
The type of a cryptographic key.
Container of certificates of a key.
A frontend handle of a key instance.
Definition: key.hpp:49
Represents an absolute name.
Definition: name.hpp:42
std::ostream & operator<<(std::ostream &os, const AdditionalDescription &other)
Component holds a read-only name component value.
Name constructKeyName(const Name &identity, const name::Component &keyId)
Construct key name based on the appropriate naming conventions.
Definition: key.cpp:143
bool operator==(const Data &lhs, const Data &rhs)
Definition: data.cpp:265
Name extractIdentityFromKeyName(const Name &keyName)
Extract identity namespace from the key name keyName.
Definition: key.cpp:160
General-purpose automatically managed/resized buffer.
Definition: buffer.hpp:40
ndn security v2 KeyChain
Definition: key-chain.cpp:76