All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
signature-lite.hpp
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
22 #ifndef NDN_SIGNATURE_LITE_HPP
23 #define NDN_SIGNATURE_LITE_HPP
24 
25 #include "key-locator-lite.hpp"
26 #include "security/validity-period-lite.hpp"
27 #include "../c/data-types.h"
28 
29 namespace ndn {
30 
37 class SignatureLite : private ndn_Signature {
38 public:
48  SignatureLite(ndn_NameComponent* keyNameComponents, size_t maxKeyNameComponents);
49 
53  void
54  clear();
55 
56  ndn_SignatureType
57  getType() const { return type; }
58 
59  const BlobLite&
60  getSignature() const { return BlobLite::downCast(signature); }
61 
67  const BlobLite&
69 
78  int
79  getGenericTypeCode() const { return genericTypeCode; }
80 
81  const KeyLocatorLite&
82  getKeyLocator() const { return KeyLocatorLite::downCast(keyLocator); }
83 
84  KeyLocatorLite&
85  getKeyLocator() { return KeyLocatorLite::downCast(keyLocator); }
86 
87  const ValidityPeriodLite&
88  getValidityPeriod() const { return ValidityPeriodLite::downCast(validityPeriod); }
89 
90  ValidityPeriodLite&
91  getValidityPeriod() { return ValidityPeriodLite::downCast(validityPeriod); }
92 
93  void
94  setType(ndn_SignatureType type) { this->type = type; }
95 
101  void
102  setSignature(const BlobLite& signature)
103  {
104  BlobLite::downCast(this->signature) = signature;
105  }
106 
116  void
119  {
120  BlobLite::downCast(this->signatureInfoEncoding) = signatureInfoEncoding;
121  this->genericTypeCode = genericTypeCode;
122  }
123 
130  ndn_Error
131  set(const SignatureLite& other);
132 
138  static SignatureLite&
139  downCast(ndn_Signature& signature) { return *(SignatureLite*)&signature; }
140 
141  static const SignatureLite&
142  downCast(const ndn_Signature& signature) { return *(SignatureLite*)&signature; }
143 
144 private:
145  // Declare friends who can downcast to the private base.
146  friend class Tlv0_2WireFormatLite;
147 
153  SignatureLite(const SignatureLite& other);
154 
160  SignatureLite& operator=(const SignatureLite& other);
161 };
162 
163 }
164 
165 #endif
struct ndn_ValidityPeriod validityPeriod
used with Sha256WithRsaSignature, Sha256WithEcdsaSignature
Definition: data-types.h:73
int genericTypeCode
used with Generic.
Definition: data-types.h:70
const BlobLite & getSignatureInfoEncoding() const
Get the bytes of the entire signature info encoding (including the type code).
Definition: signature-lite.hpp:68
static KeyLocatorLite & downCast(ndn_KeyLocator &keyLocator)
Downcast the reference to the ndn_KeyLocator struct to a KeyLocatorLite.
Definition: key-locator-lite.hpp:100
A SignatureLite holds a signature type, a KeyLocatorLite, the signature bytes and other fields to rep...
Definition: signature-lite.hpp:37
static BlobLite & downCast(ndn_Blob &blob)
Downcast the reference to the ndn_Blob struct to a BlobLite.
Definition: blob-lite.hpp:86
ndn_Error set(const SignatureLite &other)
Set this signature to have the values from the other signature.
Definition: signature-lite.cpp:37
ndn_SignatureType type
-1 for unspecified
Definition: data-types.h:67
A KeyLocatorLite holds a type and other info to represent the key which signs a Data packet...
Definition: key-locator-lite.hpp:34
struct ndn_KeyLocator keyLocator
used with Sha256WithRsaSignature, Sha256WithEcdsaSignature, HmacWithSha256Signature ...
Definition: data-types.h:71
An ndn_NameComponent holds a pointer to the component value.
Definition: name-types.h:47
void setSignatureInfoEncoding(const BlobLite &signatureInfoEncoding, int genericTypeCode)
Set the bytes of the entire signature info encoding (including the type code).
Definition: signature-lite.hpp:118
static ValidityPeriodLite & downCast(ndn_ValidityPeriod &validityPeriod)
Downcast the reference to the ndn_ValidityPeriod struct to a ValidityPeriodLite.
Definition: validity-period-lite.hpp:104
A BlobLite holds a pointer to an immutable pre-allocated buffer and its length This is like a JavaScr...
Definition: blob-lite.hpp:37
SignatureLite(ndn_NameComponent *keyNameComponents, size_t maxKeyNameComponents)
Create a SignatureLite with values for none.
Definition: signature-lite.cpp:28
void setSignature(const BlobLite &signature)
Set the signature bytes.
Definition: signature-lite.hpp:102
void clear()
Set the fields the values for none as in the constructor.
Definition: signature-lite.cpp:34
static SignatureLite & downCast(ndn_Signature &signature)
Downcast the reference to the ndn_Signature struct to a SignatureLite.
Definition: signature-lite.hpp:139
An ndn_Signature struct holds the signature bits and other info representing the signature in a data ...
Definition: data-types.h:66
struct ndn_Blob signatureInfoEncoding
used with Generic
Definition: data-types.h:69
int getGenericTypeCode() const
Get the type code of the generic signature.
Definition: signature-lite.hpp:79