hmac-with-sha256-signature.hpp
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
22 #ifndef NDN_HMAC_WITH_SHA256_SIGNATURE_HPP
23 #define NDN_HMAC_WITH_SHA256_SIGNATURE_HPP
24 
25 #include "signature.hpp"
26 #include "key-locator.hpp"
27 #include "util/change-counter.hpp"
28 
29 
30 namespace ndn {
31 
37 public:
39  : changeCount_(0)
40  {
41  }
42 
47  virtual ptr_lib::shared_ptr<Signature>
48  clone() const;
49 
58  virtual void
59  get(SignatureLite& signatureLite) const;
60 
65  virtual void
66  set(const SignatureLite& signatureLite);
67 
72  virtual const Blob&
73  getSignature() const;
74 
75  const KeyLocator&
76  getKeyLocator() const { return keyLocator_.get(); }
77 
78  KeyLocator&
79  getKeyLocator() { return keyLocator_.get(); }
80 
85  virtual void
86  setSignature(const Blob& signature);
87 
88  void
89  setKeyLocator(const KeyLocator& keyLocator)
90  {
91  keyLocator_.set(keyLocator);
92  ++changeCount_;
93  }
94 
98  void
100  {
101  signature_.reset();
102  keyLocator_.get().clear();
103  ++changeCount_;
104  }
105 
111  virtual uint64_t
112  getChangeCount() const;
113 
114 private:
115  Blob signature_;
116  ChangeCounter<KeyLocator> keyLocator_;
117  uint64_t changeCount_;
118 };
119 
120 }
121 
122 #endif
virtual const Blob & getSignature() const
Get the signature bytes.
Definition: hmac-with-sha256-signature.cpp:36
Copyright (C) 2013-2016 Regents of the University of California.
Definition: common.hpp:35
An HmacWithSha256Signature extends Signature and holds the signature bits and other info representing...
Definition: hmac-with-sha256-signature.hpp:36
A SignatureLite holds a signature type, a KeyLocatorLite, the signature bytes and other fields to rep...
Definition: signature-lite.hpp:36
A ChangeCounter keeps a target object whose change count is tracked by a local change count...
Definition: change-counter.hpp:37
virtual void set(const SignatureLite &signatureLite)
Clear this signature, and set the values by copying from signatureLite.
Definition: hmac-with-sha256-signature.cpp:57
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
void clear()
Clear all the fields.
Definition: hmac-with-sha256-signature.hpp:99
Definition: key-locator.hpp:35
virtual ptr_lib::shared_ptr< Signature > clone() const
Return a pointer to a new HmacWithSha256Signature which is a copy of this signature.
Definition: hmac-with-sha256-signature.cpp:30
virtual uint64_t getChangeCount() const
Get the change count, which is incremented each time this object (or a child object) is changed...
Definition: hmac-with-sha256-signature.cpp:68
virtual void setSignature(const Blob &signature)
Set the signature bytes to the given value.
Definition: hmac-with-sha256-signature.cpp:42