diff --git a/ndn-cpp/c/encoding/binary-xml-data.c b/ndn-cpp/c/encoding/binary-xml-data.c
index 564e6f4..37513f9 100644
--- a/ndn-cpp/c/encoding/binary-xml-data.c
+++ b/ndn-cpp/c/encoding/binary-xml-data.c
@@ -188,7 +188,7 @@
       return error;
   }
   else
-    ndn_SignedInfo_init(&data->signedInfo);
+    ndn_SignedInfo_init(&data->signedInfo, data->signedInfo.keyLocator.keyName.components, data->signedInfo.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/c/encoding/binary-xml-key.c b/ndn-cpp/c/encoding/binary-xml-key.c
index c1df758..42e4463 100644
--- a/ndn-cpp/c/encoding/binary-xml-key.c
+++ b/ndn-cpp/c/encoding/binary-xml-key.c
@@ -8,6 +8,54 @@
 #include "binary-xml-structure-decoder.h"
 #include "binary-xml-key.h"
 
+static ndn_Error decodeKeyNameData(struct ndn_KeyLocator *keyLocator, struct ndn_BinaryXmlDecoder *decoder)
+{
+  int gotExpectedTag;
+  ndn_Error error; 
+  if ((error = ndn_BinaryXmlDecoder_peekDTag(decoder, ndn_BinaryXml_DTag_PublisherPublicKeyDigest, &gotExpectedTag)))
+    return error;
+  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)))
+      return error;
+  }
+  else {
+    if ((error = ndn_BinaryXmlDecoder_peekDTag(decoder, ndn_BinaryXml_DTag_PublisherCertificateDigest, &gotExpectedTag)))
+      return error;
+    if (gotExpectedTag) {
+      keyLocator->keyNameType = ndn_KeyNameType_PUBLISHER_CERTIFICATE_DIGEST;
+      if ((error = ndn_BinaryXmlDecoder_readBinaryDTagElement
+          (decoder, ndn_BinaryXml_DTag_PublisherCertificateDigest, 0, &keyLocator->keyData, &keyLocator->keyDataLength)))
+        return error;
+    }
+    else {
+      if ((error = ndn_BinaryXmlDecoder_peekDTag(decoder, ndn_BinaryXml_DTag_PublisherIssuerKeyDigest, &gotExpectedTag)))
+        return error;
+      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)))
+          return error;
+      }
+      else {
+        if ((error = ndn_BinaryXmlDecoder_peekDTag(decoder, ndn_BinaryXml_DTag_PublisherIssuerCertificateDigest, &gotExpectedTag)))
+          return error;
+        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)))
+            return error;
+        }
+        else
+          return NDN_ERROR_decodeBinaryXmlKeyLocator_unrecognized_key_name_type;
+      }
+    }
+  }
+  
+  return NDN_ERROR_success;
+}
+
 ndn_Error ndn_encodeBinaryXmlKeyLocator(struct ndn_KeyLocator *keyLocator, struct ndn_BinaryXmlEncoder *encoder)
 {
   if (keyLocator->type < 0)
@@ -28,7 +76,36 @@
       return error;    
   }
   else if (keyLocator->type == ndn_KeyLocatorType_KEYNAME) {
-    // TODO: Implement keyName
+    if ((error = ndn_BinaryXmlEncoder_writeElementStartDTag(encoder, ndn_BinaryXml_DTag_KeyName)))
+      return error;
+    if ((error = ndn_encodeBinaryXmlName(&keyLocator->keyName, encoder)))
+      return error;
+    
+    if (keyLocator->keyNameType == ndn_KeyNameType_PUBLISHER_PUBLIC_KEY_DIGEST) {
+      if ((error = ndn_BinaryXmlEncoder_writeBlobDTagElement
+          (encoder, ndn_BinaryXml_DTag_PublisherPublicKeyDigest, keyLocator->keyData, keyLocator->keyDataLength)))
+        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)))
+        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)))
+        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)))
+        return error;    
+    }
+    else
+      return NDN_ERROR_unrecognized_ndn_KeyNameType;
+
+    if ((error = ndn_BinaryXmlEncoder_writeElementClose(encoder)))
+      return error;
   }
   else
     return NDN_ERROR_unrecognized_ndn_KeyLocatorType;
@@ -69,16 +146,16 @@
       if ((error = ndn_BinaryXmlDecoder_peekDTag(decoder, ndn_BinaryXml_DTag_KeyName, &gotExpectedTag)))
         return error;
       if (gotExpectedTag) {
-        // TODO: Implement keyName. For now, just use a structure decoder to skip it.
-        struct ndn_BinaryXmlStructureDecoder structureDecoder;
-        ndn_BinaryXmlStructureDecoder_init(&structureDecoder);
+        keyLocator->type = ndn_KeyLocatorType_KEYNAME;
         
-        ndn_BinaryXmlStructureDecoder_seek(&structureDecoder, decoder->offset);
-        if ((error = ndn_BinaryXmlStructureDecoder_findElementEnd(&structureDecoder, decoder->input, decoder->inputLength)))
+        if ((error = ndn_BinaryXmlDecoder_readElementStartDTag(decoder, ndn_BinaryXml_DTag_KeyName)))
           return error;
-        if (!structureDecoder.gotElementEnd)
-          return NDN_ERROR_read_past_the_end_of_the_input;
-        ndn_BinaryXmlDecoder_seek(decoder, structureDecoder.offset);        
+        if ((error = ndn_decodeBinaryXmlName(&keyLocator->keyName, decoder)))
+          return error;
+        if ((error = decodeKeyNameData(keyLocator, decoder)))
+          return error;        
+        if ((error = ndn_BinaryXmlDecoder_readElementClose(decoder)))
+          return error;
       }
       else
         return NDN_ERROR_decodeBinaryXmlKeyLocator_unrecognized_key_locator_type;
@@ -102,7 +179,7 @@
       return error;
   }
   else
-    ndn_KeyLocator_init(keyLocator);
+    ndn_KeyLocator_init(keyLocator, keyLocator->keyName.components, keyLocator->keyName.maxComponents);
   
   return NDN_ERROR_success;
 }
