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-2022 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_CXX_SECURITY_CERTIFICATE_HPP
26 #define NDN_CXX_SECURITY_CERTIFICATE_HPP
27 
28 #include "ndn-cxx/data.hpp"
29 
30 namespace ndn {
31 namespace security {
32 inline namespace v2 {
33 
60 class Certificate : public Data
61 {
62 public:
63  Certificate();
64 
69  explicit
70  Certificate(Data&& data);
71 
76  explicit
77  Certificate(const Data& data);
78 
83  explicit
84  Certificate(const Block& block);
85 
89  Name
90  getKeyName() const;
91 
95  Name
96  getIdentity() const;
97 
102  getKeyId() const;
103 
108  getIssuerId() const;
109 
114  Buffer
115  getPublicKey() const;
116 
121  getValidityPeriod() const;
122 
126  bool
128 
133  Block
134  getExtension(uint32_t type) const;
135 
136  // @TODO Implement extension enumeration (Issue #3907)
137 public:
141  static bool
142  isValidName(const Name& certName);
143 
144 public:
145  static const ssize_t VERSION_OFFSET;
146  static const ssize_t ISSUER_ID_OFFSET;
147  static const ssize_t KEY_COMPONENT_OFFSET;
148  static const ssize_t KEY_ID_OFFSET;
149  static const size_t MIN_CERT_NAME_LENGTH;
150  static const size_t MIN_KEY_NAME_LENGTH;
153 };
154 
155 std::ostream&
156 operator<<(std::ostream& os, const Certificate& cert);
157 
161 Name
162 extractIdentityFromCertName(const Name& certName);
163 
167 Name
168 extractKeyNameFromCertName(const Name& certName);
169 
170 } // inline namespace v2
171 } // namespace security
172 } // namespace ndn
173 
174 #endif // NDN_CXX_SECURITY_CERTIFICATE_HPP
Copyright (c) 2011-2015 Regents of the University of California.
static const ssize_t KEY_ID_OFFSET
Represents an NDN certificate following the version 2.0 format.
Definition: certificate.hpp:60
Buffer getPublicKey() const
Get public key bits (in PKCS#8 format)
name::Component getIssuerId() const
Get issuer ID.
Definition: certificate.cpp:98
static const size_t MIN_KEY_NAME_LENGTH
Name getIdentity() const
Get identity name.
Definition: certificate.cpp:86
Name extractKeyNameFromCertName(const Name &certName)
Extract key name from the certificate name certName.
Represents a TLV element of the NDN packet format.
Definition: block.hpp:44
static time_point now() noexcept
Definition: time.cpp:46
static const size_t MIN_CERT_NAME_LENGTH
std::ostream & operator<<(std::ostream &os, const AdditionalDescription &desc)
Represents a ValidityPeriod TLV element.
static const ssize_t KEY_COMPONENT_OFFSET
static const ssize_t VERSION_OFFSET
Name getKeyName() const
Get key name.
Definition: certificate.cpp:80
Represents an absolute name.
Definition: name.hpp:41
Represents a name component.
name::Component getKeyId() const
Get key ID.
Definition: certificate.cpp:92
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
Block getExtension(uint32_t type) const
Get extension with TLV type.
ValidityPeriod getValidityPeriod() const
Get validity period of the certificate.
Represents a Data packet.
Definition: data.hpp:37
General-purpose automatically managed/resized buffer.
Definition: buffer.hpp:41
bool isValid(const time::system_clock::TimePoint &ts=time::system_clock::now()) const
Check if the certificate is valid at ts.
time_point TimePoint
Definition: time.hpp:203
static const name::Component DEFAULT_ISSUER_ID
Name extractIdentityFromCertName(const Name &certName)
Extract identity namespace from the certificate name certName.