Added C crypto.c for digestSha256
diff --git a/Makefile.am b/Makefile.am
index 53eb83f..10297a0 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -34,6 +34,7 @@
   ndn-cpp/c/transport/socket-transport.c ndn-cpp/c/transport/socket-transport.h \
   ndn-cpp/c/transport/tcp-transport.h \
   ndn-cpp/c/transport/udp-transport.h \
+  ndn-cpp/c/util/crypto.c ndn-cpp/c/util/crypto.h \
   ndn-cpp/c/util/dynamic-uchar-array.c ndn-cpp/c/util/dynamic-uchar-array.h \
   ndn-cpp/c/util/ndn_memory.c ndn-cpp/c/util/ndn_memory.h \
   ndn-cpp/c/util/ndn_realloc.c ndn-cpp/c/util/ndn_realloc.h
diff --git a/Makefile.in b/Makefile.in
index 1944982..f7d87d4 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -143,7 +143,7 @@
 	ndn-cpp/c/encoding/binary-xml-publisher-public-key-digest.lo \
 	ndn-cpp/c/encoding/binary-xml-structure-decoder.lo \
 	ndn-cpp/c/transport/socket-transport.lo \
-	ndn-cpp/c/util/dynamic-uchar-array.lo \
+	ndn-cpp/c/util/crypto.lo ndn-cpp/c/util/dynamic-uchar-array.lo \
 	ndn-cpp/c/util/ndn_memory.lo ndn-cpp/c/util/ndn_realloc.lo
 libndn_c_la_OBJECTS = $(am_libndn_c_la_OBJECTS)
 AM_V_lt = $(am__v_lt_@AM_V@)
@@ -475,6 +475,7 @@
   ndn-cpp/c/transport/socket-transport.c ndn-cpp/c/transport/socket-transport.h \
   ndn-cpp/c/transport/tcp-transport.h \
   ndn-cpp/c/transport/udp-transport.h \
+  ndn-cpp/c/util/crypto.c ndn-cpp/c/util/crypto.h \
   ndn-cpp/c/util/dynamic-uchar-array.c ndn-cpp/c/util/dynamic-uchar-array.h \
   ndn-cpp/c/util/ndn_memory.c ndn-cpp/c/util/ndn_memory.h \
   ndn-cpp/c/util/ndn_realloc.c ndn-cpp/c/util/ndn_realloc.h
@@ -659,6 +660,8 @@
 ndn-cpp/c/util/$(DEPDIR)/$(am__dirstamp):
 	@$(MKDIR_P) ndn-cpp/c/util/$(DEPDIR)
 	@: > ndn-cpp/c/util/$(DEPDIR)/$(am__dirstamp)
+ndn-cpp/c/util/crypto.lo: ndn-cpp/c/util/$(am__dirstamp) \
+	ndn-cpp/c/util/$(DEPDIR)/$(am__dirstamp)
 ndn-cpp/c/util/dynamic-uchar-array.lo: ndn-cpp/c/util/$(am__dirstamp) \
 	ndn-cpp/c/util/$(DEPDIR)/$(am__dirstamp)
 ndn-cpp/c/util/ndn_memory.lo: ndn-cpp/c/util/$(am__dirstamp) \
@@ -848,6 +851,7 @@
 @AMDEP_TRUE@@am__include@ @am__quote@ndn-cpp/c/encoding/$(DEPDIR)/binary-xml-publisher-public-key-digest.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@ndn-cpp/c/encoding/$(DEPDIR)/binary-xml-structure-decoder.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@ndn-cpp/c/transport/$(DEPDIR)/socket-transport.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@ndn-cpp/c/util/$(DEPDIR)/crypto.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@ndn-cpp/c/util/$(DEPDIR)/dynamic-uchar-array.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@ndn-cpp/c/util/$(DEPDIR)/ndn_memory.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@ndn-cpp/c/util/$(DEPDIR)/ndn_realloc.Plo@am__quote@
diff --git a/ndn-cpp/c/util/crypto.c b/ndn-cpp/c/util/crypto.c
new file mode 100644
index 0000000..68af3e4
--- /dev/null
+++ b/ndn-cpp/c/util/crypto.c
@@ -0,0 +1,14 @@
+/**
+ * @author: Jeff Thompson
+ * See COPYING for copyright and distribution information.
+ */
+
+#include "crypto.h"
+
+void ndn_digestSha256(const unsigned char *data, unsigned int dataLength, unsigned char *digest)
+{
+  SHA256_CTX sha256;
+  SHA256_Init(&sha256);
+  SHA256_Update(&sha256, data, dataLength);
+  SHA256_Final(digest, &sha256);
+}
diff --git a/ndn-cpp/c/util/crypto.h b/ndn-cpp/c/util/crypto.h
new file mode 100644
index 0000000..0b6be6b
--- /dev/null
+++ b/ndn-cpp/c/util/crypto.h
@@ -0,0 +1,28 @@
+/**
+ * @author: Jeff Thompson
+ * See COPYING for copyright and distribution information.
+ */
+
+#ifndef NDN_CRYPTO_H
+#define NDN_CRYPTO_H
+
+#include <openssl/ssl.h>
+#include <openssl/rsa.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Compute the sha-256 digest of data.
+ * @param data Pointer to the input byte array.
+ * @param dataLength The length of data.
+ * @param digest A pointer to a buffer of size SHA256_DIGEST_LENGTH to receive the data.
+ */
+void ndn_digestSha256(const unsigned char *data, unsigned int dataLength, unsigned char *digest);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/ndn-cpp/key-chain.cpp b/ndn-cpp/key-chain.cpp
index 1bd3e63..b917405 100644
--- a/ndn-cpp/key-chain.cpp
+++ b/ndn-cpp/key-chain.cpp
@@ -4,8 +4,7 @@
  */
 
 #include <stdexcept>
-#include <openssl/ssl.h>
-#include <openssl/rsa.h>
+#include "c/util/crypto.h"
 #include "c/encoding/binary-xml-data.h"
 #include "encoding/binary-xml-encoder.hpp"
 #include "key-chain.hpp"
@@ -61,29 +60,15 @@
 };
 
 /**
- * Compute the sha-256 digest of data.
- * @param data Pointer to the input byte array.
- * @param dataLength The length of data.
- * @param digest A pointer to a buffer of size SHA256_DIGEST_LENGTH to receive the data.
- */
-static void digestSha256(const unsigned char *data, unsigned int dataLength, unsigned char *digest)
-{
-  SHA256_CTX sha256;
-  SHA256_Init(&sha256);
-  SHA256_Update(&sha256, data, dataLength);
-  SHA256_Final(digest, &sha256);
-}
-
-/**
  * Call digestSha256 and set the digest vector to the result.
  * @param data
  * @param dataLength
  * @param digest
  */
-static void setSha256(const unsigned char *data, unsigned int dataLength, vector<unsigned char> &digest)
+void setSha256(const unsigned char *data, unsigned int dataLength, vector<unsigned char> &digest)
 {
   unsigned char digestBuffer[SHA256_DIGEST_LENGTH];
-  digestSha256(data, dataLength, digestBuffer);
+  ndn_digestSha256(data, dataLength, digestBuffer);
   setVector(digest, digestBuffer, sizeof(digestBuffer));
 }
 
@@ -97,7 +82,7 @@
   unsigned int signedFieldsBeginOffset, signedFieldsEndOffset;
   ptr_lib::shared_ptr<vector<unsigned char> > encoding = wireFormat.encodeData(data, &signedFieldsBeginOffset, &signedFieldsEndOffset);
   
-  digestSha256(&encoding->front() + signedFieldsBeginOffset, signedFieldsEndOffset - signedFieldsBeginOffset, digest);
+  ndn_digestSha256(&encoding->front() + signedFieldsBeginOffset, signedFieldsEndOffset - signedFieldsBeginOffset, digest);
 }
 
 void KeyChain::sign
@@ -152,7 +137,7 @@
     // TODO: Allow a non-default digest algorithm.
     throw std::runtime_error("Cannot verify a data packet with a non-default digest algorithm");
   unsigned char dataFieldsDigest[SHA256_DIGEST_LENGTH];
-  digestSha256(input + signedFieldsBeginOffset, signedFieldsEndOffset - signedFieldsBeginOffset, dataFieldsDigest);
+  ndn_digestSha256(input + signedFieldsBeginOffset, signedFieldsEndOffset - signedFieldsBeginOffset, dataFieldsDigest);
   
   // Find the public key.
   const unsigned char *publicKeyDer;