security: add support for BLAKE2 hash function
Requires openssl >= 1.1.0
Change-Id: I680c948d23561cee8cb62eb8bf757e55bf70abca
diff --git a/src/security/detail/openssl-helper.cpp b/src/security/detail/openssl-helper.cpp
index 83e0ec9..92ec501 100644
--- a/src/security/detail/openssl-helper.cpp
+++ b/src/security/detail/openssl-helper.cpp
@@ -37,6 +37,12 @@
return EVP_sha384();
case DigestAlgorithm::SHA512:
return EVP_sha512();
+#if OPENSSL_VERSION_NUMBER >= 0x1010000fL && !defined(OPENSSL_NO_BLAKE2)
+ case DigestAlgorithm::BLAKE2B_512:
+ return EVP_blake2b512();
+ case DigestAlgorithm::BLAKE2S_256:
+ return EVP_blake2s256();
+#endif
default:
return nullptr;
}
@@ -50,7 +56,7 @@
EVP_PKEY_type(key->type);
#else
EVP_PKEY_base_id(key);
-#endif // OPENSSL_VERSION_NUMBER < 0x1010000fL
+#endif
}
EvpMdCtx::EvpMdCtx()
diff --git a/src/security/security-common.cpp b/src/security/security-common.cpp
index 5cfe551..5e5fa31 100644
--- a/src/security/security-common.cpp
+++ b/src/security/security-common.cpp
@@ -85,6 +85,10 @@
return os << "SHA384";
case DigestAlgorithm::SHA512:
return os << "SHA512";
+ case DigestAlgorithm::BLAKE2B_512:
+ return os << "BLAKE2b-512";
+ case DigestAlgorithm::BLAKE2S_256:
+ return os << "BLAKE2s-256";
}
return os << static_cast<int>(algorithm);
}
diff --git a/src/security/security-common.hpp b/src/security/security-common.hpp
index 5df2c13..9685dc3 100644
--- a/src/security/security-common.hpp
+++ b/src/security/security-common.hpp
@@ -108,6 +108,8 @@
SHA256 = 1,
SHA384 = 3,
SHA512 = 4,
+ BLAKE2B_512 = 10,
+ BLAKE2S_256 = 11,
};
std::ostream&