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 {
68  };
69 
70 public:
80  explicit
82  const Name& signerName = getEmptyName(),
83  const SignatureInfo& signatureInfo = getEmptySignatureInfo());
84 
88  explicit
89  SigningInfo(const Identity& identity);
90 
94  explicit
95  SigningInfo(const Key& key);
96 
109  explicit
110  SigningInfo(const std::string& signingStr);
111 
116  SigningInfo&
117  setSigningIdentity(const Name& identity);
118 
123  SigningInfo&
124  setSigningKeyName(const Name& keyName);
125 
130  SigningInfo&
131  setSigningCertName(const Name& certificateName);
132 
137  SigningInfo&
139 
144  SigningInfo&
145  setPibIdentity(const Identity& identity);
146 
151  SigningInfo&
152  setPibKey(const Key& key);
153 
157  SignerType
159  {
160  return m_type;
161  }
162 
166  const Name&
168  {
169  return m_name;
170  }
171 
176  const Identity&
178  {
179  BOOST_ASSERT(m_type == SIGNER_TYPE_PIB_ID);
180  return m_identity;
181  }
182 
187  const Key&
188  getPibKey() const
189  {
190  BOOST_ASSERT(m_type == SIGNER_TYPE_PIB_KEY);
191  return m_key;
192  }
193 
197  SigningInfo&
199  {
200  m_digestAlgorithm = algorithm;
201  return *this;
202  }
203 
209  {
210  return m_digestAlgorithm;
211  }
212 
216  SigningInfo&
217  setSignatureInfo(const SignatureInfo& signatureInfo);
218 
222  const SignatureInfo&
224  {
225  return m_info;
226  }
227 
228 public:
229  static const Name&
230  getEmptyName();
231 
232  static const SignatureInfo&
234 
238  static const Name&
240 
241 private:
242  SignerType m_type;
243  Name m_name;
244  Identity m_identity;
245  Key m_key;
246  DigestAlgorithm m_digestAlgorithm;
247  SignatureInfo m_info;
248 };
249 
250 std::ostream&
251 operator<<(std::ostream& os, const SigningInfo& si);
252 
253 } // namespace security
254 } // namespace ndn
255 
256 #endif // NDN_SECURITY_SIGNING_INFO_HPP
SigningInfo & setPibIdentity(const Identity &identity)
Set signer as a PIB identity handler identity.
Copyright (c) 2013-2016 Regents of the University of California.
Definition: common.hpp:74
given PIB identity handle, use its default key and default certificate
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.
std::ostream & operator<<(std::ostream &os, CommandInterestValidator::ErrorCode error)
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.
Name abstraction to represent an absolute name.
Definition: name.hpp:46
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;.
given PIB key handle, use its default certificate
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.
DigestAlgorithm getDigestAlgorithm() const
SignerType getSignerType() const
SigningInfo & setSigningKeyName(const Name &keyName)
Set signer as a key with name keyName.