NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.3: 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; -*- */
22 #ifndef NDN_SECURITY_SIGNING_INFO_HPP
23 #define NDN_SECURITY_SIGNING_INFO_HPP
24 
25 #include "../name.hpp"
26 #include "../signature-info.hpp"
27 #include "pib/identity.hpp"
28 #include "pib/key.hpp"
29 #include "security-common.hpp"
30 
31 namespace ndn {
32 namespace security {
33 
41 {
42 public:
43  class Error : public std::runtime_error
44  {
45  public:
46  explicit
47  Error(const std::string& what)
48  : std::runtime_error(what)
49  {
50  }
51  };
52 
53  enum SignerType {
64  };
65 
66 public:
76  explicit
78  const Name& signerName = getEmptyName(),
79  const SignatureInfo& signatureInfo = getEmptySignatureInfo());
80 
84  explicit
85  SigningInfo(const Identity& identity);
86 
90  explicit
91  SigningInfo(const Key& key);
92 
105  explicit
106  SigningInfo(const std::string& signingStr);
107 
112  SigningInfo&
113  setSigningIdentity(const Name& identity);
114 
119  SigningInfo&
120  setSigningKeyName(const Name& keyName);
121 
126  SigningInfo&
127  setSigningCertName(const Name& certificateName);
128 
133  SigningInfo&
135 
140  SigningInfo&
141  setPibIdentity(const Identity& identity);
142 
147  SigningInfo&
148  setPibKey(const Key& key);
149 
153  SignerType
155  {
156  return m_type;
157  }
158 
162  const Name&
164  {
165  return m_name;
166  }
167 
173  const Identity&
175  {
176  BOOST_ASSERT(m_type == SIGNER_TYPE_ID);
177  return m_identity;
178  }
179 
184  const Key&
185  getPibKey() const
186  {
187  BOOST_ASSERT(m_type == SIGNER_TYPE_KEY);
188  return m_key;
189  }
190 
194  SigningInfo&
196  {
197  m_digestAlgorithm = algorithm;
198  return *this;
199  }
200 
206  {
207  return m_digestAlgorithm;
208  }
209 
213  SigningInfo&
214  setSignatureInfo(const SignatureInfo& signatureInfo);
215 
219  const SignatureInfo&
221  {
222  return m_info;
223  }
224 
225 public:
226  static const Name&
227  getEmptyName();
228 
229  static const SignatureInfo&
231 
235  static const Name&
237 
238  bool
239  operator==(const SigningInfo& rhs) const;
240 
241  bool
242  operator!=(const SigningInfo& rhs) const
243  {
244  return !(*this == rhs);
245  }
246 
247 private:
248  SignerType m_type;
249  Name m_name;
250  Identity m_identity;
251  Key m_key;
252  DigestAlgorithm m_digestAlgorithm;
253  SignatureInfo m_info;
254 };
255 
256 std::ostream&
257 operator<<(std::ostream& os, const SigningInfo& si);
258 
259 } // namespace security
260 } // namespace ndn
261 
262 #endif // NDN_SECURITY_SIGNING_INFO_HPP
SigningInfo & setPibIdentity(const Identity &identity)
Set signer as a PIB identity handler identity.
bool operator==(const SigningInfo &rhs) const
Copyright (c) 2011-2015 Regents of the University of California.
Represents a SignatureInfo TLV element.
const Name & getSignerName() const
SigningInfo(SignerType signerType=SIGNER_TYPE_NULL, const Name &signerName=getEmptyName(), const SignatureInfo &signatureInfo=getEmptySignatureInfo())
Constructor.
SigningInfo & setDigestAlgorithm(const DigestAlgorithm &algorithm)
Set the digest algorithm for public key operations.
STL namespace.
use sha256 digest, no signer needs to be specified
Signing parameters passed to KeyChain.
Catch-all error for security policy errors that don&#39;t fit in other categories.
Definition: base.hpp:79
const Identity & getPibIdentity() const
SigningInfo & setSha256Signing()
Set Sha256 as the signing method.
no signer is specified, use default setting or follow the trust schema
const SignatureInfo & getSignatureInfo() const
Error(const std::string &what)
static const Name & getDigestSha256Identity()
A localhost identity to indicate that the signature is generated using SHA-256.
Represents an absolute name.
Definition: name.hpp:42
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;.
static const Name & getEmptyName()
SigningInfo & setSigningIdentity(const Name &identity)
Set signer as an identity with name identity.
signer is an identity, use its default key and default certificate
const Key & getPibKey() const
SigningInfo & setPibKey(const Key &key)
Set signer as a PIB key handler key.
bool operator!=(const SigningInfo &rhs) const
DigestAlgorithm getDigestAlgorithm() const
std::ostream & operator<<(std::ostream &os, const SigningInfo &si)
SignerType getSignerType() const
SigningInfo & setSigningKeyName(const Name &keyName)
Set signer as a key with name keyName.