Renamed KeyLocator keyOrCertificate to keyData
diff --git a/ndn-cpp/c/encoding/binary-xml-key.c b/ndn-cpp/c/encoding/binary-xml-key.c
index 5b6de79..c1df758 100644
--- a/ndn-cpp/c/encoding/binary-xml-key.c
+++ b/ndn-cpp/c/encoding/binary-xml-key.c
@@ -19,12 +19,12 @@
if (keyLocator->type == ndn_KeyLocatorType_KEY) {
if ((error = ndn_BinaryXmlEncoder_writeBlobDTagElement
- (encoder, ndn_BinaryXml_DTag_Key, keyLocator->keyOrCertificate, keyLocator->keyOrCertificateLength)))
+ (encoder, ndn_BinaryXml_DTag_Key, keyLocator->keyData, keyLocator->keyDataLength)))
return error;
}
else if (keyLocator->type == ndn_KeyLocatorType_CERTIFICATE) {
if ((error = ndn_BinaryXmlEncoder_writeBlobDTagElement
- (encoder, ndn_BinaryXml_DTag_Certificate, keyLocator->keyOrCertificate, keyLocator->keyOrCertificateLength)))
+ (encoder, ndn_BinaryXml_DTag_Certificate, keyLocator->keyData, keyLocator->keyDataLength)))
return error;
}
else if (keyLocator->type == ndn_KeyLocatorType_KEYNAME) {
@@ -52,7 +52,7 @@
keyLocator->type = ndn_KeyLocatorType_KEY;
if ((error = ndn_BinaryXmlDecoder_readBinaryDTagElement
- (decoder, ndn_BinaryXml_DTag_Key, 0, &keyLocator->keyOrCertificate, &keyLocator->keyOrCertificateLength)))
+ (decoder, ndn_BinaryXml_DTag_Key, 0, &keyLocator->keyData, &keyLocator->keyDataLength)))
return error;
}
else {
@@ -62,7 +62,7 @@
keyLocator->type = ndn_KeyLocatorType_CERTIFICATE;
if ((error = ndn_BinaryXmlDecoder_readBinaryDTagElement
- (decoder, ndn_BinaryXml_DTag_Certificate, 0, &keyLocator->keyOrCertificate, &keyLocator->keyOrCertificateLength)))
+ (decoder, ndn_BinaryXml_DTag_Certificate, 0, &keyLocator->keyData, &keyLocator->keyDataLength)))
return error;
}
else {
diff --git a/ndn-cpp/c/key.h b/ndn-cpp/c/key.h
index 0f599d5..bb0aee6 100644
--- a/ndn-cpp/c/key.h
+++ b/ndn-cpp/c/key.h
@@ -18,16 +18,16 @@
struct ndn_KeyLocator {
ndn_KeyLocatorType type; /**< -1 for none */
- unsigned char *keyOrCertificate; /**< if type is ndn_KeyLocatorType_KEY, pointer to the pre-allocated buffer for the key value.
- if type is ndn_KeyLocatorType_CERTIFICATE, pointer to the pre-allocated buffer for the cetrificate value. */
- unsigned int keyOrCertificateLength;
+ unsigned char *keyData; /**< if type is ndn_KeyLocatorType_KEY, pointer to the pre-allocated buffer for the key value.
+ if type is ndn_KeyLocatorType_CERTIFICATE, pointer to the pre-allocated buffer for the cetrificate value. */
+ unsigned int keyDataLength;
// TODO: Implement keyName.
};
static inline void ndn_KeyLocator_init(struct ndn_KeyLocator *self) {
self->type = (ndn_KeyLocatorType)-1;
- self->keyOrCertificate = 0;
- self->keyOrCertificateLength = 0;
+ self->keyData = 0;
+ self->keyDataLength = 0;
// TODO: Implement keyName.
}
diff --git a/ndn-cpp/key-chain.cpp b/ndn-cpp/key-chain.cpp
index ef31c4c..9ab58fc 100644
--- a/ndn-cpp/key-chain.cpp
+++ b/ndn-cpp/key-chain.cpp
@@ -116,7 +116,7 @@
// Set the public key.
setSha256(publicKeyDer, publicKeyDerLength, data.getSignedInfo().getPublisherPublicKeyDigest().getPublisherPublicKeyDigest());
data.getSignedInfo().getKeyLocator().setType(ndn_KeyLocatorType_KEY);
- data.getSignedInfo().getKeyLocator().setKeyOrCertificate(publicKeyDer, publicKeyDerLength);
+ data.getSignedInfo().getKeyLocator().setKeyData(publicKeyDer, publicKeyDerLength);
// Clear the signature so we don't encode it below.
data.getSignature().clear();
@@ -161,8 +161,8 @@
const unsigned char *publicKeyDer;
unsigned int publicKeyDerLength;
if (data.getSignedInfo().getKeyLocator().getType() == ndn_KeyLocatorType_KEY) {
- publicKeyDer = &data.getSignedInfo().getKeyLocator().getKeyOrCertificate().front();
- publicKeyDerLength = data.getSignedInfo().getKeyLocator().getKeyOrCertificate().size();
+ publicKeyDer = &data.getSignedInfo().getKeyLocator().getKeyData().front();
+ publicKeyDerLength = data.getSignedInfo().getKeyLocator().getKeyData().size();
}
else
// Can't find a public key.
diff --git a/ndn-cpp/key.cpp b/ndn-cpp/key.cpp
index 41fe8b9..e927a8e 100644
--- a/ndn-cpp/key.cpp
+++ b/ndn-cpp/key.cpp
@@ -14,11 +14,11 @@
{
keyLocatorStruct.type = type_;
- keyLocatorStruct.keyOrCertificateLength = keyOrCertificate_.size();
- if (keyOrCertificate_.size() > 0)
- keyLocatorStruct.keyOrCertificate = (unsigned char *)&keyOrCertificate_[0];
+ keyLocatorStruct.keyDataLength = keyData_.size();
+ if (keyData_.size() > 0)
+ keyLocatorStruct.keyData = (unsigned char *)&keyData_[0];
else
- keyLocatorStruct.keyOrCertificate = 0;
+ keyLocatorStruct.keyData = 0;
// TODO: Implement keyName.
}
@@ -26,7 +26,7 @@
void KeyLocator::set(const struct ndn_KeyLocator &keyLocatorStruct)
{
type_ = keyLocatorStruct.type;
- setVector(keyOrCertificate_, keyLocatorStruct.keyOrCertificate, keyLocatorStruct.keyOrCertificateLength);
+ setVector(keyData_, keyLocatorStruct.keyData, keyLocatorStruct.keyDataLength);
// TODO: Implement keyName.
}
diff --git a/ndn-cpp/key.hpp b/ndn-cpp/key.hpp
index f221505..c9037b1 100644
--- a/ndn-cpp/key.hpp
+++ b/ndn-cpp/key.hpp
@@ -33,23 +33,38 @@
ndn_KeyLocatorType getType() const { return type_; }
- const std::vector<unsigned char> &getKeyOrCertificate() const { return keyOrCertificate_; }
+ const std::vector<unsigned char> &getKeyData() const { return keyData_; }
// TODO: Implement getKeyName.
void setType(ndn_KeyLocatorType type) { type_ = type; }
- void setKeyOrCertificate(const std::vector<unsigned char> &keyOrCertificate) { keyOrCertificate_ = keyOrCertificate; }
- void setKeyOrCertificate(const unsigned char *keyOrCertificate, unsigned int keyOrCertificateLength)
+ void setKeyData(const std::vector<unsigned char> &keyData) { keyData_ = keyData; }
+ void setKeyData(const unsigned char *keyData, unsigned int keyDataLength)
{
- setVector(keyOrCertificate_, keyOrCertificate, keyOrCertificateLength);
+ setVector(keyData_, keyData, keyDataLength);
}
+ /**
+ * @deprecated Use getKeyData().
+ */
+ const std::vector<unsigned char> &getKeyOrCertificate() const { return getKeyData(); }
+
+ /**
+ * @deprecated Use setKeyData.
+ */
+ void setKeyOrCertificate(const std::vector<unsigned char> &keyData) { setKeyData(keyData); }
+
+ /**
+ * @deprecated Use setKeyData.
+ */
+ void setKeyOrCertificate(const unsigned char *keyData, unsigned int keyDataLength) { setKeyData(keyData, keyDataLength); }
+
// TODO: Implement setKeyName.
private:
ndn_KeyLocatorType type_;
- std::vector<unsigned char> keyOrCertificate_; /**< used if type_ is ndn_KeyLocatorType_KEY or ndn_KeyLocatorType_CERTIFICATE */
+ std::vector<unsigned char> keyData_; /**< used if type_ is ndn_KeyLocatorType_KEY or ndn_KeyLocatorType_CERTIFICATE */
// TODO: Implement keyName.
};
diff --git a/tests/test-encode-decode-data.cpp b/tests/test-encode-decode-data.cpp
index 176353c..61a1202 100644
--- a/tests/test-encode-decode-data.cpp
+++ b/tests/test-encode-decode-data.cpp
@@ -118,9 +118,9 @@
cout << "signedInfo.keyLocator: ";
if (data.getSignedInfo().getKeyLocator().getType() >= 0) {
if (data.getSignedInfo().getKeyLocator().getType() == ndn_KeyLocatorType_KEY)
- cout << "Key: " << toHex(data.getSignedInfo().getKeyLocator().getKeyOrCertificate()) << endl;
+ cout << "Key: " << toHex(data.getSignedInfo().getKeyLocator().getKeyData()) << endl;
else if (data.getSignedInfo().getKeyLocator().getType() == ndn_KeyLocatorType_CERTIFICATE)
- cout << "Certificate: " << toHex(data.getSignedInfo().getKeyLocator().getKeyOrCertificate()) << endl;
+ cout << "Certificate: " << toHex(data.getSignedInfo().getKeyLocator().getKeyData()) << endl;
else if (data.getSignedInfo().getKeyLocator().getType() == ndn_KeyLocatorType_KEYNAME)
// TODO: Implement keyName.
cout << "keyName" << endl;