security: support more SHA2 hash functions

Change-Id: Ibbe4f02054ae9028899e8408c331ae8e704df9b8
diff --git a/src/security/detail/openssl-helper.cpp b/src/security/detail/openssl-helper.cpp
index 865bc36..83e0ec9 100644
--- a/src/security/detail/openssl-helper.cpp
+++ b/src/security/detail/openssl-helper.cpp
@@ -29,8 +29,14 @@
 digestAlgorithmToEvpMd(DigestAlgorithm algo)
 {
   switch (algo) {
+  case DigestAlgorithm::SHA224:
+    return EVP_sha224();
   case DigestAlgorithm::SHA256:
     return EVP_sha256();
+  case DigestAlgorithm::SHA384:
+    return EVP_sha384();
+  case DigestAlgorithm::SHA512:
+    return EVP_sha512();
   default:
     return nullptr;
   }
diff --git a/src/security/security-common.cpp b/src/security/security-common.cpp
index cda5fc5..5cfe551 100644
--- a/src/security/security-common.cpp
+++ b/src/security/security-common.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2013-2016 Regents of the University of California.
+/*
+ * Copyright (c) 2013-2017 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -20,6 +20,7 @@
  */
 
 #include "security-common.hpp"
+
 #include <ostream>
 
 namespace ndn {
@@ -50,7 +51,7 @@
       return os << "EC";
     case KeyType::AES:
       return os << "AES";
-  };
+  }
   return os << static_cast<int>(keyType);
 }
 
@@ -66,7 +67,7 @@
       return os << "PRIVATE";
     case KeyClass::SYMMETRIC:
       return os << "SYMMETRIC";
-  };
+  }
   return os << static_cast<int>(keyClass);
 }
 
@@ -76,9 +77,15 @@
   switch (algorithm) {
     case DigestAlgorithm::NONE:
       return os << "NONE";
+    case DigestAlgorithm::SHA224:
+      return os << "SHA224";
     case DigestAlgorithm::SHA256:
       return os << "SHA256";
-  };
+    case DigestAlgorithm::SHA384:
+      return os << "SHA384";
+    case DigestAlgorithm::SHA512:
+      return os << "SHA512";
+  }
   return os << static_cast<int>(algorithm);
 }
 
@@ -90,7 +97,7 @@
       return os << "NONE";
     case BlockCipherAlgorithm::AES_CBC:
       return os << "AES_CBC";
-  };
+  }
   return os << static_cast<int>(algorithm);
 }
 
@@ -102,7 +109,7 @@
       return os << "DECRYPT";
     case CipherOperator::ENCRYPT:
       return os << "ENCRYPT";
-  };
+  }
   return os << static_cast<int>(op);
 }
 
@@ -116,7 +123,7 @@
       return os << "PUBLIC";
     case AclType::PRIVATE:
       return os << "PRIVATE";
-  };
+  }
   return os << static_cast<int>(aclType);
 }
 
diff --git a/src/security/security-common.hpp b/src/security/security-common.hpp
index 2a0a4c8..5df2c13 100644
--- a/src/security/security-common.hpp
+++ b/src/security/security-common.hpp
@@ -104,7 +104,10 @@
 
 enum class DigestAlgorithm {
   NONE   = 0,
+  SHA224 = 2,
   SHA256 = 1,
+  SHA384 = 3,
+  SHA512 = 4,
 };
 
 std::ostream&
diff --git a/src/security/tpm/back-end-osx.cpp b/src/security/tpm/back-end-osx.cpp
index 53c2295..145ffeb 100644
--- a/src/security/tpm/back-end-osx.cpp
+++ b/src/security/tpm/back-end-osx.cpp
@@ -1,5 +1,5 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
  * Copyright (c) 2013-2017 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
@@ -100,7 +100,10 @@
 getDigestAlgorithm(DigestAlgorithm digestAlgo)
 {
   switch (digestAlgo) {
+  case DigestAlgorithm::SHA224:
   case DigestAlgorithm::SHA256:
+  case DigestAlgorithm::SHA384:
+  case DigestAlgorithm::SHA512:
     return kSecDigestSHA2;
   default:
     return 0;
@@ -111,15 +114,21 @@
 getDigestSize(DigestAlgorithm digestAlgo)
 {
   switch (digestAlgo) {
+  case DigestAlgorithm::SHA224:
+    return 224;
   case DigestAlgorithm::SHA256:
     return 256;
+  case DigestAlgorithm::SHA384:
+    return 384;
+  case DigestAlgorithm::SHA512:
+    return 512;
   default:
     return -1;
   }
 }
 
 BackEndOsx::BackEndOsx(const std::string&)
-  : m_impl(new Impl)
+  : m_impl(make_unique<Impl>())
 {
   SecKeychainSetUserInteractionAllowed(!m_impl->isTerminalMode);
 
diff --git a/src/security/tpm/key-handle-mem.cpp b/src/security/tpm/key-handle-mem.cpp
index 00f5b21..d9b5c32 100644
--- a/src/security/tpm/key-handle-mem.cpp
+++ b/src/security/tpm/key-handle-mem.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2013-2016 Regents of the University of California.
+/*
+ * Copyright (c) 2013-2017 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -20,9 +20,9 @@
  */
 
 #include "key-handle-mem.hpp"
-#include "../../encoding/buffer-stream.hpp"
 #include "../transform.hpp"
 #include "../transform/private-key.hpp"
+#include "../../encoding/buffer-stream.hpp"
 
 namespace ndn {
 namespace security {
@@ -39,17 +39,11 @@
 ConstBufferPtr
 KeyHandleMem::doSign(DigestAlgorithm digestAlgorithm, const uint8_t* buf, size_t size) const
 {
-  switch (digestAlgorithm) {
-    case DigestAlgorithm::SHA256: {
-      using namespace transform;
+  using namespace transform;
 
-      OBufferStream sigOs;
-      bufferSource(buf, size) >> signerFilter(digestAlgorithm, *m_key) >> streamSink(sigOs);
-      return sigOs.buf();
-    }
-    default:
-      return nullptr;
-  }
+  OBufferStream sigOs;
+  bufferSource(buf, size) >> signerFilter(digestAlgorithm, *m_key) >> streamSink(sigOs);
+  return sigOs.buf();
 }
 
 ConstBufferPtr