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