security: add support for SHA-3
Requires openssl >= 1.1.1-pre1
Change-Id: I8d91ca30425129694f3b0fc40daa891b58ded065
diff --git a/src/security/detail/openssl-helper.cpp b/src/security/detail/openssl-helper.cpp
index 92ec501..b5c9e5e 100644
--- a/src/security/detail/openssl-helper.cpp
+++ b/src/security/detail/openssl-helper.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2017 Regents of the University of California.
+ * Copyright (c) 2013-2018 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -43,6 +43,16 @@
case DigestAlgorithm::BLAKE2S_256:
return EVP_blake2s256();
#endif
+#if OPENSSL_VERSION_NUMBER >= 0x10101001L
+ case DigestAlgorithm::SHA3_224:
+ return EVP_sha3_224();
+ case DigestAlgorithm::SHA3_256:
+ return EVP_sha3_256();
+ case DigestAlgorithm::SHA3_384:
+ return EVP_sha3_384();
+ case DigestAlgorithm::SHA3_512:
+ return EVP_sha3_512();
+#endif
default:
return nullptr;
}
diff --git a/src/security/detail/openssl.hpp b/src/security/detail/openssl.hpp
index 99d20cb..252d370 100644
--- a/src/security/detail/openssl.hpp
+++ b/src/security/detail/openssl.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2017 Regents of the University of California.
+ * Copyright (c) 2013-2018 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -33,7 +33,6 @@
#include <openssl/ec.h>
#include <openssl/err.h>
#include <openssl/evp.h>
-#include <openssl/hmac.h>
#include <openssl/pem.h>
#include <openssl/rand.h>
#include <openssl/rsa.h>
diff --git a/src/security/security-common.cpp b/src/security/security-common.cpp
index 5e5fa31..1d0d4f2 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-2017 Regents of the University of California.
+ * Copyright (c) 2013-2018 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -89,6 +89,14 @@
return os << "BLAKE2b-512";
case DigestAlgorithm::BLAKE2S_256:
return os << "BLAKE2s-256";
+ case DigestAlgorithm::SHA3_224:
+ return os << "SHA3-224";
+ case DigestAlgorithm::SHA3_256:
+ return os << "SHA3-256";
+ case DigestAlgorithm::SHA3_384:
+ return os << "SHA3-384";
+ case DigestAlgorithm::SHA3_512:
+ return os << "SHA3-512";
}
return os << static_cast<int>(algorithm);
}
diff --git a/src/security/security-common.hpp b/src/security/security-common.hpp
index 9685dc3..c2fa8f4 100644
--- a/src/security/security-common.hpp
+++ b/src/security/security-common.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2017 Regents of the University of California.
+ * Copyright (c) 2013-2018 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -110,6 +110,10 @@
SHA512 = 4,
BLAKE2B_512 = 10,
BLAKE2S_256 = 11,
+ SHA3_224 = 20,
+ SHA3_256 = 21,
+ SHA3_384 = 22,
+ SHA3_512 = 23,
};
std::ostream&