generic-signature.hpp
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
22 #ifndef NDN_GENERIC_SIGNATURE_HPP
23 #define NDN_GENERIC_SIGNATURE_HPP
24 
25 #include "signature.hpp"
26 
27 namespace ndn {
28 
35 class GenericSignature : public Signature {
36 public:
41  : changeCount_(0),
42  typeCode_(-1)
43  {
44  }
45 
51  virtual ptr_lib::shared_ptr<Signature>
52  clone() const;
53 
62  virtual void
63  get(SignatureLite& signatureLite) const;
64 
69  virtual void
70  set(const SignatureLite& signatureLite);
71 
77  const Blob&
78  getSignatureInfoEncoding() const { return signatureInfoEncoding_; }
79 
88  void
89  setSignatureInfoEncoding(const Blob& signatureInfoEncoding, int typeCode = -1)
90  {
91  signatureInfoEncoding_ = signatureInfoEncoding;
92  typeCode_ = typeCode;
93 
94  ++changeCount_;
95  }
96 
101  virtual const Blob&
102  getSignature() const;
103 
108  virtual void
109  setSignature(const Blob& signature);
110 
118  int
119  getTypeCode() const { return typeCode_; }
120 
124  void
126  {
127  signature_.reset();
128  signatureInfoEncoding_.reset();
129  typeCode_ = -1;
130  ++changeCount_;
131  }
132 
137  virtual uint64_t
138  getChangeCount() const;
139 
140 private:
141  Blob signature_;
142  Blob signatureInfoEncoding_;
143  int typeCode_;
144  uint64_t changeCount_;
145 };
146 
147 
148 }
149 
150 #endif
virtual const Blob & getSignature() const
Get the signature bytes.
Definition: generic-signature.cpp:35
Copyright (C) 2013-2016 Regents of the University of California.
Definition: common.hpp:35
int getTypeCode() const
Get the type code of the signature type.
Definition: generic-signature.hpp:119
A SignatureLite holds a signature type, a KeyLocatorLite, the signature bytes and other fields to rep...
Definition: signature-lite.hpp:36
const Blob & getSignatureInfoEncoding() const
Get the bytes of the entire signature info encoding (including the type code).
Definition: generic-signature.hpp:78
void setSignatureInfoEncoding(const Blob &signatureInfoEncoding, int typeCode=-1)
Set the bytes of the entire signature info encoding (including the type code).
Definition: generic-signature.hpp:89
virtual void set(const SignatureLite &signatureLite)
Clear this signature, and set the values by copying from signatureLite.
Definition: generic-signature.cpp:59
virtual uint64_t getChangeCount() const
Get the change count, which is incremented each time this object is changed.
Definition: generic-signature.cpp:74
A Signature is an abstract base class providing methods to work with the signature information in a D...
Definition: signature.hpp:35
A Blob holds a pointer to an immutable byte array implemented as const std::vector.
Definition: blob.hpp:42
virtual ptr_lib::shared_ptr< Signature > clone() const
Return a pointer to a new DigestSha256Signature which is a copy of this GenericSignature.
Definition: generic-signature.cpp:29
GenericSignature()
Create a new GenericSignature with default values.
Definition: generic-signature.hpp:40
A GenericSignature extends Signature and holds the encoding bytes of the SignatureInfo so that the ap...
Definition: generic-signature.hpp:35
void clear()
Clear all the fields.
Definition: generic-signature.hpp:125
virtual void setSignature(const Blob &signature)
Set the signature bytes to the given value.
Definition: generic-signature.cpp:41