NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
certificate.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  * @author Zhiyi Zhang <dreamerbarrychang@gmail.com>
22  * @author Yingdi Yu <http://irl.cs.ucla.edu/~yingdi/>
23  */
24 
25 #ifndef NDN_SECURITY_V2_CERTIFICATE_HPP
26 #define NDN_SECURITY_V2_CERTIFICATE_HPP
27 
28 #include "ndn-cxx/data.hpp"
29 
30 namespace ndn {
31 namespace security {
32 namespace v2 {
33 
81 class Certificate : public Data
82 {
83 public:
84  Certificate();
85 
90  explicit
91  Certificate(Data&& data);
92 
97  explicit
98  Certificate(const Data& data);
99 
104  explicit
105  Certificate(const Block& block);
106 
110  Name
111  getKeyName() const;
112 
116  Name
117  getIdentity() const;
118 
123  getKeyId() const;
124 
129  getIssuerId() const;
130 
135  Buffer
136  getPublicKey() const;
137 
142  getValidityPeriod() const;
143 
147  bool
149 
154  const Block&
155  getExtension(uint32_t type) const;
156 
157  // @TODO Implement extension enumeration (Issue #3907)
158 public:
162  static bool
163  isValidName(const Name& certName);
164 
165 public:
166  static const ssize_t VERSION_OFFSET;
167  static const ssize_t ISSUER_ID_OFFSET;
168  static const ssize_t KEY_COMPONENT_OFFSET;
169  static const ssize_t KEY_ID_OFFSET;
170  static const size_t MIN_CERT_NAME_LENGTH;
171  static const size_t MIN_KEY_NAME_LENGTH;
173 };
174 
175 std::ostream&
176 operator<<(std::ostream& os, const Certificate& cert);
177 
181 Name
182 extractIdentityFromCertName(const Name& certName);
183 
187 Name
188 extractKeyNameFromCertName(const Name& certName);
189 
190 } // namespace v2
191 } // namespace security
192 } // namespace ndn
193 
194 #endif // NDN_SECURITY_V2_CERTIFICATE_HPP
Copyright (c) 2011-2015 Regents of the University of California.
static const ssize_t KEY_ID_OFFSET
The certificate following the certificate format naming convention.
Definition: certificate.hpp:81
Buffer getPublicKey() const
Get public key bits (in PKCS#8 format)
name::Component getIssuerId() const
Get issuer ID.
Definition: certificate.cpp:99
static const size_t MIN_KEY_NAME_LENGTH
Name getIdentity() const
Get identity name.
Definition: certificate.cpp:87
Name extractKeyNameFromCertName(const Name &certName)
Extract key name from the certificate name certName.
Represents a TLV element of NDN packet format.
Definition: block.hpp:42
static time_point now() noexcept
Definition: time.cpp:46
static const size_t MIN_CERT_NAME_LENGTH
Abstraction of validity period.
static const ssize_t KEY_COMPONENT_OFFSET
static const ssize_t VERSION_OFFSET
Name getKeyName() const
Get key name.
Definition: certificate.cpp:81
Represents an absolute name.
Definition: name.hpp:43
time_point TimePoint
Definition: time.hpp:195
std::ostream & operator<<(std::ostream &os, const AdditionalDescription &other)
Represents a name component.
name::Component getKeyId() const
Get key ID.
Definition: certificate.cpp:93
static bool isValidName(const Name &certName)
Check if the specified name follows the naming convention for the certificate.
static const name::Component KEY_COMPONENT
static const ssize_t ISSUER_ID_OFFSET
ValidityPeriod getValidityPeriod() const
Get validity period of the certificate.
Represents a Data packet.
Definition: data.hpp:35
const Block & getExtension(uint32_t type) const
Get extension with TLV type.
General-purpose automatically managed/resized buffer.
Definition: buffer.hpp:40
bool isValid(const time::system_clock::TimePoint &ts=time::system_clock::now()) const
Check if the certificate is valid at ts.
Name extractIdentityFromCertName(const Name &certName)
Extract identity namespace from the certificate name certName.