security: rename SignatureSha256 to DigestSha256

Change-Id: Idabb95222d86e2541372593698ed9754156a5df2
diff --git a/src/security/digest-sha256.hpp b/src/security/digest-sha256.hpp
new file mode 100644
index 0000000..19833e1
--- /dev/null
+++ b/src/security/digest-sha256.hpp
@@ -0,0 +1,65 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2013-2014 Regents of the University of California.
+ *
+ * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
+ *
+ * ndn-cxx library is free software: you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ *
+ * You should have received copies of the GNU General Public License and GNU Lesser
+ * General Public License along with ndn-cxx, e.g., in COPYING.md file.  If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
+ */
+
+#ifndef NDN_SECURITY_DIGEST_SHA256_HPP
+#define NDN_SECURITY_DIGEST_SHA256_HPP
+
+#include "../data.hpp"
+#include "../encoding/tlv.hpp"
+
+namespace ndn {
+
+/**
+ * Represent a SHA256 digest.
+ */
+class DigestSha256 : public Signature
+{
+public:
+  class Error : public Signature::Error
+  {
+  public:
+    explicit
+    Error(const std::string& what)
+      : Signature::Error(what)
+    {
+    }
+  };
+
+  DigestSha256()
+  {
+    m_info = Block(Tlv::SignatureInfo);
+
+    m_type = Signature::Sha256;
+    m_info.push_back(nonNegativeIntegerBlock(Tlv::SignatureType, Tlv::DigestSha256));
+  }
+
+  explicit
+  DigestSha256(const Signature& signature)
+    : Signature(signature)
+  {
+    if (getType() != Signature::Sha256)
+      throw Error("Incorrect signature type");
+  }
+};
+
+} // namespace ndn
+
+#endif //NDN_SECURITY_DIGEST_SHA256_HPP
diff --git a/src/security/key-chain.hpp b/src/security/key-chain.hpp
index 00a2e6b..191eeda 100644
--- a/src/security/key-chain.hpp
+++ b/src/security/key-chain.hpp
@@ -28,7 +28,7 @@
 #include "sec-tpm.hpp"
 #include "secured-bag.hpp"
 #include "signature-sha256-with-rsa.hpp"
-#include "signature-sha256.hpp"
+#include "digest-sha256.hpp"
 
 #include "../interest.hpp"
 #include "../util/crypto.hpp"
@@ -808,7 +808,7 @@
 inline void
 KeyChain::signWithSha256(Data& data)
 {
-  SignatureSha256 sig;
+  DigestSha256 sig;
   data.setSignature(sig);
 
   Block sigValue(Tlv::SignatureValue,
diff --git a/src/security/signature-sha256.hpp b/src/security/signature-sha256.hpp
index 28fbc04..e04ba0f 100644
--- a/src/security/signature-sha256.hpp
+++ b/src/security/signature-sha256.hpp
@@ -22,43 +22,9 @@
 #ifndef NDN_SECURITY_SIGNATURE_SHA256_HPP
 #define NDN_SECURITY_SIGNATURE_SHA256_HPP
 
-#include "../data.hpp"
-#include "../encoding/tlv.hpp"
+#include "digest-sha256.hpp"
 
-namespace ndn {
-
-/**
- * Representing of SHA256 signature in a data packet.
- */
-class SignatureSha256 : public Signature
-{
-public:
-  class Error : public Signature::Error
-  {
-  public:
-    explicit
-    Error(const std::string& what)
-      : Signature::Error(what)
-    {
-    }
-  };
-
-  SignatureSha256()
-  {
-    m_info = Block(Tlv::SignatureInfo);
-
-    m_type = Signature::Sha256;
-    m_info.push_back(nonNegativeIntegerBlock(Tlv::SignatureType, Tlv::DigestSha256));
-  }
-
-  SignatureSha256(const Signature& signature)
-    : Signature(signature)
-  {
-    if (getType() != Signature::Sha256)
-      throw Error("Incorrect signature type");
-  }
-};
-
-} // namespace ndn
+///@deprecated
+typedef DigestSha256 SignatureSha256;
 
 #endif //NDN_SECURITY_SIGNATURE_SHA256_HPP
diff --git a/src/security/validator-config.hpp b/src/security/validator-config.hpp
index a55797a..f768efc 100644
--- a/src/security/validator-config.hpp
+++ b/src/security/validator-config.hpp
@@ -268,7 +268,7 @@
 {
   if (signature.getType() == Signature::Sha256)
     {
-      SignatureSha256 sigSha256(signature);
+      DigestSha256 sigSha256(signature);
 
       if (verifySignature(packet, sigSha256))
         return onValidated(packet.shared_from_this());
diff --git a/src/security/validator.cpp b/src/security/validator.cpp
index 4962779..29a4801 100644
--- a/src/security/validator.cpp
+++ b/src/security/validator.cpp
@@ -260,7 +260,7 @@
 }
 
 bool
-Validator::verifySignature(const uint8_t* buf, const size_t size, const SignatureSha256& sig)
+Validator::verifySignature(const uint8_t* buf, const size_t size, const DigestSha256& sig)
 {
   try
     {
diff --git a/src/security/validator.hpp b/src/security/validator.hpp
index 0017102..5d66367 100644
--- a/src/security/validator.hpp
+++ b/src/security/validator.hpp
@@ -31,7 +31,7 @@
 #include "../face.hpp"
 #include "public-key.hpp"
 #include "signature-sha256-with-rsa.hpp"
-#include "signature-sha256.hpp"
+#include "digest-sha256.hpp"
 #include "validation-request.hpp"
 
 namespace ndn {
@@ -157,7 +157,7 @@
 
   /// @brief Verify the data against the SHA256 signature.
   static bool
-  verifySignature(const Data& data, const SignatureSha256& sig)
+  verifySignature(const Data& data, const DigestSha256& sig)
   {
     return verifySignature(data.wireEncode().value(),
                            data.wireEncode().value_size() -
@@ -170,7 +170,7 @@
    * (Note the signature covers the first n-2 name components).
    */
   static bool
-  verifySignature(const Interest& interest, const SignatureSha256& sig)
+  verifySignature(const Interest& interest, const DigestSha256& sig)
   {
     if (interest.getName().size() < 2)
       return false;
@@ -184,14 +184,14 @@
 
   /// @brief Verify the blob against the SHA256 signature.
   static bool
-  verifySignature(const Buffer& blob, const SignatureSha256& sig)
+  verifySignature(const Buffer& blob, const DigestSha256& sig)
   {
     return verifySignature (blob.buf(), blob.size(), sig);
   }
 
   /// @brief Verify the blob against the SHA256 signature.
   static bool
-  verifySignature(const uint8_t* buf, const size_t size, const SignatureSha256& sig);
+  verifySignature(const uint8_t* buf, const size_t size, const DigestSha256& sig);
 
 protected:
   /**
diff --git a/tests/unit-tests/security/test-signature-sha256.cpp b/tests/unit-tests/security/test-digest-sha256.cpp
similarity index 95%
rename from tests/unit-tests/security/test-signature-sha256.cpp
rename to tests/unit-tests/security/test-digest-sha256.cpp
index 7aac44e..94ded5b 100644
--- a/tests/unit-tests/security/test-signature-sha256.cpp
+++ b/tests/unit-tests/security/test-digest-sha256.cpp
@@ -29,7 +29,7 @@
 using namespace std;
 namespace ndn {
 
-BOOST_AUTO_TEST_SUITE(SecurityTestSignatureSha256)
+BOOST_AUTO_TEST_SUITE(SecurityTestDigestSha256)
 
 string SHA256_RESULT("a883dafc480d466ee04e0d6da986bd78eb1fdd2178d04693723da3a8f95d42f4");
 
@@ -61,7 +61,7 @@
 
   testData.wireEncode();
 
-  SignatureSha256 sig(testData.getSignature());
+  DigestSha256 sig(testData.getSignature());
 
   BOOST_REQUIRE(Validator::verifySignature(testData, sig));
 }
diff --git a/tests/unit-tests/test-data.cpp b/tests/unit-tests/test-data.cpp
index f86c2bc..e7be94e 100644
--- a/tests/unit-tests/test-data.cpp
+++ b/tests/unit-tests/test-data.cpp
@@ -232,12 +232,12 @@
   BOOST_CHECK_EQUAL(a == b, true);
   BOOST_CHECK_EQUAL(a != b, false);
 
-  a = SignatureSha256();
+  a = DigestSha256();
   b = SignatureSha256WithRsa();
   BOOST_CHECK_EQUAL(a == b, false);
   BOOST_CHECK_EQUAL(a != b, true);
 
-  b = SignatureSha256();
+  b = DigestSha256();
   BOOST_CHECK_EQUAL(a == b, true);
   BOOST_CHECK_EQUAL(a != b, false);
 }
diff --git a/tests/unit-tests/test-interest.cpp b/tests/unit-tests/test-interest.cpp
index 5bb0a85..f02a8a8 100644
--- a/tests/unit-tests/test-interest.cpp
+++ b/tests/unit-tests/test-interest.cpp
@@ -22,7 +22,7 @@
 #include "interest.hpp"
 #include "data.hpp"
 #include "security/signature-sha256-with-rsa.hpp"
-#include "security/signature-sha256.hpp"
+#include "security/digest-sha256.hpp"
 #include "encoding/buffer-stream.hpp"
 
 #include "boost-test.hpp"
@@ -492,7 +492,7 @@
   interest.setPublisherPublicKeyLocator(KeyLocator("ndn:/B"));
 
   Data data4 = data;
-  SignatureSha256 signature4; // violates PublisherPublicKeyLocator
+  DigestSha256 signature4; // violates PublisherPublicKeyLocator
   data4.setSignature(signature4);
   data4.wireEncode();
   BOOST_CHECK_EQUAL(interest.matchesData(data4), false);