security: support more SHA2 hash functions
Change-Id: Ibbe4f02054ae9028899e8408c331ae8e704df9b8
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