Internal: Use C struct ndn_Blob where possible. Make ndn::Blob work with ndn_Blob.
diff --git a/ndn-cpp/c/encoding/binary-xml-data.c b/ndn-cpp/c/encoding/binary-xml-data.c
index 25cf16a..0f28ff5 100644
--- a/ndn-cpp/c/encoding/binary-xml-data.c
+++ b/ndn-cpp/c/encoding/binary-xml-data.c
@@ -19,13 +19,11 @@
   
   // TODO: Check if digestAlgorithm is the same as the default, and skip it, otherwise encode it as UDATA.
 
-  if ((error = ndn_BinaryXmlEncoder_writeOptionalBlobDTagElement
-      (encoder, ndn_BinaryXml_DTag_Witness, signature->witness, signature->witnessLength)))
+  if ((error = ndn_BinaryXmlEncoder_writeOptionalBlobDTagElement(encoder, ndn_BinaryXml_DTag_Witness, &signature->witness)))
     return error;
 
   // Require a signature.
-  if ((error = ndn_BinaryXmlEncoder_writeBlobDTagElement
-      (encoder, ndn_BinaryXml_DTag_SignatureBits, signature->signature, signature->signatureLength)))
+  if ((error = ndn_BinaryXmlEncoder_writeBlobDTagElement(encoder, ndn_BinaryXml_DTag_SignatureBits, &signature->signature)))
     return error;
   
   if ((error = ndn_BinaryXmlEncoder_writeElementClose(encoder)))
@@ -40,15 +38,15 @@
   if ((error = ndn_BinaryXmlDecoder_readElementStartDTag(decoder, ndn_BinaryXml_DTag_Signature)))
     return error;
   
-  /* TODO: digestAlgorithm as UDATA */ signature->digestAlgorithm = 0; signature->digestAlgorithmLength = 0;
+  /* TODO: digestAlgorithm as UDATA */ signature->digestAlgorithm.value = 0; signature->digestAlgorithm.length = 0;
   
   if ((error = ndn_BinaryXmlDecoder_readOptionalBinaryDTagElement
-      (decoder, ndn_BinaryXml_DTag_Witness, 0, &signature->witness, &signature->witnessLength)))
+      (decoder, ndn_BinaryXml_DTag_Witness, 0, &signature->witness)))
     return error;
   
   // Require a signature.
   if ((error = ndn_BinaryXmlDecoder_readBinaryDTagElement
-      (decoder, ndn_BinaryXml_DTag_SignatureBits, 0, &signature->signature, &signature->signatureLength)))
+      (decoder, ndn_BinaryXml_DTag_SignatureBits, 0, &signature->signature)))
     return error;
   
   if ((error = ndn_BinaryXmlDecoder_readElementClose(decoder)))
@@ -76,23 +74,22 @@
   
   if (!(metaInfo->type < 0 || metaInfo->type == ndn_ContentType_DATA)) {
     // Not the default of DATA, so we need to encode the type.
-    uint8_t *typeBytes;
-    size_t typeBytesLength = 3;
+    struct ndn_Blob typeBytes;
+    typeBytes.length = 3;
     if (metaInfo->type == ndn_ContentType_ENCR)
-      typeBytes = "\x10\xD0\x91";
+      typeBytes.value = "\x10\xD0\x91";
     else if (metaInfo->type == ndn_ContentType_GONE)
-      typeBytes = "\x18\xE3\x44";
+      typeBytes.value = "\x18\xE3\x44";
     else if (metaInfo->type == ndn_ContentType_KEY)
-      typeBytes = "\x28\x46\x3F";
+      typeBytes.value = "\x28\x46\x3F";
     else if (metaInfo->type == ndn_ContentType_LINK)
-      typeBytes = "\x2C\x83\x4A";
+      typeBytes.value = "\x2C\x83\x4A";
     else if (metaInfo->type == ndn_ContentType_NACK)
-      typeBytes = "\x34\x00\x8A";
+      typeBytes.value = "\x34\x00\x8A";
     else
       return NDN_ERROR_unrecognized_ndn_ContentType;
 
-    if ((error = ndn_BinaryXmlEncoder_writeBlobDTagElement
-        (encoder, ndn_BinaryXml_DTag_Type, typeBytes, typeBytesLength)))
+    if ((error = ndn_BinaryXmlEncoder_writeBlobDTagElement(encoder, ndn_BinaryXml_DTag_Type, &typeBytes)))
       return error;
   }
   
@@ -101,7 +98,7 @@
     return error;
   
   if ((error = ndn_BinaryXmlEncoder_writeOptionalBlobDTagElement
-      (encoder, ndn_BinaryXml_DTag_FinalBlockID, metaInfo->finalBlockID.value, metaInfo->finalBlockID.valueLength)))
+      (encoder, ndn_BinaryXml_DTag_FinalBlockID, &metaInfo->finalBlockID.value)))
     return error;
  
   // This will skip encoding if there is no key locator.
@@ -127,27 +124,26 @@
       (decoder, ndn_BinaryXml_DTag_Timestamp, &metaInfo->timestampMilliseconds))
     return error;
   
-  uint8_t *typeBytes;
-  size_t typeBytesLength;
+  struct ndn_Blob typeBytes;
   if ((error = ndn_BinaryXmlDecoder_readOptionalBinaryDTagElement
-      (decoder, ndn_BinaryXml_DTag_Type, 0, &typeBytes, &typeBytesLength)))
+      (decoder, ndn_BinaryXml_DTag_Type, 0, &typeBytes)))
     return error;
-  if (typeBytesLength == 0)
+  if (typeBytes.length == 0)
     // The default Type is DATA.
     metaInfo->type = ndn_ContentType_DATA;
-  else if (typeBytesLength == 3) {
+  else if (typeBytes.length == 3) {
     // All the recognized content types are 3 bytes.
-    if (ndn_memcmp(typeBytes, "\x0C\x04\xC0", typeBytesLength) == 0)
+    if (ndn_memcmp(typeBytes.value, "\x0C\x04\xC0", typeBytes.length) == 0)
       metaInfo->type = ndn_ContentType_DATA;
-    else if (ndn_memcmp(typeBytes, "\x10\xD0\x91", typeBytesLength) == 0)
+    else if (ndn_memcmp(typeBytes.value, "\x10\xD0\x91", typeBytes.length) == 0)
       metaInfo->type = ndn_ContentType_ENCR;
-    else if (ndn_memcmp(typeBytes, "\x18\xE3\x44", typeBytesLength) == 0)
+    else if (ndn_memcmp(typeBytes.value, "\x18\xE3\x44", typeBytes.length) == 0)
       metaInfo->type = ndn_ContentType_GONE;
-    else if (ndn_memcmp(typeBytes, "\x28\x46\x3F", typeBytesLength) == 0)
+    else if (ndn_memcmp(typeBytes.value, "\x28\x46\x3F", typeBytes.length) == 0)
       metaInfo->type = ndn_ContentType_KEY;
-    else if (ndn_memcmp(typeBytes, "\x2C\x83\x4A", typeBytesLength) == 0)
+    else if (ndn_memcmp(typeBytes.value, "\x2C\x83\x4A", typeBytes.length) == 0)
       metaInfo->type = ndn_ContentType_LINK;
-    else if (ndn_memcmp(typeBytes, "\x34\x00\x8A", typeBytesLength) == 0)
+    else if (ndn_memcmp(typeBytes.value, "\x34\x00\x8A", typeBytes.length) == 0)
       metaInfo->type = ndn_ContentType_NACK;
     else
       return NDN_ERROR_unrecognized_ndn_ContentType;
@@ -160,7 +156,7 @@
     return error;
 
   if ((error = ndn_BinaryXmlDecoder_readOptionalBinaryDTagElement
-      (decoder, ndn_BinaryXml_DTag_FinalBlockID, 0, &metaInfo->finalBlockID.value, &metaInfo->finalBlockID.valueLength)))
+      (decoder, ndn_BinaryXml_DTag_FinalBlockID, 0, &metaInfo->finalBlockID.value)))
     return error;
 
   if ((error = ndn_decodeOptionalBinaryXmlKeyLocator(&signature->keyLocator, decoder)))
@@ -190,8 +186,7 @@
   if ((error = encodeSignedInfo(&data->signature, &data->metaInfo, encoder)))
     return error;
 
-  if ((error = ndn_BinaryXmlEncoder_writeBlobDTagElement
-      (encoder, ndn_BinaryXml_DTag_Content, data->content, data->contentLength)))
+  if ((error = ndn_BinaryXmlEncoder_writeBlobDTagElement(encoder, ndn_BinaryXml_DTag_Content, &data->content)))
     return error;
 
   *signedPortionEndOffset = encoder->offset;
@@ -234,8 +229,7 @@
     ndn_MetaInfo_initialize(&data->metaInfo);
 
   // Require a Content element, but set allowNull to allow a missing BLOB.
-  if ((error = ndn_BinaryXmlDecoder_readBinaryDTagElement
-      (decoder, ndn_BinaryXml_DTag_Content, 1, &data->content, &data->contentLength)))
+  if ((error = ndn_BinaryXmlDecoder_readBinaryDTagElement(decoder, ndn_BinaryXml_DTag_Content, 1, &data->content)))
     return error; 
   
   *signedPortionEndOffset = decoder->offset;
diff --git a/ndn-cpp/c/encoding/binary-xml-decoder.c b/ndn-cpp/c/encoding/binary-xml-decoder.c
index 6cbb8ac..eab5cdf 100644
--- a/ndn-cpp/c/encoding/binary-xml-decoder.c
+++ b/ndn-cpp/c/encoding/binary-xml-decoder.c
@@ -140,7 +140,7 @@
 }
 
 ndn_Error ndn_BinaryXmlDecoder_readBinaryDTagElement
-  (struct ndn_BinaryXmlDecoder *self, unsigned int expectedTag, int allowNull, uint8_t **value, size_t *valueLength)
+  (struct ndn_BinaryXmlDecoder *self, unsigned int expectedTag, int allowNull, struct ndn_Blob *value)
 {
   ndn_Error error;
   if ((error = ndn_BinaryXmlDecoder_readElementStartDTag(self, expectedTag)))
@@ -153,8 +153,8 @@
     if (unsafeGetOctet(self) == ndn_BinaryXml_CLOSE) {
       // The binary item is missing, and this is allowed, so read the element close and return a null value.
       ++self->offset;
-      *value = 0;
-      *valueLength = 0;
+      value->value = 0;
+      value->length = 0;
       return NDN_ERROR_success;
     }
   }
@@ -164,9 +164,9 @@
   if ((error = ndn_BinaryXmlDecoder_decodeTypeAndValue(self, &itemType, &uintValueLength)))
     return error;
   // Ignore itemType.
-  *value = self->input + self->offset;
-  *valueLength = (size_t)uintValueLength;
-  self->offset += *valueLength;
+  value->value = self->input + self->offset;
+  value->length = (size_t)uintValueLength;
+  self->offset += value->length;
   
   if ((error = ndn_BinaryXmlDecoder_readElementClose(self)))
     return error;
@@ -175,26 +175,26 @@
 }
 
 ndn_Error ndn_BinaryXmlDecoder_readOptionalBinaryDTagElement
-  (struct ndn_BinaryXmlDecoder *self, unsigned int expectedTag, int allowNull, uint8_t **value, size_t *valueLength)
+  (struct ndn_BinaryXmlDecoder *self, unsigned int expectedTag, int allowNull, struct ndn_Blob *value)
 {
   ndn_Error error;
   int gotExpectedTag;
   if ((error = ndn_BinaryXmlDecoder_peekDTag(self, expectedTag, &gotExpectedTag)))
     return error;
   if (gotExpectedTag) {
-    if ((error = ndn_BinaryXmlDecoder_readBinaryDTagElement(self, expectedTag, allowNull, value, valueLength)))
+    if ((error = ndn_BinaryXmlDecoder_readBinaryDTagElement(self, expectedTag, allowNull, value)))
       return error;
   }
   else {
-    *value = 0;
-    *valueLength = 0;
+    value->value = 0;
+    value->length = 0;
   }  
   
   return NDN_ERROR_success;
 }
 
 ndn_Error ndn_BinaryXmlDecoder_readUDataDTagElement
-  (struct ndn_BinaryXmlDecoder *self, unsigned int expectedTag, uint8_t **value, size_t *valueLength)
+  (struct ndn_BinaryXmlDecoder *self, unsigned int expectedTag, struct ndn_Blob *value)
 {
   ndn_Error error;
   if ((error = ndn_BinaryXmlDecoder_readElementStartDTag(self, expectedTag)))
@@ -206,9 +206,9 @@
     return error;
   if (itemType != ndn_BinaryXml_UDATA)
     return NDN_ERROR_item_is_not_UDATA;
-  *value = self->input + self->offset;
-  *valueLength = uintValueLength;
-  self->offset += *valueLength;
+  value->value = self->input + self->offset;
+  value->length = uintValueLength;
+  self->offset += value->length;
   
   if ((error = ndn_BinaryXmlDecoder_readElementClose(self)))
     return error;
@@ -217,19 +217,19 @@
 }
 
 ndn_Error ndn_BinaryXmlDecoder_readOptionalUDataDTagElement
-  (struct ndn_BinaryXmlDecoder *self, unsigned int expectedTag, uint8_t **value, size_t *valueLength)
+  (struct ndn_BinaryXmlDecoder *self, unsigned int expectedTag, struct ndn_Blob *value)
 {
   ndn_Error error;
   int gotExpectedTag;
   if ((error = ndn_BinaryXmlDecoder_peekDTag(self, expectedTag, &gotExpectedTag)))
     return error;
   if (gotExpectedTag) {
-    if ((error = ndn_BinaryXmlDecoder_readUDataDTagElement(self, expectedTag, value, valueLength)))
+    if ((error = ndn_BinaryXmlDecoder_readUDataDTagElement(self, expectedTag, value)))
       return error;
   }
   else {
-    *value = 0;
-    *valueLength = 0;
+    value->value = 0;
+    value->length = 0;
   }  
   
   return NDN_ERROR_success;
@@ -238,13 +238,12 @@
 ndn_Error ndn_BinaryXmlDecoder_readUnsignedIntegerDTagElement
   (struct ndn_BinaryXmlDecoder *self, unsigned int expectedTag, unsigned int *value)
 {
-  uint8_t *udataValue;
-  size_t udataValueLength;
+  struct ndn_Blob udataValue;
   ndn_Error error;
-  if ((error = ndn_BinaryXmlDecoder_readUDataDTagElement(self, expectedTag, &udataValue, &udataValueLength)))
+  if ((error = ndn_BinaryXmlDecoder_readUDataDTagElement(self, expectedTag, &udataValue)))
     return error;
   
-  if ((error = parseUnsignedDecimalInt(udataValue, udataValueLength, value)))
+  if ((error = parseUnsignedDecimalInt(udataValue.value, udataValue.length, value)))
     return error;
   
   return NDN_ERROR_success;
@@ -275,12 +274,11 @@
   (struct ndn_BinaryXmlDecoder *self, unsigned int expectedTag, double *milliseconds)
 {
   ndn_Error error;
-  uint8_t *bytes;
-  size_t bytesLength;
-  if ((error = ndn_BinaryXmlDecoder_readBinaryDTagElement(self, expectedTag, 0, &bytes, &bytesLength)))
+  struct ndn_Blob bytes;
+  if ((error = ndn_BinaryXmlDecoder_readBinaryDTagElement(self, expectedTag, 0, &bytes)))
     return error;
     
-  *milliseconds = 1000.0 * ndn_BinaryXmlDecoder_unsignedBigEndianToDouble(bytes, bytesLength) / 4096.0;
+  *milliseconds = 1000.0 * ndn_BinaryXmlDecoder_unsignedBigEndianToDouble(bytes.value, bytes.length) / 4096.0;
   return NDN_ERROR_success;  
 }
 
diff --git a/ndn-cpp/c/encoding/binary-xml-decoder.h b/ndn-cpp/c/encoding/binary-xml-decoder.h
index a520a0f..3e16497 100644
--- a/ndn-cpp/c/encoding/binary-xml-decoder.h
+++ b/ndn-cpp/c/encoding/binary-xml-decoder.h
@@ -9,6 +9,7 @@
 
 #include "../common.h"
 #include "../errors.h"
+#include "../util/blob.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -71,14 +72,12 @@
  * @param expectedTag the expected value for DTAG
  * @param allowNull 1 if the binary item may be missing
  * @param value output a pointer to the binary data inside self's input buffer. However, if allowNull is 1 and the
- * binary data item is absent, then return 0.
- * @param valueLength output the length of the binary data. However, if allowNull is 1 and the
- * binary data item is absent, then return 0.
+ * binary data item is absent, then set value and length to 0.
  * @return 0 for success, else an error code, including an error if not the expected tag, or if allowNull is 0
  * and the binary data is absent
  */
 ndn_Error ndn_BinaryXmlDecoder_readBinaryDTagElement
-  (struct ndn_BinaryXmlDecoder *self, unsigned int expectedTag, int allowNull, uint8_t **value, size_t *valueLength);
+  (struct ndn_BinaryXmlDecoder *self, unsigned int expectedTag, int allowNull, struct ndn_Blob *value);
 
 /**
  * Peek at the next element and if it is the expectedTag, call ndn_BinaryXmlDecoder_readBinaryDTagElement.
@@ -87,13 +86,11 @@
  * @param expectedTag the expected value for DTAG
  * @param allowNull 1 if the binary item may be missing
  * @param value output a pointer to the binary data inside self's input buffer. However, if allowNull is 1 and the
- * binary data item is absent, then return 0.
- * @param valueLength output the length of the binary data. However, if allowNull is 1 and the
- * binary data item is absent, then return 0.
+ * binary data item is absent, then set value and length to 0.
  * @return 0 for success, else an error code, including if allowNull is 0 and the binary data is absent
  */
 ndn_Error ndn_BinaryXmlDecoder_readOptionalBinaryDTagElement
-  (struct ndn_BinaryXmlDecoder *self, unsigned int expectedTag, int allowNull, uint8_t **value, size_t *valueLength);
+  (struct ndn_BinaryXmlDecoder *self, unsigned int expectedTag, int allowNull, struct ndn_Blob *value);
 
 /**
  * Decode the header from self's input starting at offset, expecting the type to be DTAG and the value to be expectedTag.
@@ -102,11 +99,10 @@
  * @param self pointer to the ndn_BinaryXmlDecoder struct
  * @param expectedTag the expected value for DTAG
  * @param value output a pointer to the binary data inside self's input buffer.
- * @param valueLength output the length of the binary data.
  * @return 0 for success, else an error code, including an error if not the expected tag, or if the item is not UDATA.
  */
 ndn_Error ndn_BinaryXmlDecoder_readUDataDTagElement
-  (struct ndn_BinaryXmlDecoder *self, unsigned int expectedTag, uint8_t **value, size_t *valueLength);
+  (struct ndn_BinaryXmlDecoder *self, unsigned int expectedTag, struct ndn_Blob *value);
 
 /**
  * Peek at the next element and if it is the expectedTag, call ndn_BinaryXmlDecoder_readUDataDTagElement.
@@ -114,13 +110,11 @@
  * @param self pointer to the ndn_BinaryXmlDecoder struct
  * @param expectedTag the expected value for DTAG
  * @param value output a pointer to the binary data inside self's input buffer. However, if allowNull is 1 and the
- * binary data item is absent, then return 0.
- * @param valueLength output the length of the binary data. However, if allowNull is 1 and the
- * binary data item is absent, then return 0.
+ * binary data item is absent, then set value and length to 0.
  * @return 0 for success, else an error code.
  */
 ndn_Error ndn_BinaryXmlDecoder_readOptionalUDataDTagElement
-  (struct ndn_BinaryXmlDecoder *self, unsigned int expectedTag, uint8_t **value, size_t *valueLength);
+  (struct ndn_BinaryXmlDecoder *self, unsigned int expectedTag, struct ndn_Blob *value);
 
 /**
  * Decode the header from self's input starting at offset, expecting the type to be DTAG and the value to be expectedTag.
diff --git a/ndn-cpp/c/encoding/binary-xml-encoder.c b/ndn-cpp/c/encoding/binary-xml-encoder.c
index 652de3e..10f6cd6 100644
--- a/ndn-cpp/c/encoding/binary-xml-encoder.c
+++ b/ndn-cpp/c/encoding/binary-xml-encoder.c
@@ -217,25 +217,25 @@
   return NDN_ERROR_success;
 }
 
-ndn_Error ndn_BinaryXmlEncoder_writeBlob(struct ndn_BinaryXmlEncoder *self, uint8_t *value, size_t valueLength)
+ndn_Error ndn_BinaryXmlEncoder_writeBlob(struct ndn_BinaryXmlEncoder *self, struct ndn_Blob *value)
 {
   ndn_Error error;
-  if ((error = ndn_BinaryXmlEncoder_encodeTypeAndValue(self, ndn_BinaryXml_BLOB, valueLength)))
+  if ((error = ndn_BinaryXmlEncoder_encodeTypeAndValue(self, ndn_BinaryXml_BLOB, value->length)))
     return error;
   
-  if ((error = writeArray(self, value, valueLength)))
+  if ((error = writeArray(self, value->value, value->length)))
     return error;
   
   return NDN_ERROR_success;
 }
 
-ndn_Error ndn_BinaryXmlEncoder_writeBlobDTagElement(struct ndn_BinaryXmlEncoder *self, unsigned int tag, uint8_t *value, size_t valueLength)
+ndn_Error ndn_BinaryXmlEncoder_writeBlobDTagElement(struct ndn_BinaryXmlEncoder *self, unsigned int tag, struct ndn_Blob *value)
 {
   ndn_Error error;
   if ((error = ndn_BinaryXmlEncoder_writeElementStartDTag(self, tag)))
     return error;
   
-  if ((error = ndn_BinaryXmlEncoder_writeBlob(self, value, valueLength)))
+  if ((error = ndn_BinaryXmlEncoder_writeBlob(self, value)))
     return error;  
   
   if ((error = ndn_BinaryXmlEncoder_writeElementClose(self)))
@@ -244,25 +244,25 @@
   return NDN_ERROR_success;
 }
 
-ndn_Error ndn_BinaryXmlEncoder_writeUData(struct ndn_BinaryXmlEncoder *self, uint8_t *value, size_t valueLength)
+ndn_Error ndn_BinaryXmlEncoder_writeUData(struct ndn_BinaryXmlEncoder *self, struct ndn_Blob *value)
 {
   ndn_Error error;
-  if ((error = ndn_BinaryXmlEncoder_encodeTypeAndValue(self, ndn_BinaryXml_UDATA, valueLength)))
+  if ((error = ndn_BinaryXmlEncoder_encodeTypeAndValue(self, ndn_BinaryXml_UDATA, value->length)))
     return error;
   
-  if ((error = writeArray(self, value, valueLength)))
+  if ((error = writeArray(self, value->value, value->length)))
     return error;
   
   return NDN_ERROR_success;
 }
 
-ndn_Error ndn_BinaryXmlEncoder_writeUDataDTagElement(struct ndn_BinaryXmlEncoder *self, unsigned int tag, uint8_t *value, size_t valueLength)
+ndn_Error ndn_BinaryXmlEncoder_writeUDataDTagElement(struct ndn_BinaryXmlEncoder *self, unsigned int tag, struct ndn_Blob *value)
 {
   ndn_Error error;
   if ((error = ndn_BinaryXmlEncoder_writeElementStartDTag(self, tag)))
     return error;
   
-  if ((error = ndn_BinaryXmlEncoder_writeUData(self, value, valueLength)))
+  if ((error = ndn_BinaryXmlEncoder_writeUData(self, value)))
     return error;  
   
   if ((error = ndn_BinaryXmlEncoder_writeElementClose(self)))
diff --git a/ndn-cpp/c/encoding/binary-xml-encoder.h b/ndn-cpp/c/encoding/binary-xml-encoder.h
index c457185..81fa6b9 100644
--- a/ndn-cpp/c/encoding/binary-xml-encoder.h
+++ b/ndn-cpp/c/encoding/binary-xml-encoder.h
@@ -9,6 +9,7 @@
 
 #include "../errors.h"
 #include "../util/dynamic-uint8-array.h"
+#include "../util/blob.h"
 #include "binary-xml.h"
 
 #ifdef __cplusplus
@@ -66,36 +67,33 @@
 /**
  * Write a BLOB header, then the bytes of the blob value to self->output.
  * @param self pointer to the ndn_BinaryXmlEncoder struct
- * @param value an array of bytes for the blob value
- * @param valueLength the length of the array
+ * @param value A Blob with the array of bytes for the value.
  * @return 0 for success, else an error code
  */
-ndn_Error ndn_BinaryXmlEncoder_writeBlob(struct ndn_BinaryXmlEncoder *self, uint8_t *value, size_t valueLength);
+ndn_Error ndn_BinaryXmlEncoder_writeBlob(struct ndn_BinaryXmlEncoder *self, struct ndn_Blob *value);
 
 /**
  * Write an element start header using DTAG with the tag to self->output, then the blob, then an element close.
  * (If you want to just write the blob, use ndn_BinaryXmlEncoder_writeBlob .)
  * @param self pointer to the ndn_BinaryXmlEncoder struct
  * @param tag the DTAG tag
- * @param value an array of bytes for the blob value
- * @param valueLength the length of the array
+ * @param value A Blob with the array of bytes for the value.
  * @return 0 for success, else an error code
  */
-ndn_Error ndn_BinaryXmlEncoder_writeBlobDTagElement(struct ndn_BinaryXmlEncoder *self, unsigned int tag, uint8_t *value, size_t valueLength);
+ndn_Error ndn_BinaryXmlEncoder_writeBlobDTagElement(struct ndn_BinaryXmlEncoder *self, unsigned int tag, struct ndn_Blob *value);
 
 /**
  * If value or valueLen is 0 then do nothing, otherwise call ndn_BinaryXmlEncoder_writeBlobDTagElement.
- * @param self pointer to the ndn_BinaryXmlEncoder struct
- * @param tag the DTAG tag
- * @param value an array of bytes for the blob value
- * @param valueLength the length of the array
+ * @param self A pointer to the ndn_BinaryXmlEncoder struct.
+ * @param tag The DTAG tag.
+ * @param value A Blob with the array of bytes for the value.
  * @return 0 for success, else an error code
  */
 static inline ndn_Error ndn_BinaryXmlEncoder_writeOptionalBlobDTagElement
-  (struct ndn_BinaryXmlEncoder *self, unsigned int tag, uint8_t *value, size_t valueLength)
+  (struct ndn_BinaryXmlEncoder *self, unsigned int tag, struct ndn_Blob *value)
 {
-  if (value && valueLength > 0)
-    return ndn_BinaryXmlEncoder_writeBlobDTagElement(self, tag, value, valueLength);
+  if (value->value && value->length > 0)
+    return ndn_BinaryXmlEncoder_writeBlobDTagElement(self, tag, value);
   else
     return NDN_ERROR_success;
 }
@@ -103,36 +101,33 @@
 /**
  * Write a UDATA header, then the bytes of the UDATA value to self->output.
  * @param self pointer to the ndn_BinaryXmlEncoder struct
- * @param value an array of bytes for the value
- * @param valueLength the length of the array
+ * @param value A Blob with the array of bytes for the value.
  * @return 0 for success, else an error code
  */
-ndn_Error ndn_BinaryXmlEncoder_writeUData(struct ndn_BinaryXmlEncoder *self, uint8_t *value, size_t valueLength);
+ndn_Error ndn_BinaryXmlEncoder_writeUData(struct ndn_BinaryXmlEncoder *self, struct ndn_Blob *value);
 
 /**
  * Write an element start header using DTAG with the tag to self->output, then the UDATA value, then an element close.
  * (If you want to just write the UDATA value, use ndn_BinaryXmlEncoder_writeUData .)
  * @param self pointer to the ndn_BinaryXmlEncoder struct
  * @param tag the DTAG tag
- * @param value an array of bytes for the value
- * @param valueLength the length of the array
+ * @param value A Blob with the array of bytes for the value.
  * @return 0 for success, else an error code
  */
-ndn_Error ndn_BinaryXmlEncoder_writeUDataDTagElement(struct ndn_BinaryXmlEncoder *self, unsigned int tag, uint8_t *value, size_t valueLength);
+ndn_Error ndn_BinaryXmlEncoder_writeUDataDTagElement(struct ndn_BinaryXmlEncoder *self, unsigned int tag, struct ndn_Blob *value);
 
 /**
  * If value or valueLen is 0 then do nothing, otherwise call ndn_BinaryXmlEncoder_writeUDataDTagElement.
  * @param self pointer to the ndn_BinaryXmlEncoder struct
  * @param tag the DTAG tag
- * @param value an array of bytes for the value
- * @param valueLength the length of the array
+ * @param value A Blob with the array of bytes for the value.
  * @return 0 for success, else an error code
  */
 static inline ndn_Error ndn_BinaryXmlEncoder_writeOptionalUDataDTagElement
-  (struct ndn_BinaryXmlEncoder *self, unsigned int tag, uint8_t *value, size_t valueLength)
+  (struct ndn_BinaryXmlEncoder *self, unsigned int tag, struct ndn_Blob *value)
 {
-  if (value && valueLength > 0)
-    return ndn_BinaryXmlEncoder_writeUDataDTagElement(self, tag, value, valueLength);
+  if (value->value && value->length > 0)
+    return ndn_BinaryXmlEncoder_writeUDataDTagElement(self, tag, value);
   else
     return NDN_ERROR_success;
 }
diff --git a/ndn-cpp/c/encoding/binary-xml-forwarding-entry.c b/ndn-cpp/c/encoding/binary-xml-forwarding-entry.c
index 8788cec..271029b 100644
--- a/ndn-cpp/c/encoding/binary-xml-forwarding-entry.c
+++ b/ndn-cpp/c/encoding/binary-xml-forwarding-entry.c
@@ -15,7 +15,7 @@
     return error;
     
   if ((error = ndn_BinaryXmlEncoder_writeOptionalUDataDTagElement
-      (encoder, ndn_BinaryXml_DTag_Action, forwardingEntry->action, forwardingEntry->actionLength)))
+      (encoder, ndn_BinaryXml_DTag_Action, &forwardingEntry->action)))
     return error;
   if ((error = ndn_encodeBinaryXmlName(&forwardingEntry->prefix, encoder)))
     return error;
@@ -46,7 +46,7 @@
     return error;
     
   if ((error = ndn_BinaryXmlDecoder_readOptionalUDataDTagElement
-      (decoder, ndn_BinaryXml_DTag_Action, &forwardingEntry->action, &forwardingEntry->actionLength)))
+      (decoder, ndn_BinaryXml_DTag_Action, &forwardingEntry->action)))
     return error;
   if ((error = ndn_decodeBinaryXmlName(&forwardingEntry->prefix, decoder)))
     return error;
diff --git a/ndn-cpp/c/encoding/binary-xml-interest.c b/ndn-cpp/c/encoding/binary-xml-interest.c
index a43ce3b..48d3fe0 100644
--- a/ndn-cpp/c/encoding/binary-xml-interest.c
+++ b/ndn-cpp/c/encoding/binary-xml-interest.c
@@ -26,8 +26,7 @@
     struct ndn_ExcludeEntry *entry = &exclude->entries[i];
     
     if (entry->type == ndn_Exclude_COMPONENT) {
-      if ((error = ndn_BinaryXmlEncoder_writeBlobDTagElement
-          (encoder, ndn_BinaryXml_DTag_Component, entry->component.value, entry->component.valueLength)))
+      if ((error = ndn_BinaryXmlEncoder_writeBlobDTagElement(encoder, ndn_BinaryXml_DTag_Component, &entry->component.value)))
         return error;
     }
     else if (entry->type == ndn_Exclude_ANY) {
@@ -60,15 +59,14 @@
       return error;    
     if (gotExpectedTag) {
       // Component
-      uint8_t *component;
-      size_t componentLen;
-      if ((error = ndn_BinaryXmlDecoder_readBinaryDTagElement(decoder, ndn_BinaryXml_DTag_Component, 0, &component, &componentLen)))
+      struct ndn_Blob component;
+      if ((error = ndn_BinaryXmlDecoder_readBinaryDTagElement(decoder, ndn_BinaryXml_DTag_Component, 0, &component)))
         return error;
     
       // Add the component entry.
       if (exclude->nEntries >= exclude->maxEntries)
         return NDN_ERROR_read_an_entry_past_the_maximum_number_of_entries_allowed_in_the_exclude;
-      ndn_ExcludeEntry_initialize(exclude->entries + exclude->nEntries, ndn_Exclude_COMPONENT, component, componentLen);
+      ndn_ExcludeEntry_initialize(exclude->entries + exclude->nEntries, ndn_Exclude_COMPONENT, component.value, component.length);
       ++exclude->nEntries;
 
       continue;
@@ -96,9 +94,8 @@
       return error;    
     if (gotExpectedTag) {
       // Skip the Bloom and treat it as Any.
-      uint8_t *value;
-      size_t valueLen;
-      if ((error = ndn_BinaryXmlDecoder_readBinaryDTagElement(decoder, ndn_BinaryXml_DTag_Bloom, 0, &value, &valueLen)))
+      struct ndn_Blob value;
+      if ((error = ndn_BinaryXmlDecoder_readBinaryDTagElement(decoder, ndn_BinaryXml_DTag_Bloom, 0, &value)))
         return error;
     
       // Add the any entry.
@@ -160,8 +157,7 @@
       (encoder, ndn_BinaryXml_DTag_InterestLifetime, interest->interestLifetimeMilliseconds)))
     return error;
   
-  if ((error = ndn_BinaryXmlEncoder_writeOptionalBlobDTagElement
-      (encoder, ndn_BinaryXml_DTag_Nonce, interest->nonce, interest->nonceLength)))
+  if ((error = ndn_BinaryXmlEncoder_writeOptionalBlobDTagElement(encoder, ndn_BinaryXml_DTag_Nonce, &interest->nonce)))
     return error;
   
   if ((error = ndn_BinaryXmlEncoder_writeElementClose(encoder)))
@@ -214,7 +210,7 @@
     return error;
   
   if ((error = ndn_BinaryXmlDecoder_readOptionalBinaryDTagElement
-      (decoder, ndn_BinaryXml_DTag_Nonce, 0, &interest->nonce, &interest->nonceLength)))
+      (decoder, ndn_BinaryXml_DTag_Nonce, 0, &interest->nonce)))
     return error;
 
   if ((error = ndn_BinaryXmlDecoder_readElementClose(decoder)))
diff --git a/ndn-cpp/c/encoding/binary-xml-key.c b/ndn-cpp/c/encoding/binary-xml-key.c
index 5ae3db0..d9cce61 100644
--- a/ndn-cpp/c/encoding/binary-xml-key.c
+++ b/ndn-cpp/c/encoding/binary-xml-key.c
@@ -18,7 +18,7 @@
   if (gotExpectedTag) {
     keyLocator->keyNameType = ndn_KeyNameType_PUBLISHER_PUBLIC_KEY_DIGEST;
     if ((error = ndn_BinaryXmlDecoder_readBinaryDTagElement
-        (decoder, ndn_BinaryXml_DTag_PublisherPublicKeyDigest, 0, &keyLocator->keyData, &keyLocator->keyDataLength)))
+        (decoder, ndn_BinaryXml_DTag_PublisherPublicKeyDigest, 0, &keyLocator->keyData)))
       return error;
   }
   else {
@@ -27,7 +27,7 @@
     if (gotExpectedTag) {
       keyLocator->keyNameType = ndn_KeyNameType_PUBLISHER_CERTIFICATE_DIGEST;
       if ((error = ndn_BinaryXmlDecoder_readBinaryDTagElement
-          (decoder, ndn_BinaryXml_DTag_PublisherCertificateDigest, 0, &keyLocator->keyData, &keyLocator->keyDataLength)))
+          (decoder, ndn_BinaryXml_DTag_PublisherCertificateDigest, 0, &keyLocator->keyData)))
         return error;
     }
     else {
@@ -36,7 +36,7 @@
       if (gotExpectedTag) {
         keyLocator->keyNameType = ndn_KeyNameType_PUBLISHER_ISSUER_KEY_DIGEST;
         if ((error = ndn_BinaryXmlDecoder_readBinaryDTagElement
-            (decoder, ndn_BinaryXml_DTag_PublisherIssuerKeyDigest, 0, &keyLocator->keyData, &keyLocator->keyDataLength)))
+            (decoder, ndn_BinaryXml_DTag_PublisherIssuerKeyDigest, 0, &keyLocator->keyData)))
           return error;
       }
       else {
@@ -45,13 +45,13 @@
         if (gotExpectedTag) {
           keyLocator->keyNameType = ndn_KeyNameType_PUBLISHER_ISSUER_CERTIFICATE_DIGEST;
           if ((error = ndn_BinaryXmlDecoder_readBinaryDTagElement
-              (decoder, ndn_BinaryXml_DTag_PublisherIssuerCertificateDigest, 0, &keyLocator->keyData, &keyLocator->keyDataLength)))
+              (decoder, ndn_BinaryXml_DTag_PublisherIssuerCertificateDigest, 0, &keyLocator->keyData)))
             return error;
         }
         else {
           // Key name data is omitted.
           keyLocator->keyNameType = -1;
-          keyLocator->keyDataLength = 0;
+          keyLocator->keyData.length = 0;
         }
       }
     }
@@ -70,13 +70,11 @@
     return error;
 
   if (keyLocator->type == ndn_KeyLocatorType_KEY) {
-    if ((error = ndn_BinaryXmlEncoder_writeBlobDTagElement
-        (encoder, ndn_BinaryXml_DTag_Key, keyLocator->keyData, keyLocator->keyDataLength)))
+    if ((error = ndn_BinaryXmlEncoder_writeBlobDTagElement(encoder, ndn_BinaryXml_DTag_Key, &keyLocator->keyData)))
       return error;    
   }
   else if (keyLocator->type == ndn_KeyLocatorType_CERTIFICATE) {
-    if ((error = ndn_BinaryXmlEncoder_writeBlobDTagElement
-        (encoder, ndn_BinaryXml_DTag_Certificate, keyLocator->keyData, keyLocator->keyDataLength)))
+    if ((error = ndn_BinaryXmlEncoder_writeBlobDTagElement(encoder, ndn_BinaryXml_DTag_Certificate, &keyLocator->keyData)))
       return error;    
   }
   else if (keyLocator->type == ndn_KeyLocatorType_KEYNAME) {
@@ -85,25 +83,25 @@
     if ((error = ndn_encodeBinaryXmlName(&keyLocator->keyName, encoder)))
       return error;
     
-    if ((int)keyLocator->keyNameType >= 0 && keyLocator->keyDataLength > 0) {
+    if ((int)keyLocator->keyNameType >= 0 && keyLocator->keyData.length > 0) {
       if (keyLocator->keyNameType == ndn_KeyNameType_PUBLISHER_PUBLIC_KEY_DIGEST) {
         if ((error = ndn_BinaryXmlEncoder_writeBlobDTagElement
-            (encoder, ndn_BinaryXml_DTag_PublisherPublicKeyDigest, keyLocator->keyData, keyLocator->keyDataLength)))
+            (encoder, ndn_BinaryXml_DTag_PublisherPublicKeyDigest, &keyLocator->keyData)))
           return error;    
       }
       else if (keyLocator->keyNameType == ndn_KeyNameType_PUBLISHER_CERTIFICATE_DIGEST) {
         if ((error = ndn_BinaryXmlEncoder_writeBlobDTagElement
-            (encoder, ndn_BinaryXml_DTag_PublisherCertificateDigest, keyLocator->keyData, keyLocator->keyDataLength)))
+            (encoder, ndn_BinaryXml_DTag_PublisherCertificateDigest, &keyLocator->keyData)))
           return error;    
       }
       else if (keyLocator->keyNameType == ndn_KeyNameType_PUBLISHER_ISSUER_KEY_DIGEST) {
         if ((error = ndn_BinaryXmlEncoder_writeBlobDTagElement
-            (encoder, ndn_BinaryXml_DTag_PublisherIssuerKeyDigest, keyLocator->keyData, keyLocator->keyDataLength)))
+            (encoder, ndn_BinaryXml_DTag_PublisherIssuerKeyDigest, &keyLocator->keyData)))
           return error;    
       }
       else if (keyLocator->keyNameType == ndn_KeyNameType_PUBLISHER_ISSUER_CERTIFICATE_DIGEST) {
         if ((error = ndn_BinaryXmlEncoder_writeBlobDTagElement
-            (encoder, ndn_BinaryXml_DTag_PublisherIssuerCertificateDigest, keyLocator->keyData, keyLocator->keyDataLength)))
+            (encoder, ndn_BinaryXml_DTag_PublisherIssuerCertificateDigest, &keyLocator->keyData)))
           return error;    
       }
       else
@@ -134,8 +132,7 @@
   if (gotExpectedTag) {
     keyLocator->type = ndn_KeyLocatorType_KEY;
     
-    if ((error = ndn_BinaryXmlDecoder_readBinaryDTagElement
-        (decoder, ndn_BinaryXml_DTag_Key, 0, &keyLocator->keyData, &keyLocator->keyDataLength)))
+    if ((error = ndn_BinaryXmlDecoder_readBinaryDTagElement(decoder, ndn_BinaryXml_DTag_Key, 0, &keyLocator->keyData)))
       return error;
   }
   else {
@@ -145,7 +142,7 @@
       keyLocator->type = ndn_KeyLocatorType_CERTIFICATE;
     
       if ((error = ndn_BinaryXmlDecoder_readBinaryDTagElement
-          (decoder, ndn_BinaryXml_DTag_Certificate, 0, &keyLocator->keyData, &keyLocator->keyDataLength)))
+          (decoder, ndn_BinaryXml_DTag_Certificate, 0, &keyLocator->keyData)))
         return error;
     }
     else {
diff --git a/ndn-cpp/c/encoding/binary-xml-name.c b/ndn-cpp/c/encoding/binary-xml-name.c
index 00f5858..30cd60f 100644
--- a/ndn-cpp/c/encoding/binary-xml-name.c
+++ b/ndn-cpp/c/encoding/binary-xml-name.c
@@ -17,8 +17,7 @@
   
   size_t i;
   for (i = 0; i < name->nComponents; ++i) {
-    if ((error = ndn_BinaryXmlEncoder_writeBlobDTagElement
-        (encoder, ndn_BinaryXml_DTag_Component, name->components[i].value, name->components[i].valueLength)))
+    if ((error = ndn_BinaryXmlEncoder_writeBlobDTagElement(encoder, ndn_BinaryXml_DTag_Component, &name->components[i].value)))
       return error;
   }
   
@@ -44,15 +43,14 @@
       // No more components.
       break;
     
-    uint8_t *component;
-    size_t componentLen;
-    if ((error = ndn_BinaryXmlDecoder_readBinaryDTagElement(decoder, ndn_BinaryXml_DTag_Component, 0, &component, &componentLen)))
+    struct ndn_Blob component;
+    if ((error = ndn_BinaryXmlDecoder_readBinaryDTagElement(decoder, ndn_BinaryXml_DTag_Component, 0, &component)))
       return error;
     
     // Add the component to the name.
     if (name->nComponents >= name->maxComponents)
       return NDN_ERROR_read_a_component_past_the_maximum_number_of_components_allowed_in_the_name;
-    ndn_NameComponent_initialize(name->components + name->nComponents, component, componentLen);
+    ndn_NameComponent_initialize(name->components + name->nComponents, component.value, component.length);
     ++name->nComponents;
   }
   
diff --git a/ndn-cpp/c/encoding/binary-xml-publisher-public-key-digest.c b/ndn-cpp/c/encoding/binary-xml-publisher-public-key-digest.c
index 37015bc..4748147 100644
--- a/ndn-cpp/c/encoding/binary-xml-publisher-public-key-digest.c
+++ b/ndn-cpp/c/encoding/binary-xml-publisher-public-key-digest.c
@@ -11,13 +11,12 @@
 ndn_Error ndn_encodeBinaryXmlPublisherPublicKeyDigest
   (struct ndn_PublisherPublicKeyDigest *publisherPublicKeyDigest, struct ndn_BinaryXmlEncoder *encoder)
 {  
-  if (!publisherPublicKeyDigest->publisherPublicKeyDigest || publisherPublicKeyDigest->publisherPublicKeyDigestLength == 0)
+  if (!publisherPublicKeyDigest->publisherPublicKeyDigest.value || publisherPublicKeyDigest->publisherPublicKeyDigest.length == 0)
     return NDN_ERROR_success;
   
   ndn_Error error;
   if ((error = ndn_BinaryXmlEncoder_writeBlobDTagElement
-      (encoder, ndn_BinaryXml_DTag_PublisherPublicKeyDigest, publisherPublicKeyDigest->publisherPublicKeyDigest, 
-       publisherPublicKeyDigest->publisherPublicKeyDigestLength)))
+      (encoder, ndn_BinaryXml_DTag_PublisherPublicKeyDigest, &publisherPublicKeyDigest->publisherPublicKeyDigest)))
     return error;
   
   return NDN_ERROR_success;
@@ -28,8 +27,7 @@
 {
   ndn_Error error; 
   if ((error = ndn_BinaryXmlDecoder_readBinaryDTagElement
-      (decoder, ndn_BinaryXml_DTag_PublisherPublicKeyDigest, 0, &publisherPublicKeyDigest->publisherPublicKeyDigest,
-       &publisherPublicKeyDigest->publisherPublicKeyDigestLength)))
+      (decoder, ndn_BinaryXml_DTag_PublisherPublicKeyDigest, 0, &publisherPublicKeyDigest->publisherPublicKeyDigest)))
     return error;
   
   return NDN_ERROR_success;
@@ -47,8 +45,8 @@
       return error;
   }
   else {
-    publisherPublicKeyDigest->publisherPublicKeyDigest = 0;
-    publisherPublicKeyDigest->publisherPublicKeyDigestLength = 0;
+    publisherPublicKeyDigest->publisherPublicKeyDigest.value = 0;
+    publisherPublicKeyDigest->publisherPublicKeyDigest.length = 0;
   }
   
   return NDN_ERROR_success;