Added separate PublishPublicKeyDigest and use in Interest.
diff --git a/ndn-cpp/Interest.cpp b/ndn-cpp/Interest.cpp
index 382db2e..797fa35 100644
--- a/ndn-cpp/Interest.cpp
+++ b/ndn-cpp/Interest.cpp
@@ -41,10 +41,7 @@
 	minSuffixComponents_ = interestStruct.minSuffixComponents;
 	maxSuffixComponents_ = interestStruct.maxSuffixComponents;
 	
-	publisherPublicKeyDigest_.clear();
-  if (interestStruct.publisherPublicKeyDigest)
-    publisherPublicKeyDigest_.insert
-      (publisherPublicKeyDigest_.begin(), interestStruct.publisherPublicKeyDigest, interestStruct.publisherPublicKeyDigest + interestStruct.publisherPublicKeyDigestLength);
+	publisherPublicKeyDigest_.set(interestStruct.publisherPublicKeyDigest);
   
   exclude_.set(interestStruct.exclude);
 	childSelector_ = interestStruct.childSelector;
@@ -62,13 +59,7 @@
   name_.get(interestStruct.name);
   interestStruct.minSuffixComponents = minSuffixComponents_;
   interestStruct.maxSuffixComponents = maxSuffixComponents_;
-  
-  interestStruct.publisherPublicKeyDigestLength = publisherPublicKeyDigest_.size();
-  if (publisherPublicKeyDigest_.size() > 0)
-    interestStruct.publisherPublicKeyDigest = (unsigned char *)&publisherPublicKeyDigest_[0];
-  else
-    interestStruct.publisherPublicKeyDigest = 0;
-  
+  publisherPublicKeyDigest_.get(interestStruct.publisherPublicKeyDigest);
   exclude_.get(interestStruct.exclude);
   interestStruct.childSelector = childSelector_;
   interestStruct.answerOriginKind = answerOriginKind_;
diff --git a/ndn-cpp/Interest.hpp b/ndn-cpp/Interest.hpp
index 23f7d1f..2c6ee3e 100644
--- a/ndn-cpp/Interest.hpp
+++ b/ndn-cpp/Interest.hpp
@@ -8,10 +8,14 @@
 
 #include <vector>
 #include "Name.hpp"
+#include "PublisherPublicKeyDigest.hpp"
 #include "c/Interest.h"
 
 namespace ndn {
   
+/**
+ * An ExcludeEntry holds an ndn_ExcludeType, and if it is a COMPONENT, it holds the component value.
+ */
 class ExcludeEntry {
 public:
   /**
@@ -33,7 +37,7 @@
   /**
    * Set the type in the excludeEntryStruct and to point to this component, without copying any memory.
    * WARNING: The resulting pointer in excludeEntryStruct is invalid after a further use of this object which could reallocate memory.
-   * @param excludeEntryStruct the C ndn_NameComponent struct to receive the pointer.
+   * @param excludeEntryStruct the C ndn_NameComponent struct to receive the pointer
    */
   void get(struct ndn_ExcludeEntry &excludeEntryStruct) const 
   {
@@ -53,6 +57,9 @@
   std::vector<unsigned char> component_; /**< only used if type_ is ndn_Exclude_COMPONENT */
 }; 
   
+/**
+ * An Exclude holds a vector of ExcludeEntry.
+ */
 class Exclude {
 public:
   /**
@@ -68,14 +75,14 @@
   const ExcludeEntry &getEntry(unsigned int i) const { return entries_[i]; }
   
   /**
-   * Set the excludeStruct to point to the entries in this exclude, without copying any memory.
+   * Set the excludeStruct to point to the entries in this Exclude, without copying any memory.
    * WARNING: The resulting pointers in excludeStruct are invalid after a further use of this object which could reallocate memory.
-   * @param excludeStruct a C ndn_Exclude struct where the entries array is already allocated.
+   * @param excludeStruct a C ndn_Exclude struct where the entries array is already allocated
    */
   void get(struct ndn_Exclude &excludeStruct) const;
   
   /**
-   * Clear this exclude, and set the entries by copying from the ndn_Exclude struct.
+   * Clear this Exclude, and set the entries by copying from the ndn_Exclude struct.
    * @param excludeStruct a C ndn_Exclude struct
    */
   void set(struct ndn_Exclude &excludeStruct);
@@ -107,6 +114,9 @@
 	std::vector<ExcludeEntry> entries_;
 };
 
+/**
+ * An Interest holds a Name and other fields for an interest.
+ */
 class Interest {
 public:    
   void encode(std::vector<unsigned char> &output, WireFormat &wireFormat) const 
@@ -148,7 +158,8 @@
   
   int getMaxSuffixComponents() const { return maxSuffixComponents_; }
   
-  const std::vector<unsigned char> getPublisherPublicKeyDigest() const { return publisherPublicKeyDigest_; }
+  PublisherPublicKeyDigest &getPublisherPublicKeyDigest() { return publisherPublicKeyDigest_; }
+  const PublisherPublicKeyDigest &getPublisherPublicKeyDigest() const { return publisherPublicKeyDigest_; }
 
   Exclude &getExclude() { return exclude_; }
   const Exclude &getExclude() const { return exclude_; }
@@ -173,8 +184,6 @@
   
   void setMaxSuffixComponents(int value) { maxSuffixComponents_ = value; }
   
-  void setPublisherPublicKeyDigest(const std::vector<unsigned char> &value) { publisherPublicKeyDigest_ = value; }
-
   void setChildSelector(int value) { childSelector_ = value; }
 
   void setAnswerOriginKind(int value) { answerOriginKind_ = value; }
@@ -190,7 +199,7 @@
   Name name_;
 	int minSuffixComponents_;
 	int maxSuffixComponents_;	
-	std::vector<unsigned char> publisherPublicKeyDigest_;
+	PublisherPublicKeyDigest publisherPublicKeyDigest_;
   Exclude exclude_;
 	int childSelector_;
 	int answerOriginKind_;
diff --git a/ndn-cpp/PublisherPublicKeyDigest.hpp b/ndn-cpp/PublisherPublicKeyDigest.hpp
new file mode 100644
index 0000000..5ce4124
--- /dev/null
+++ b/ndn-cpp/PublisherPublicKeyDigest.hpp
@@ -0,0 +1,58 @@
+/**
+ * @author: Jeff Thompson
+ * See COPYING for copyright and distribution information.
+ */
+
+#ifndef NDN_PUBLISHERPUBLICKEYDIGEST_HPP
+#define	NDN_PUBLISHERPUBLICKEYDIGEST_HPP
+
+#include <vector>
+#include "c/PublisherPublicKeyDigest.h"
+
+namespace ndn {
+  
+/**
+ * A PublisherPublicKeyDigest holds the publisher public key digest value, if any.
+ * We make a separate class since this is used by multiple other classes.
+ */
+class PublisherPublicKeyDigest {
+public:    
+  PublisherPublicKeyDigest() {
+  }
+  
+  /**
+   * Set the publisherPublicKeyDigestStruct to point to the entries in this PublisherPublicKeyDigest, without copying any memory.
+   * WARNING: The resulting pointers in publisherPublicKeyDigestStruct are invalid after a further use of this object which could reallocate memory.
+   * @param publisherPublicKeyDigestStruct a C ndn_PublisherPublicKeyDigest struct to receive the pointer
+   */
+  void get(struct ndn_PublisherPublicKeyDigest &publisherPublicKeyDigestStruct) const 
+  {
+    publisherPublicKeyDigestStruct.publisherPublicKeyDigestLength = publisherPublicKeyDigest_.size();
+    if (publisherPublicKeyDigest_.size() > 0)
+      publisherPublicKeyDigestStruct.publisherPublicKeyDigest = (unsigned char *)&publisherPublicKeyDigest_[0];
+    else
+      publisherPublicKeyDigestStruct.publisherPublicKeyDigest = 0;
+  }
+  
+  /**
+   * Clear this PublisherPublicKeyDigest, and copy from the ndn_PublisherPublicKeyDigest struct.
+   * @param excludeStruct a C ndn_Exclude struct
+   */
+  void set(struct ndn_PublisherPublicKeyDigest &publisherPublicKeyDigestStruct) 
+  {
+  	publisherPublicKeyDigest_.clear();
+    if (publisherPublicKeyDigestStruct.publisherPublicKeyDigest)
+      publisherPublicKeyDigest_.insert
+        (publisherPublicKeyDigest_.begin(), publisherPublicKeyDigestStruct.publisherPublicKeyDigest, 
+         publisherPublicKeyDigestStruct.publisherPublicKeyDigest + publisherPublicKeyDigestStruct.publisherPublicKeyDigestLength);
+  }
+
+  const std::vector<unsigned char> &getPublisherPublicKeyDigest() const { return publisherPublicKeyDigest_; }
+
+private:
+	std::vector<unsigned char> publisherPublicKeyDigest_;
+};
+  
+}
+
+#endif
diff --git a/ndn-cpp/c/Interest.h b/ndn-cpp/c/Interest.h
index 81d9bce..76af56d 100644
--- a/ndn-cpp/c/Interest.h
+++ b/ndn-cpp/c/Interest.h
@@ -7,6 +7,7 @@
 #define	NDN_INTEREST_H
 
 #include "Name.h"
+#include "PublisherPublicKeyDigest.h"
 
 #ifdef	__cplusplus
 extern "C" {
@@ -72,12 +73,14 @@
   ndn_Interest_DEFAULT_ANSWER_ORIGIN_KIND = ndn_Interest_ANSWER_CONTENT_STORE | ndn_Interest_ANSWER_GENERATED
 };
 
+/**
+ * An ndn_Interest holds an ndn_Name and other fields for an interest.
+ */
 struct ndn_Interest {
   struct ndn_Name name;
 	int minSuffixComponents;  /**< -1 for none */
 	int maxSuffixComponents;  /**< -1 for none */
-	unsigned char *publisherPublicKeyDigest;      /**< pointer to pre-allocated buffer.  0 for none */
-  unsigned int publisherPublicKeyDigestLength; /**< length of publisherPublicKeyDigest.  0 for none */
+  struct ndn_PublisherPublicKeyDigest publisherPublicKeyDigest;
 	struct ndn_Exclude exclude;
 	int childSelector;        /**< -1 for none */
 	int answerOriginKind;     /**< -1 for none */
@@ -103,8 +106,7 @@
   ndn_Name_init(&self->name, nameComponents, maxNameComponents);
 	self->minSuffixComponents = -1;
   self->maxSuffixComponents = -1;
-	self->publisherPublicKeyDigest = 0;
-	self->publisherPublicKeyDigestLength = 0;
+  ndn_PublisherPublicKeyDigest_init(&self->publisherPublicKeyDigest);
   ndn_Exclude_init(&self->exclude, excludeEntries, maxExcludeEntries);
 	self->childSelector = -1;
 	self->answerOriginKind = -1;
diff --git a/ndn-cpp/c/PublisherPublicKeyDigest.h b/ndn-cpp/c/PublisherPublicKeyDigest.h
new file mode 100644
index 0000000..57b85f2
--- /dev/null
+++ b/ndn-cpp/c/PublisherPublicKeyDigest.h
@@ -0,0 +1,35 @@
+/**
+ * @author: Jeff Thompson
+ * See COPYING for copyright and distribution information.
+ */
+
+#ifndef NDN_PUBLISHERPUBLICKEYDIGEST_H
+#define	NDN_PUBLISHERPUBLICKEYDIGEST_H
+
+#ifdef	__cplusplus
+extern "C" {
+#endif
+
+/**
+ * A PublisherPublicKeyDigest holds a pointer to the publisher public key digest value, if any.
+ * We make a separate struct since this is used by multiple other structs.
+ */
+struct ndn_PublisherPublicKeyDigest {
+	unsigned char *publisherPublicKeyDigest;      /**< pointer to pre-allocated buffer.  0 for none */
+  unsigned int publisherPublicKeyDigestLength;  /**< length of publisherPublicKeyDigest.  0 for none */  
+};
+
+/**
+ * Initialize an ndn_PublisherPublicKeyDigest struct with 0 for none.
+ */
+static inline void ndn_PublisherPublicKeyDigest_init(struct ndn_PublisherPublicKeyDigest *self)
+{
+  self->publisherPublicKeyDigest = 0;
+  self->publisherPublicKeyDigestLength = 0;
+}
+
+#ifdef	__cplusplus
+}
+#endif
+
+#endif
diff --git a/ndn-cpp/c/encoding/BinaryXMLInterest.c b/ndn-cpp/c/encoding/BinaryXMLInterest.c
index 270e13b..c7e4177 100644
--- a/ndn-cpp/c/encoding/BinaryXMLInterest.c
+++ b/ndn-cpp/c/encoding/BinaryXMLInterest.c
@@ -7,6 +7,7 @@
 #include "BinaryXMLEncoder.h"
 #include "BinaryXMLDecoder.h"
 #include "BinaryXMLName.h"
+#include "BinaryXMLPublisherPublicKeyDigest.h"
 #include "BinaryXMLInterest.h"
 
 static ndn_Error encodeExclude(struct ndn_Exclude *exclude, struct ndn_BinaryXMLEncoder *encoder)
@@ -138,13 +139,11 @@
       return error;
   }
     
-  if (interest->publisherPublicKeyDigest && interest->publisherPublicKeyDigestLength > 0) {
-    if (error = ndn_BinaryXMLEncoder_writeBlobDTagElement
-        (encoder, ndn_BinaryXML_DTag_PublisherPublicKeyDigest, interest->publisherPublicKeyDigest, interest->publisherPublicKeyDigestLength))
-      return error;
-  }
+  // This will skip encoding if there is no publisherPublicKeyDigest.
+  if (error = ndn_encodeBinaryXMLPublisherPublicKeyDigest(&interest->publisherPublicKeyDigest, encoder))
+    return error;
   
-  // This will check for no exclude.
+  // This will skip encoding if there is no exclude.
   if (error = encodeExclude(&interest->exclude, encoder))
     return error;
 
@@ -208,14 +207,12 @@
   if (error = ndn_BinaryXMLDecoder_peekDTag(decoder, ndn_BinaryXML_DTag_PublisherPublicKeyDigest, &gotExpectedTag))
     return error;
   if (gotExpectedTag) {
-    if (error = ndn_BinaryXMLDecoder_readBinaryDTagElement
-        (decoder, ndn_BinaryXML_DTag_PublisherPublicKeyDigest, 0, &interest->publisherPublicKeyDigest,
-         &interest->publisherPublicKeyDigestLength))
+    if (error = ndn_decodeBinaryXMLPublisherPublicKeyDigest(&interest->publisherPublicKeyDigest, decoder))
       return error;
   }
   else {
-    interest->publisherPublicKeyDigest = 0;
-    interest->publisherPublicKeyDigestLength = 0;
+    interest->publisherPublicKeyDigest.publisherPublicKeyDigest = 0;
+    interest->publisherPublicKeyDigest.publisherPublicKeyDigestLength = 0;
   }
   
   if (error = ndn_BinaryXMLDecoder_peekDTag(decoder, ndn_BinaryXML_DTag_Exclude, &gotExpectedTag))
diff --git a/ndn-cpp/c/encoding/BinaryXMLInterest.h b/ndn-cpp/c/encoding/BinaryXMLInterest.h
index 38917aa..9a58b78 100644
--- a/ndn-cpp/c/encoding/BinaryXMLInterest.h
+++ b/ndn-cpp/c/encoding/BinaryXMLInterest.h
@@ -8,6 +8,8 @@
 
 #include "../errors.h"
 #include "../Interest.h"
+#include "BinaryXMLEncoder.h"
+#include "BinaryXMLDecoder.h"
 
 #ifdef	__cplusplus
 extern "C" {
diff --git a/ndn-cpp/c/encoding/BinaryXMLPublisherPublicKeyDigest.c b/ndn-cpp/c/encoding/BinaryXMLPublisherPublicKeyDigest.c
new file mode 100644
index 0000000..b1ee3f8
--- /dev/null
+++ b/ndn-cpp/c/encoding/BinaryXMLPublisherPublicKeyDigest.c
@@ -0,0 +1,35 @@
+/**
+ * @author: Jeff Thompson
+ * Derived from PublisherPublicKeyDigest.js by Meki Cheraoui.
+ * See COPYING for copyright and distribution information.
+ */
+
+#include "BinaryXML.h"
+#include "BinaryXMLPublisherPublicKeyDigest.h"
+
+ndn_Error ndn_encodeBinaryXMLPublisherPublicKeyDigest
+  (struct ndn_PublisherPublicKeyDigest *publisherPublicKeyDigest, struct ndn_BinaryXMLEncoder *encoder)
+{  
+  if (!publisherPublicKeyDigest->publisherPublicKeyDigest || publisherPublicKeyDigest->publisherPublicKeyDigestLength == 0)
+    return;
+  
+  ndn_Error error;
+  if (error = ndn_BinaryXMLEncoder_writeBlobDTagElement
+      (encoder, ndn_BinaryXML_DTag_PublisherPublicKeyDigest, publisherPublicKeyDigest->publisherPublicKeyDigest, 
+       publisherPublicKeyDigest->publisherPublicKeyDigestLength))
+    return error;
+  
+  return 0;
+}
+
+ndn_Error ndn_decodeBinaryXMLPublisherPublicKeyDigest
+  (struct ndn_PublisherPublicKeyDigest *publisherPublicKeyDigest, struct ndn_BinaryXMLDecoder *decoder)
+{
+  ndn_Error error; 
+  if (error = ndn_BinaryXMLDecoder_readBinaryDTagElement
+      (decoder, ndn_BinaryXML_DTag_PublisherPublicKeyDigest, 0, &publisherPublicKeyDigest->publisherPublicKeyDigest,
+       &publisherPublicKeyDigest->publisherPublicKeyDigestLength))
+    return error;
+  
+  return 0;
+}
diff --git a/ndn-cpp/c/encoding/BinaryXMLPublisherPublicKeyDigest.h b/ndn-cpp/c/encoding/BinaryXMLPublisherPublicKeyDigest.h
new file mode 100644
index 0000000..430395c
--- /dev/null
+++ b/ndn-cpp/c/encoding/BinaryXMLPublisherPublicKeyDigest.h
@@ -0,0 +1,41 @@
+/**
+ * @author: Jeff Thompson
+ * See COPYING for copyright and distribution information.
+ */
+
+#ifndef NDN_BINARYXMLPUBLISHERPUBLICKEYDIGEST_H
+#define	NDN_BINARYXMLPUBLISHERPUBLICKEYDIGEST_H
+
+#include "../errors.h"
+#include "../PublisherPublicKeyDigest.h"
+#include "BinaryXMLEncoder.h"
+#include "BinaryXMLDecoder.h"
+
+#ifdef	__cplusplus
+extern "C" {
+#endif
+
+/**
+ * Encode the ndn_PublisherPublicKeyDigest struct using Binary XML.  If publisherPublicKeyDigest->publisherPublicKeyDigest or
+ * publisherPublicKeyDigestLength is 0, then do nothing. 
+ * @param publisherPublicKeyDigest pointer to the ndn_PublisherPublicKeyDigest struct
+ * @param encoder pointer to the ndn_BinaryXMLEncoder struct
+ * @return 0 for success, else an error code
+ */
+ndn_Error ndn_encodeBinaryXMLPublisherPublicKeyDigest
+  (struct ndn_PublisherPublicKeyDigest *publisherPublicKeyDigest, struct ndn_BinaryXMLEncoder *encoder);
+
+/**
+ * Expect the next element to be a Binary XML PublisherPublicKeyDigest and decode into the ndn_PublisherPublicKeyDigest struct.
+ * @param publisherPublicKeyDigest pointer to the ndn_PublisherPublicKeyDigest struct
+ * @param decoder pointer to the ndn_BinaryXMLDecoder struct
+ * @return 0 for success, else an error code, including if the next element is not PublisherPublicKeyDigest.
+ */
+ndn_Error ndn_decodeBinaryXMLPublisherPublicKeyDigest
+  (struct ndn_PublisherPublicKeyDigest *publisherPublicKeyDigest, struct ndn_BinaryXMLDecoder *decoder);
+
+#ifdef	__cplusplus
+}
+#endif
+
+#endif
diff --git a/test/test-encode-decode-interest.cpp b/test/test-encode-decode-interest.cpp
index a6a3325..6c13d87 100644
--- a/test/test-encode-decode-interest.cpp
+++ b/test/test-encode-decode-interest.cpp
@@ -40,6 +40,7 @@
     interest.decode(Interest1, sizeof(Interest1));
     cout << "Interest name " << interest.getName().to_uri() << endl;
     cout << "Interest minSuffixComponents " << interest.getMinSuffixComponents() << endl;
+    cout << "Interest publisherPublicKeyDigest length " << interest.getPublisherPublicKeyDigest().getPublisherPublicKeyDigest().size() << endl;
     cout << "Interest excludeEntryCount " << interest.getExclude().getEntryCount() << endl;
     cout << "InterestLifetime " << interest.getInterestLifetime() << endl;
     
@@ -51,6 +52,7 @@
     reDecodedInterest.decode(encoding);
     cout << "Re-decoded Interest name " << reDecodedInterest.getName().to_uri() << endl;
     cout << "Re-decoded Interest minSuffixComponents " << reDecodedInterest.getMinSuffixComponents() << endl;
+    cout << "Re-decoded Interest publisherPublicKeyDigest length " << reDecodedInterest.getPublisherPublicKeyDigest().getPublisherPublicKeyDigest().size() << endl;
     cout << "Re-decoded Interest excludeEntryCount " << reDecodedInterest.getExclude().getEntryCount() << endl;
     cout << "Re-decoded InterestLifetime " << reDecodedInterest.getInterestLifetime() << endl;
   } catch (exception &e) {