25 #include <ndn-cpp/c/data-types.h>
27 #include "key-locator.h"
28 #include "security/validity-period.h"
40 static __inline
void ndn_Signature_initialize(
struct ndn_Signature *
self,
struct ndn_NameComponent *keyNameComponents,
size_t maxKeyNameComponents) {
41 self->type = (ndn_SignatureType)-1;
42 ndn_Blob_initialize(&self->signature, 0, 0);
43 ndn_Blob_initialize(&self->signatureInfoEncoding, 0, 0);
44 self->genericTypeCode = -1;
45 ndn_KeyLocator_initialize(&self->keyLocator, keyNameComponents, maxKeyNameComponents);
46 ndn_ValidityPeriod_initialize(&self->validityPeriod);
54 static __inline
void ndn_Signature_clear(
struct ndn_Signature *
self)
56 ndn_Signature_initialize
57 (
self, self->keyLocator.keyName.components,
58 self->keyLocator.keyName.maxComponents);
68 static __inline ndn_Error
69 ndn_Signature_setFromSignature
76 return NDN_ERROR_success;
78 self->type = other->
type;
79 ndn_Blob_setFromBlob(&self->signature, &other->signature);
82 if ((error = ndn_KeyLocator_setFromKeyLocator
87 return NDN_ERROR_success;
94 static __inline
void ndn_MetaInfo_initialize(
struct ndn_MetaInfo *
self)
96 self->timestampMilliseconds = -1;
97 self->type = ndn_ContentType_BLOB;
98 self->otherTypeCode = -1;
99 self->freshnessPeriod = -1;
100 ndn_NameComponent_initialize(&self->finalBlockId, 0, 0);
106 static __inline
int ndn_MetaInfo_getFreshnessSeconds(
const struct ndn_MetaInfo *
self)
108 return self->freshnessPeriod < 0 ? -1 : (int)round(self->freshnessPeriod / 1000.0);
114 static __inline
void ndn_MetaInfo_setFreshnessSeconds(
struct ndn_MetaInfo *
self,
int freshnessSeconds)
116 self->freshnessPeriod = freshnessSeconds < 0 ? -1.0 : (double)freshnessSeconds * 1000.0;
126 static __inline ndn_Error
127 ndn_MetaInfo_setFromMetaInfo
132 return NDN_ERROR_success;
135 self->type = other->
type;
137 ndn_NameComponent_setFromNameComponent(&self->finalBlockId, &other->
finalBlockId);
139 return NDN_ERROR_success;
151 static __inline
void ndn_Data_initialize
155 ndn_Signature_initialize(&self->signature, keyNameComponents, maxKeyNameComponents);
156 ndn_Name_initialize(&self->name, nameComponents, maxNameComponents);
157 ndn_MetaInfo_initialize(&self->metaInfo);
158 ndn_Blob_initialize(&self->content, 0, 0);
168 static __inline ndn_Error
175 return NDN_ERROR_success;
177 if ((error = ndn_Signature_setFromSignature
178 (&self->signature, &other->signature)))
180 if ((error = ndn_Name_setFromName(&self->name, &other->name)))
182 if ((error = ndn_MetaInfo_setFromMetaInfo
183 (&self->metaInfo, &other->metaInfo)))
185 ndn_Blob_setFromBlob(&self->content, &other->
content);
187 return NDN_ERROR_success;
struct ndn_ValidityPeriod validityPeriod
used with Sha256WithRsaSignature, Sha256WithEcdsaSignature
Definition: data-types.h:73
int genericTypeCode
used with Generic.
Definition: data-types.h:70
Definition: data-types.h:88
struct ndn_Blob content
A Blob with a pointer to the content.
Definition: data-types.h:92
ndn_SignatureType type
-1 for unspecified
Definition: data-types.h:67
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
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