Renamed SignedInfo to MetaInfo (except for encoding binary XML).
diff --git a/ndn-cpp/c/data.h b/ndn-cpp/c/data.h
index e8b2bf1..0226919 100644
--- a/ndn-cpp/c/data.h
+++ b/ndn-cpp/c/data.h
@@ -42,7 +42,7 @@
ndn_ContentType_NACK = 5
} ndn_ContentType;
-struct ndn_SignedInfo {
+struct ndn_MetaInfo {
struct ndn_PublisherPublicKeyDigest publisherPublicKeyDigest;
double timestampMilliseconds; /**< milliseconds since 1/1/1970. -1 for none */
ndn_ContentType type; /**< default is ndn_ContentType_DATA. -1 for none */
@@ -53,13 +53,13 @@
};
/**
- * Initialize the ndn_SignedInfo struct with values for none and the type to the default ndn_ContentType_DATA.
- * @param self A pointer to the ndn_SignedInfo struct.
+ * Initialize the ndn_MetaInfo struct with values for none and the type to the default ndn_ContentType_DATA.
+ * @param self A pointer to the ndn_MetaInfo struct.
* @param keyNameComponents The pre-allocated array of ndn_NameComponent for the keyLocator.
* @param maxKeyNameComponents The number of elements in the allocated keyNameComponents array.
*/
-static inline void ndn_SignedInfo_initialize
- (struct ndn_SignedInfo *self, struct ndn_NameComponent *keyNameComponents, unsigned int maxKeyNameComponents) {
+static inline void ndn_MetaInfo_initialize
+ (struct ndn_MetaInfo *self, struct ndn_NameComponent *keyNameComponents, unsigned int maxKeyNameComponents) {
ndn_PublisherPublicKeyDigest_initialize(&self->publisherPublicKeyDigest);
self->type = ndn_ContentType_DATA;
self->freshnessSeconds = -1;
@@ -71,7 +71,7 @@
struct ndn_Data {
struct ndn_Signature signature;
struct ndn_Name name;
- struct ndn_SignedInfo signedInfo;
+ struct ndn_MetaInfo metaInfo;
unsigned char *content; /**< pointer to the content */
unsigned int contentLength; /**< length of content */
};
@@ -82,7 +82,7 @@
* @param self A pointer to the ndn_Data struct.
* @param nameComponents The pre-allocated array of ndn_NameComponent.
* @param maxNameComponents The number of elements in the allocated nameComponents array.
- * @param keyNameComponents The pre-allocated array of ndn_NameComponent for the signedInfo.keyLocator.
+ * @param keyNameComponents The pre-allocated array of ndn_NameComponent for the metaInfo.keyLocator.
* @param maxKeyNameComponents The number of elements in the allocated keyNameComponents array.
*/
static inline void ndn_Data_initialize
@@ -91,7 +91,7 @@
{
ndn_Signature_initialize(&self->signature);
ndn_Name_initialize(&self->name, nameComponents, maxNameComponents);
- ndn_SignedInfo_initialize(&self->signedInfo, keyNameComponents, maxKeyNameComponents);
+ ndn_MetaInfo_initialize(&self->metaInfo, keyNameComponents, maxKeyNameComponents);
self->content = 0;
self->contentLength = 0;
}
diff --git a/ndn-cpp/c/encoding/binary-xml-data.c b/ndn-cpp/c/encoding/binary-xml-data.c
index 31354d4..ebc9987 100644
--- a/ndn-cpp/c/encoding/binary-xml-data.c
+++ b/ndn-cpp/c/encoding/binary-xml-data.c
@@ -56,9 +56,9 @@
return NDN_ERROR_success;
}
-static ndn_Error encodeSignedInfo(struct ndn_SignedInfo *signedInfo, struct ndn_BinaryXmlEncoder *encoder)
+static ndn_Error encodeSignedInfo(struct ndn_MetaInfo *metaInfo, struct ndn_BinaryXmlEncoder *encoder)
{
- if (signedInfo->type < 0)
+ if (metaInfo->type < 0)
return NDN_ERROR_success;
ndn_Error error;
@@ -66,26 +66,26 @@
return error;
// This will skip encoding if there is no publisherPublicKeyDigest.
- if ((error = ndn_encodeBinaryXmlPublisherPublicKeyDigest(&signedInfo->publisherPublicKeyDigest, encoder)))
+ if ((error = ndn_encodeBinaryXmlPublisherPublicKeyDigest(&metaInfo->publisherPublicKeyDigest, encoder)))
return error;
if ((error = ndn_BinaryXmlEncoder_writeOptionalTimeMillisecondsDTagElement
- (encoder, ndn_BinaryXml_DTag_Timestamp, signedInfo->timestampMilliseconds)))
+ (encoder, ndn_BinaryXml_DTag_Timestamp, metaInfo->timestampMilliseconds)))
return error;
- if (!(signedInfo->type < 0 || signedInfo->type == ndn_ContentType_DATA)) {
+ if (!(metaInfo->type < 0 || metaInfo->type == ndn_ContentType_DATA)) {
// Not the default of DATA, so we need to encode the type.
unsigned char *typeBytes;
unsigned int typeBytesLength = 3;
- if (signedInfo->type == ndn_ContentType_ENCR)
+ if (metaInfo->type == ndn_ContentType_ENCR)
typeBytes = "\x10\xD0\x91";
- else if (signedInfo->type == ndn_ContentType_GONE)
+ else if (metaInfo->type == ndn_ContentType_GONE)
typeBytes = "\x18\xE3\x44";
- else if (signedInfo->type == ndn_ContentType_KEY)
+ else if (metaInfo->type == ndn_ContentType_KEY)
typeBytes = "\x28\x46\x3F";
- else if (signedInfo->type == ndn_ContentType_LINK)
+ else if (metaInfo->type == ndn_ContentType_LINK)
typeBytes = "\x2C\x83\x4A";
- else if (signedInfo->type == ndn_ContentType_NACK)
+ else if (metaInfo->type == ndn_ContentType_NACK)
typeBytes = "\x34\x00\x8A";
else
return NDN_ERROR_unrecognized_ndn_ContentType;
@@ -96,15 +96,15 @@
}
if ((error = ndn_BinaryXmlEncoder_writeOptionalUnsignedDecimalIntDTagElement
- (encoder, ndn_BinaryXml_DTag_FreshnessSeconds, signedInfo->freshnessSeconds)))
+ (encoder, ndn_BinaryXml_DTag_FreshnessSeconds, metaInfo->freshnessSeconds)))
return error;
if ((error = ndn_BinaryXmlEncoder_writeOptionalBlobDTagElement
- (encoder, ndn_BinaryXml_DTag_FinalBlockID, signedInfo->finalBlockID, signedInfo->finalBlockIDLength)))
+ (encoder, ndn_BinaryXml_DTag_FinalBlockID, metaInfo->finalBlockID, metaInfo->finalBlockIDLength)))
return error;
// This will skip encoding if there is no key locator.
- if ((error = ndn_encodeBinaryXmlKeyLocator(&signedInfo->keyLocator, encoder)))
+ if ((error = ndn_encodeBinaryXmlKeyLocator(&metaInfo->keyLocator, encoder)))
return error;
if ((error = ndn_BinaryXmlEncoder_writeElementClose(encoder)))
@@ -113,17 +113,17 @@
return NDN_ERROR_success;
}
-static ndn_Error decodeSignedInfo(struct ndn_SignedInfo *signedInfo, struct ndn_BinaryXmlDecoder *decoder)
+static ndn_Error decodeSignedInfo(struct ndn_MetaInfo *metaInfo, struct ndn_BinaryXmlDecoder *decoder)
{
ndn_Error error;
if ((error = ndn_BinaryXmlDecoder_readElementStartDTag(decoder, ndn_BinaryXml_DTag_SignedInfo)))
return error;
- if ((error = ndn_decodeOptionalBinaryXmlPublisherPublicKeyDigest(&signedInfo->publisherPublicKeyDigest, decoder)))
+ if ((error = ndn_decodeOptionalBinaryXmlPublisherPublicKeyDigest(&metaInfo->publisherPublicKeyDigest, decoder)))
return error;
if (error= ndn_BinaryXmlDecoder_readOptionalTimeMillisecondsDTagElement
- (decoder, ndn_BinaryXml_DTag_Timestamp, &signedInfo->timestampMilliseconds))
+ (decoder, ndn_BinaryXml_DTag_Timestamp, &metaInfo->timestampMilliseconds))
return error;
unsigned char *typeBytes;
@@ -133,21 +133,21 @@
return error;
if (typeBytesLength == 0)
// The default Type is DATA.
- signedInfo->type = ndn_ContentType_DATA;
+ metaInfo->type = ndn_ContentType_DATA;
else if (typeBytesLength == 3) {
// All the recognized content types are 3 bytes.
if (ndn_memcmp(typeBytes, "\x0C\x04\xC0", typeBytesLength) == 0)
- signedInfo->type = ndn_ContentType_DATA;
+ metaInfo->type = ndn_ContentType_DATA;
else if (ndn_memcmp(typeBytes, "\x10\xD0\x91", typeBytesLength) == 0)
- signedInfo->type = ndn_ContentType_ENCR;
+ metaInfo->type = ndn_ContentType_ENCR;
else if (ndn_memcmp(typeBytes, "\x18\xE3\x44", typeBytesLength) == 0)
- signedInfo->type = ndn_ContentType_GONE;
+ metaInfo->type = ndn_ContentType_GONE;
else if (ndn_memcmp(typeBytes, "\x28\x46\x3F", typeBytesLength) == 0)
- signedInfo->type = ndn_ContentType_KEY;
+ metaInfo->type = ndn_ContentType_KEY;
else if (ndn_memcmp(typeBytes, "\x2C\x83\x4A", typeBytesLength) == 0)
- signedInfo->type = ndn_ContentType_LINK;
+ metaInfo->type = ndn_ContentType_LINK;
else if (ndn_memcmp(typeBytes, "\x34\x00\x8A", typeBytesLength) == 0)
- signedInfo->type = ndn_ContentType_NACK;
+ metaInfo->type = ndn_ContentType_NACK;
else
return NDN_ERROR_unrecognized_ndn_ContentType;
}
@@ -155,14 +155,14 @@
return NDN_ERROR_unrecognized_ndn_ContentType;
if ((error = ndn_BinaryXmlDecoder_readOptionalUnsignedIntegerDTagElement
- (decoder, ndn_BinaryXml_DTag_FreshnessSeconds, &signedInfo->freshnessSeconds)))
+ (decoder, ndn_BinaryXml_DTag_FreshnessSeconds, &metaInfo->freshnessSeconds)))
return error;
if ((error = ndn_BinaryXmlDecoder_readOptionalBinaryDTagElement
- (decoder, ndn_BinaryXml_DTag_FinalBlockID, 0, &signedInfo->finalBlockID, &signedInfo->finalBlockIDLength)))
+ (decoder, ndn_BinaryXml_DTag_FinalBlockID, 0, &metaInfo->finalBlockID, &metaInfo->finalBlockIDLength)))
return error;
- if ((error = ndn_decodeOptionalBinaryXmlKeyLocator(&signedInfo->keyLocator, decoder)))
+ if ((error = ndn_decodeOptionalBinaryXmlKeyLocator(&metaInfo->keyLocator, decoder)))
return error;
if ((error = ndn_BinaryXmlDecoder_readElementClose(decoder)))
@@ -186,7 +186,7 @@
if ((error = ndn_encodeBinaryXmlName(&data->name, encoder)))
return error;
- if ((error = encodeSignedInfo(&data->signedInfo, encoder)))
+ if ((error = encodeSignedInfo(&data->metaInfo, encoder)))
return error;
if ((error = ndn_BinaryXmlEncoder_writeBlobDTagElement
@@ -226,11 +226,11 @@
if ((error = ndn_BinaryXmlDecoder_peekDTag(decoder, ndn_BinaryXml_DTag_SignedInfo, &gotExpectedTag)))
return error;
if (gotExpectedTag) {
- if ((error = decodeSignedInfo(&data->signedInfo, decoder)))
+ if ((error = decodeSignedInfo(&data->metaInfo, decoder)))
return error;
}
else
- ndn_SignedInfo_initialize(&data->signedInfo, data->signedInfo.keyLocator.keyName.components, data->signedInfo.keyLocator.keyName.maxComponents);
+ ndn_MetaInfo_initialize(&data->metaInfo, data->metaInfo.keyLocator.keyName.components, data->metaInfo.keyLocator.keyName.maxComponents);
// Require a Content element, but set allowNull to allow a missing BLOB.
if ((error = ndn_BinaryXmlDecoder_readBinaryDTagElement
diff --git a/ndn-cpp/data.cpp b/ndn-cpp/data.cpp
index 1028795..fd41020 100644
--- a/ndn-cpp/data.cpp
+++ b/ndn-cpp/data.cpp
@@ -38,37 +38,37 @@
setVector(signature_, signatureStruct.signature, signatureStruct.signatureLength);
}
-void SignedInfo::get(struct ndn_SignedInfo& signedInfoStruct) const
+void MetaInfo::get(struct ndn_MetaInfo& metaInfoStruct) const
{
- publisherPublicKeyDigest_.get(signedInfoStruct.publisherPublicKeyDigest);
- signedInfoStruct.timestampMilliseconds = timestampMilliseconds_;
- signedInfoStruct.type = type_;
- signedInfoStruct.freshnessSeconds = freshnessSeconds_;
+ publisherPublicKeyDigest_.get(metaInfoStruct.publisherPublicKeyDigest);
+ metaInfoStruct.timestampMilliseconds = timestampMilliseconds_;
+ metaInfoStruct.type = type_;
+ metaInfoStruct.freshnessSeconds = freshnessSeconds_;
- signedInfoStruct.finalBlockIDLength = finalBlockID_.size();
+ metaInfoStruct.finalBlockIDLength = finalBlockID_.size();
if (finalBlockID_.size() > 0)
- signedInfoStruct.finalBlockID = (unsigned char *)&finalBlockID_[0];
+ metaInfoStruct.finalBlockID = (unsigned char *)&finalBlockID_[0];
else
- signedInfoStruct.finalBlockID = 0;
+ metaInfoStruct.finalBlockID = 0;
- keyLocator_.get(signedInfoStruct.keyLocator);
+ keyLocator_.get(metaInfoStruct.keyLocator);
}
-void SignedInfo::set(const struct ndn_SignedInfo& signedInfoStruct)
+void MetaInfo::set(const struct ndn_MetaInfo& metaInfoStruct)
{
- publisherPublicKeyDigest_.set(signedInfoStruct.publisherPublicKeyDigest);
- timestampMilliseconds_ = signedInfoStruct.timestampMilliseconds;
- type_ = signedInfoStruct.type;
- freshnessSeconds_ = signedInfoStruct.freshnessSeconds;
- setVector(finalBlockID_, signedInfoStruct.finalBlockID, signedInfoStruct.finalBlockIDLength);
- keyLocator_.set(signedInfoStruct.keyLocator);
+ publisherPublicKeyDigest_.set(metaInfoStruct.publisherPublicKeyDigest);
+ timestampMilliseconds_ = metaInfoStruct.timestampMilliseconds;
+ type_ = metaInfoStruct.type;
+ freshnessSeconds_ = metaInfoStruct.freshnessSeconds;
+ setVector(finalBlockID_, metaInfoStruct.finalBlockID, metaInfoStruct.finalBlockIDLength);
+ keyLocator_.set(metaInfoStruct.keyLocator);
}
void Data::get(struct ndn_Data& dataStruct) const
{
signature_.get(dataStruct.signature);
name_.get(dataStruct.name);
- signedInfo_.get(dataStruct.signedInfo);
+ metaInfo_.get(dataStruct.metaInfo);
dataStruct.contentLength = content_.size();
if (content_.size() > 0)
@@ -81,7 +81,7 @@
{
signature_.set(dataStruct.signature);
name_.set(dataStruct.name);
- signedInfo_.set(dataStruct.signedInfo);
+ metaInfo_.set(dataStruct.metaInfo);
setVector(content_, dataStruct.content, dataStruct.contentLength);
}
diff --git a/ndn-cpp/data.hpp b/ndn-cpp/data.hpp
index 620da8c..2bcc6aa 100644
--- a/ndn-cpp/data.hpp
+++ b/ndn-cpp/data.hpp
@@ -72,26 +72,26 @@
std::vector<unsigned char> signature_;
};
-class SignedInfo {
+class MetaInfo {
public:
- SignedInfo()
+ MetaInfo()
{
type_ = ndn_ContentType_DATA;
freshnessSeconds_ = -1;
}
/**
- * Set the signedInfoStruct to point to the values in this signed info object, without copying any memory.
- * WARNING: The resulting pointers in signedInfoStruct are invalid after a further use of this object which could reallocate memory.
- * @param signedInfoStruct a C ndn_SignedInfo struct where the name components array is already allocated.
+ * Set the metaInfoStruct to point to the values in this meta info object, without copying any memory.
+ * WARNING: The resulting pointers in metaInfoStruct are invalid after a further use of this object which could reallocate memory.
+ * @param metaInfoStruct a C ndn_MetaInfo struct where the name components array is already allocated.
*/
- void get(struct ndn_SignedInfo& signedInfoStruct) const;
+ void get(struct ndn_MetaInfo& metaInfoStruct) const;
/**
- * Clear this signed info, and set the values by copying from the ndn_SignedInfo struct.
- * @param signedInfoStruct a C ndn_SignedInfo struct
+ * Clear this meta info, and set the values by copying from the ndn_MetaInfo struct.
+ * @param metaInfoStruct a C ndn_MetaInfo struct
*/
- void set(const struct ndn_SignedInfo& signedInfoStruct);
+ void set(const struct ndn_MetaInfo& metaInfoStruct);
const PublisherPublicKeyDigest& getPublisherPublicKeyDigest() const { return publisherPublicKeyDigest_; }
PublisherPublicKeyDigest& getPublisherPublicKeyDigest() { return publisherPublicKeyDigest_; }
@@ -188,8 +188,8 @@
const Name& getName() const { return name_; }
Name& getName() { return name_; }
- const SignedInfo& getSignedInfo() const { return signedInfo_; }
- SignedInfo& getSignedInfo() { return signedInfo_; }
+ const MetaInfo& getMetaInfo() const { return metaInfo_; }
+ MetaInfo& getMetaInfo() { return metaInfo_; }
const std::vector<unsigned char>& getContent() const { return content_; }
std::vector<unsigned char>& getContent() { return content_; }
@@ -198,7 +198,7 @@
void setName(const Name& name) { name_ = name; }
- void setSignedInfo(const SignedInfo& signedInfo) { signedInfo_ = signedInfo; }
+ void setMetainfo(const MetaInfo& metaInfo) { metaInfo_ = metaInfo; }
void setContent(const std::vector<unsigned char>& content) { content_ = content; }
void setContent(const unsigned char *content, unsigned int contentLength)
@@ -209,7 +209,7 @@
private:
Signature signature_;
Name name_;
- SignedInfo signedInfo_;
+ MetaInfo metaInfo_;
std::vector<unsigned char> content_;
};
diff --git a/ndn-cpp/node.cpp b/ndn-cpp/node.cpp
index 1107a11..1015bc3 100644
--- a/ndn-cpp/node.cpp
+++ b/ndn-cpp/node.cpp
@@ -55,10 +55,10 @@
void Node::NdndIdFetcher::operator()(const ptr_lib::shared_ptr<const Interest>& interest, const ptr_lib::shared_ptr<Data>& ndndIdData)
{
- if (ndndIdData->getSignedInfo().getPublisherPublicKeyDigest().getPublisherPublicKeyDigest().size() > 0) {
+ if (ndndIdData->getMetaInfo().getPublisherPublicKeyDigest().getPublisherPublicKeyDigest().size() > 0) {
// Set the ndndId_ and continue.
// TODO: If there are multiple connected hubs, the NDN ID is really stored per connected hub.
- info_->node_.ndndId_ = ndndIdData->getSignedInfo().getPublisherPublicKeyDigest().getPublisherPublicKeyDigest();
+ info_->node_.ndndId_ = ndndIdData->getMetaInfo().getPublisherPublicKeyDigest().getPublisherPublicKeyDigest();
info_->node_.registerPrefixHelper(info_->prefix_, info_->onInterest_, info_->flags_);
}
// TODO: else need to log not getting the ndndId.
@@ -78,7 +78,7 @@
// Set the ForwardingEntry as the content of a Data packet and sign.
Data data;
data.setContent(*content);
- data.getSignedInfo().setTimestampMilliseconds(time(NULL) * 1000.0);
+ data.getMetaInfo().setTimestampMilliseconds(time(NULL) * 1000.0);
// TODO: Should we sign with a different key?
KeyChain::defaultSign(data);
ptr_lib::shared_ptr<vector<unsigned char> > encodedData = data.wireEncode();
diff --git a/ndn-cpp/security/key-chain.cpp b/ndn-cpp/security/key-chain.cpp
index 9ba15f0..6a44aa1 100644
--- a/ndn-cpp/security/key-chain.cpp
+++ b/ndn-cpp/security/key-chain.cpp
@@ -90,9 +90,9 @@
const unsigned char *privateKeyDer, unsigned int privateKeyDerLength, WireFormat& wireFormat)
{
// Set the public key.
- setSha256(publicKeyDer, publicKeyDerLength, data.getSignedInfo().getPublisherPublicKeyDigest().getPublisherPublicKeyDigest());
- data.getSignedInfo().getKeyLocator().setType(ndn_KeyLocatorType_KEY);
- data.getSignedInfo().getKeyLocator().setKeyData(publicKeyDer, publicKeyDerLength);
+ setSha256(publicKeyDer, publicKeyDerLength, data.getMetaInfo().getPublisherPublicKeyDigest().getPublisherPublicKeyDigest());
+ data.getMetaInfo().getKeyLocator().setType(ndn_KeyLocatorType_KEY);
+ data.getMetaInfo().getKeyLocator().setKeyData(publicKeyDer, publicKeyDerLength);
// Clear the signature so we don't encode it below.
data.getSignature().clear();
@@ -142,9 +142,9 @@
// Find the public key.
const unsigned char *publicKeyDer;
unsigned int publicKeyDerLength;
- if (data.getSignedInfo().getKeyLocator().getType() == ndn_KeyLocatorType_KEY) {
- publicKeyDer = &data.getSignedInfo().getKeyLocator().getKeyData().front();
- publicKeyDerLength = data.getSignedInfo().getKeyLocator().getKeyData().size();
+ if (data.getMetaInfo().getKeyLocator().getType() == ndn_KeyLocatorType_KEY) {
+ publicKeyDer = &data.getMetaInfo().getKeyLocator().getKeyData().front();
+ publicKeyDerLength = data.getMetaInfo().getKeyLocator().getKeyData().size();
}
else
// Can't find a public key.
diff --git a/ndn-cpp/security/key-chain.hpp b/ndn-cpp/security/key-chain.hpp
index 0d3873e..584ddc4 100644
--- a/ndn-cpp/security/key-chain.hpp
+++ b/ndn-cpp/security/key-chain.hpp
@@ -13,10 +13,10 @@
class KeyChain {
public:
/**
- * In data, set the signed info publisher public key digest and key locator key to the public key and set the
+ * In data, set the meta info publisher public key digest and key locator key to the public key and set the
* signature using the private key.
* Note: the caller must make sure the timestamp is correct, for example with
- * data.getSignedInfo().setTimestampMilliseconds(time(NULL) * 1000.0).
+ * data.getMetaInfo().setTimestampMilliseconds(time(NULL) * 1000.0).
* @param data The Data object to sign and set the key and signature.
* @param publicKeyDer A pointer to a buffer with the DER-encoded public key.
* @param publicKeyDerLength The number of bytes in publicKeyDer.
diff --git a/tests/test-encode-decode-data.cpp b/tests/test-encode-decode-data.cpp
index d550a16..cf9a352 100644
--- a/tests/test-encode-decode-data.cpp
+++ b/tests/test-encode-decode-data.cpp
@@ -71,6 +71,72 @@
}
else
cout << "content: <empty>" << endl;
+
+ cout << "metaInfo.publisherPublicKeyDigest: "
+ << (data.getMetaInfo().getPublisherPublicKeyDigest().getPublisherPublicKeyDigest().size() > 0 ?
+ toHex(data.getMetaInfo().getPublisherPublicKeyDigest().getPublisherPublicKeyDigest()).c_str() : "<none>") << endl;
+ cout << "metaInfo.timestamp: ";
+ if (data.getMetaInfo().getTimestampMilliseconds() >= 0) {
+ time_t seconds = data.getMetaInfo().getTimestampMilliseconds() / 1000.0;
+ cout << data.getMetaInfo().getTimestampMilliseconds() << " milliseconds, UTC time: " << asctime(gmtime(&seconds));
+ }
+ else
+ cout << "<none>" << endl;
+ if (!(data.getMetaInfo().getType() < 0 || data.getMetaInfo().getType() == ndn_ContentType_DATA)) {
+ cout << "metaInfo.type: ";
+ if (data.getMetaInfo().getType() == ndn_ContentType_ENCR)
+ cout << "ENCR" << endl;
+ else if (data.getMetaInfo().getType() == ndn_ContentType_GONE)
+ cout << "GONE" << endl;
+ else if (data.getMetaInfo().getType() == ndn_ContentType_KEY)
+ cout << "KEY" << endl;
+ else if (data.getMetaInfo().getType() == ndn_ContentType_LINK)
+ cout << "LINK" << endl;
+ else if (data.getMetaInfo().getType() == ndn_ContentType_NACK)
+ cout << "NACK" << endl;
+ }
+ cout << "metaInfo.freshnessSeconds: ";
+ if (data.getMetaInfo().getFreshnessSeconds() >= 0)
+ cout << data.getMetaInfo().getFreshnessSeconds() << endl;
+ else
+ cout << "<none>" << endl;
+ cout << "metaInfo.finalBlockID: "
+ << (data.getMetaInfo().getFinalBlockID().size() > 0 ?
+ toHex(data.getMetaInfo().getFinalBlockID()).c_str() : "<none>") << endl;
+ cout << "metaInfo.keyLocator: ";
+ if ((int)data.getMetaInfo().getKeyLocator().getType() >= 0) {
+ if (data.getMetaInfo().getKeyLocator().getType() == ndn_KeyLocatorType_KEY)
+ cout << "Key: " << toHex(data.getMetaInfo().getKeyLocator().getKeyData()) << endl;
+ else if (data.getMetaInfo().getKeyLocator().getType() == ndn_KeyLocatorType_CERTIFICATE)
+ cout << "Certificate: " << toHex(data.getMetaInfo().getKeyLocator().getKeyData()) << endl;
+ else if (data.getMetaInfo().getKeyLocator().getType() == ndn_KeyLocatorType_KEYNAME) {
+ cout << "KeyName: " << data.getMetaInfo().getKeyLocator().getKeyName().to_uri() << endl;
+ cout << "metaInfo.keyLocator: ";
+ if ((int)data.getMetaInfo().getKeyLocator().getKeyNameType() >= 0) {
+ bool showKeyNameData = true;
+ if (data.getMetaInfo().getKeyLocator().getKeyNameType() == ndn_KeyNameType_PUBLISHER_PUBLIC_KEY_DIGEST)
+ cout << "PublisherPublicKeyDigest: ";
+ else if (data.getMetaInfo().getKeyLocator().getKeyNameType() == ndn_KeyNameType_PUBLISHER_CERTIFICATE_DIGEST)
+ cout << "PublisherCertificateDigest: ";
+ else if (data.getMetaInfo().getKeyLocator().getKeyNameType() == ndn_KeyNameType_PUBLISHER_ISSUER_KEY_DIGEST)
+ cout << "PublisherIssuerKeyDigest: ";
+ else if (data.getMetaInfo().getKeyLocator().getKeyNameType() == ndn_KeyNameType_PUBLISHER_ISSUER_CERTIFICATE_DIGEST)
+ cout << "PublisherIssuerCertificateDigest: ";
+ else {
+ cout << "<unrecognized ndn_KeyNameType " << data.getMetaInfo().getKeyLocator().getKeyNameType() << ">" << endl;
+ showKeyNameData = false;
+ }
+ if (showKeyNameData)
+ cout << toHex(data.getMetaInfo().getKeyLocator().getKeyData()) << endl;
+ }
+ else
+ cout << "<no key digest>" << endl;
+ }
+ else
+ cout << "<unrecognized ndn_KeyLocatorType " << data.getMetaInfo().getKeyLocator().getType() << ">" << endl;
+ }
+ else
+ cout << "<none>" << endl;
cout << "signature.digestAlgorithm: "
<< (data.getSignature().getDigestAlgorithm().size() > 0 ? toHex(data.getSignature().getDigestAlgorithm()).c_str() : "default (sha-256)") << endl;
@@ -78,72 +144,6 @@
<< (data.getSignature().getWitness().size() > 0 ? toHex(data.getSignature().getWitness()).c_str() : "<none>") << endl;
cout << "signature.signature: "
<< (data.getSignature().getSignature().size() > 0 ? toHex(data.getSignature().getSignature()).c_str() : "<none>") << endl;
-
- cout << "signedInfo.publisherPublicKeyDigest: "
- << (data.getSignedInfo().getPublisherPublicKeyDigest().getPublisherPublicKeyDigest().size() > 0 ?
- toHex(data.getSignedInfo().getPublisherPublicKeyDigest().getPublisherPublicKeyDigest()).c_str() : "<none>") << endl;
- cout << "signedInfo.timestamp: ";
- if (data.getSignedInfo().getTimestampMilliseconds() >= 0) {
- time_t seconds = data.getSignedInfo().getTimestampMilliseconds() / 1000.0;
- cout << data.getSignedInfo().getTimestampMilliseconds() << " milliseconds, UTC time: " << asctime(gmtime(&seconds));
- }
- else
- cout << "<none>" << endl;
- if (!(data.getSignedInfo().getType() < 0 || data.getSignedInfo().getType() == ndn_ContentType_DATA)) {
- cout << "signedInfo.type: ";
- if (data.getSignedInfo().getType() == ndn_ContentType_ENCR)
- cout << "ENCR" << endl;
- else if (data.getSignedInfo().getType() == ndn_ContentType_GONE)
- cout << "GONE" << endl;
- else if (data.getSignedInfo().getType() == ndn_ContentType_KEY)
- cout << "KEY" << endl;
- else if (data.getSignedInfo().getType() == ndn_ContentType_LINK)
- cout << "LINK" << endl;
- else if (data.getSignedInfo().getType() == ndn_ContentType_NACK)
- cout << "NACK" << endl;
- }
- cout << "signedInfo.freshnessSeconds: ";
- if (data.getSignedInfo().getFreshnessSeconds() >= 0)
- cout << data.getSignedInfo().getFreshnessSeconds() << endl;
- else
- cout << "<none>" << endl;
- cout << "signedInfo.finalBlockID: "
- << (data.getSignedInfo().getFinalBlockID().size() > 0 ?
- toHex(data.getSignedInfo().getFinalBlockID()).c_str() : "<none>") << endl;
- cout << "signedInfo.keyLocator: ";
- if ((int)data.getSignedInfo().getKeyLocator().getType() >= 0) {
- if (data.getSignedInfo().getKeyLocator().getType() == ndn_KeyLocatorType_KEY)
- cout << "Key: " << toHex(data.getSignedInfo().getKeyLocator().getKeyData()) << endl;
- else if (data.getSignedInfo().getKeyLocator().getType() == ndn_KeyLocatorType_CERTIFICATE)
- cout << "Certificate: " << toHex(data.getSignedInfo().getKeyLocator().getKeyData()) << endl;
- else if (data.getSignedInfo().getKeyLocator().getType() == ndn_KeyLocatorType_KEYNAME) {
- cout << "KeyName: " << data.getSignedInfo().getKeyLocator().getKeyName().to_uri() << endl;
- cout << "signedInfo.keyLocator: ";
- if ((int)data.getSignedInfo().getKeyLocator().getKeyNameType() >= 0) {
- bool showKeyNameData = true;
- if (data.getSignedInfo().getKeyLocator().getKeyNameType() == ndn_KeyNameType_PUBLISHER_PUBLIC_KEY_DIGEST)
- cout << "PublisherPublicKeyDigest: ";
- else if (data.getSignedInfo().getKeyLocator().getKeyNameType() == ndn_KeyNameType_PUBLISHER_CERTIFICATE_DIGEST)
- cout << "PublisherCertificateDigest: ";
- else if (data.getSignedInfo().getKeyLocator().getKeyNameType() == ndn_KeyNameType_PUBLISHER_ISSUER_KEY_DIGEST)
- cout << "PublisherIssuerKeyDigest: ";
- else if (data.getSignedInfo().getKeyLocator().getKeyNameType() == ndn_KeyNameType_PUBLISHER_ISSUER_CERTIFICATE_DIGEST)
- cout << "PublisherIssuerCertificateDigest: ";
- else {
- cout << "<unrecognized ndn_KeyNameType " << data.getSignedInfo().getKeyLocator().getKeyNameType() << ">" << endl;
- showKeyNameData = false;
- }
- if (showKeyNameData)
- cout << toHex(data.getSignedInfo().getKeyLocator().getKeyData()) << endl;
- }
- else
- cout << "<no key digest>" << endl;
- }
- else
- cout << "<unrecognized ndn_KeyLocatorType " << data.getSignedInfo().getKeyLocator().getType() << ">" << endl;
- }
- else
- cout << "<none>" << endl;
}
int main(int argc, char** argv)
@@ -166,7 +166,7 @@
Data freshData(Name("/ndn/abc"));
const unsigned char freshContent[] = "SUCCESS!";
freshData.setContent(freshContent, sizeof(freshContent) - 1);
- freshData.getSignedInfo().setTimestampMilliseconds(time(NULL) * 1000.0);
+ freshData.getMetaInfo().setTimestampMilliseconds(time(NULL) * 1000.0);
KeyChain::defaultSign(freshData);
cout << endl << "Freshly-signed Data:" << endl;