In ndn_encodeBinaryXmlData, return signedFieldsBeginOffset and signedFieldsEndOffset
diff --git a/ndn-cpp/c/encoding/binary-xml-data.c b/ndn-cpp/c/encoding/binary-xml-data.c
index 4533fd0..b2d391a 100644
--- a/ndn-cpp/c/encoding/binary-xml-data.c
+++ b/ndn-cpp/c/encoding/binary-xml-data.c
@@ -129,7 +129,8 @@
   return NDN_ERROR_success;
 }
 
-ndn_Error ndn_encodeBinaryXmlData(struct ndn_Data *data, struct ndn_BinaryXmlEncoder *encoder)
+ndn_Error ndn_encodeBinaryXmlData
+  (struct ndn_Data *data, unsigned int *signedFieldsBeginOffset, unsigned int *signedFieldsEndOffset, struct ndn_BinaryXmlEncoder *encoder)
 {
   ndn_Error error;
   if ((error = ndn_BinaryXmlEncoder_writeElementStartDTag(encoder, ndn_BinaryXml_DTag_ContentObject)))
@@ -137,17 +138,21 @@
   
   if ((error = encodeSignature(&data->signature, encoder)))
     return NDN_ERROR_success;
+  
+  *signedFieldsBeginOffset = encoder->offset;
 
   if ((error = ndn_encodeBinaryXmlName(&data->name, encoder)))
     return error;
-
+  
   if ((error = encodeSignedInfo(&data->signedInfo, encoder)))
     return NDN_ERROR_success;
 
   if ((error = ndn_BinaryXmlEncoder_writeBlobDTagElement
       (encoder, ndn_BinaryXml_DTag_Content, data->content, data->contentLength)))
     return error;
-  
+
+  *signedFieldsEndOffset = encoder->offset;
+
   if ((error = ndn_BinaryXmlEncoder_writeElementClose(encoder)))
     return error;
   
diff --git a/ndn-cpp/c/encoding/binary-xml-data.h b/ndn-cpp/c/encoding/binary-xml-data.h
index 32c0cfb..df77d69 100644
--- a/ndn-cpp/c/encoding/binary-xml-data.h
+++ b/ndn-cpp/c/encoding/binary-xml-data.h
@@ -15,7 +15,18 @@
 extern "C" {
 #endif
 
-ndn_Error ndn_encodeBinaryXmlData(struct ndn_Data *data, struct ndn_BinaryXmlEncoder *encoder);
+/**
+ * Encode the data as binary XML.
+ * @param data Pointer to the data object the encode.
+ * @param signedFieldsBeginOffset Return the offset in the encoding of the beginning of the fields which are signed.
+ * If you are not encoding in order to sign, you can ignore this.
+ * @param signedFieldsEndOffset Return the offset in the encoding of the end of the fields which are signed.
+ * If you are not encoding in order to sign, you can ignore this.
+ * @param encoder Pointer to the encoder object which receives the encoding. 
+ * @return 
+ */
+ndn_Error ndn_encodeBinaryXmlData
+  (struct ndn_Data *data, unsigned int *signedFieldsBeginOffset, unsigned int *signedFieldsEndOffset, struct ndn_BinaryXmlEncoder *encoder);
 
 ndn_Error ndn_decodeBinaryXmlData(struct ndn_Data *data, struct ndn_BinaryXmlDecoder *decoder);
 
diff --git a/ndn-cpp/encoding/binary-xml-wire-format.cpp b/ndn-cpp/encoding/binary-xml-wire-format.cpp
index 7556777..3ef731c 100644
--- a/ndn-cpp/encoding/binary-xml-wire-format.cpp
+++ b/ndn-cpp/encoding/binary-xml-wire-format.cpp
@@ -33,7 +33,9 @@
   interest.get(interestStruct);
 
   BinaryXmlEncoder encoder;
-  ndn_encodeBinaryXmlInterest(&interestStruct, &encoder);
+  ndn_Error error;
+  if ((error = ndn_encodeBinaryXmlInterest(&interestStruct, &encoder)))
+    throw std::runtime_error(ndn_getErrorString(error));
      
   return encoder.getOutput();
 }
@@ -64,7 +66,10 @@
   data.get(dataStruct);
 
   BinaryXmlEncoder encoder;
-  ndn_encodeBinaryXmlData(&dataStruct, &encoder);
+  unsigned int dummyBeginOffset, dummyEndOffset;
+  ndn_Error error;
+  if ((error = ndn_encodeBinaryXmlData(&dataStruct, &dummyBeginOffset, &dummyEndOffset, &encoder)))
+    throw std::runtime_error(ndn_getErrorString(error));
      
   return encoder.getOutput();
 }