NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
signing-info.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_SIGNING_INFO_HPP
23 #define NDN_SECURITY_SIGNING_INFO_HPP
24 
25 #include "ndn-cxx/name.hpp"
30 
31 namespace ndn {
32 namespace security {
33 
41 {
42 public:
43  class Error : public std::runtime_error
44  {
45  public:
46  using std::runtime_error::runtime_error;
47  };
48 
49  enum SignerType {
60  };
61 
62 public:
72  explicit
74  const Name& signerName = getEmptyName(),
75  const SignatureInfo& signatureInfo = getEmptySignatureInfo());
76 
80  explicit
81  SigningInfo(const Identity& identity);
82 
86  explicit
87  SigningInfo(const Key& key);
88 
101  explicit
102  SigningInfo(const std::string& signingStr);
103 
108  SigningInfo&
109  setSigningIdentity(const Name& identity);
110 
115  SigningInfo&
116  setSigningKeyName(const Name& keyName);
117 
122  SigningInfo&
123  setSigningCertName(const Name& certificateName);
124 
129  SigningInfo&
131 
136  SigningInfo&
137  setPibIdentity(const Identity& identity);
138 
143  SigningInfo&
144  setPibKey(const Key& key);
145 
149  SignerType
151  {
152  return m_type;
153  }
154 
158  const Name&
160  {
161  return m_name;
162  }
163 
169  const Identity&
171  {
172  BOOST_ASSERT(m_type == SIGNER_TYPE_ID);
173  return m_identity;
174  }
175 
180  const Key&
181  getPibKey() const
182  {
183  BOOST_ASSERT(m_type == SIGNER_TYPE_KEY);
184  return m_key;
185  }
186 
190  SigningInfo&
192  {
193  m_digestAlgorithm = algorithm;
194  return *this;
195  }
196 
202  {
203  return m_digestAlgorithm;
204  }
205 
209  SigningInfo&
210  setSignatureInfo(const SignatureInfo& signatureInfo);
211 
215  const SignatureInfo&
217  {
218  return m_info;
219  }
220 
221 public:
222  static const Name&
223  getEmptyName();
224 
225  static const SignatureInfo&
227 
231  static const Name&
233 
234  bool
235  operator==(const SigningInfo& rhs) const;
236 
237  bool
238  operator!=(const SigningInfo& rhs) const
239  {
240  return !(*this == rhs);
241  }
242 
243 private:
244  SignerType m_type;
245  Name m_name;
246  Identity m_identity;
247  Key m_key;
248  DigestAlgorithm m_digestAlgorithm;
249  SignatureInfo m_info;
250 };
251 
252 std::ostream&
253 operator<<(std::ostream& os, const SigningInfo& si);
254 
255 } // namespace security
256 } // namespace ndn
257 
258 #endif // NDN_SECURITY_SIGNING_INFO_HPP
SigningInfo & setPibIdentity(const Identity &identity)
Set signer as a PIB identity handler identity.
Copyright (c) 2011-2015 Regents of the University of California.
Represents a SignatureInfo TLV element.
const SignatureInfo & getSignatureInfo() const
DigestAlgorithm getDigestAlgorithm() const
SigningInfo(SignerType signerType=SIGNER_TYPE_NULL, const Name &signerName=getEmptyName(), const SignatureInfo &signatureInfo=getEmptySignatureInfo())
Constructor.
const Key & getPibKey() const
SigningInfo & setDigestAlgorithm(const DigestAlgorithm &algorithm)
Set the digest algorithm for public key operations.
bool operator==(const SigningInfo &rhs) const
use sha256 digest, no signer needs to be specified
Signing parameters passed to KeyChain.
const Name & getSignerName() const
A frontend handle of a key instance.
Definition: key.hpp:49
SigningInfo & setSha256Signing()
Set Sha256 as the signing method.
no signer is specified, use default setting or follow the trust schema
static const Name & getDigestSha256Identity()
A localhost identity to indicate that the signature is generated using SHA-256.
Represents an absolute name.
Definition: name.hpp:43
signer is a certificate, use it directly
static const SignatureInfo & getEmptySignatureInfo()
SigningInfo & setSigningCertName(const Name &certificateName)
Set signer as a certificate with name certificateName.
signer is a key, use its default certificate
SigningInfo & setSignatureInfo(const SignatureInfo &signatureInfo)
Set a semi-prepared SignatureInfo;.
const Identity & getPibIdentity() const
static const Name & getEmptyName()
bool operator!=(const SigningInfo &rhs) const
SigningInfo & setSigningIdentity(const Name &identity)
Set signer as an identity with name identity.
signer is an identity, use its default key and default certificate
A frontend handle of an Identity.
Definition: identity.hpp:42
SigningInfo & setPibKey(const Key &key)
Set signer as a PIB key handler key.
std::ostream & operator<<(std::ostream &os, const SigningInfo &si)
SigningInfo & setSigningKeyName(const Name &keyName)
Set signer as a key with name keyName.
SignerType getSignerType() const