Commit ff7c3177 authored by Dmytro Stechenko's avatar Dmytro Stechenko Committed by Facebook GitHub Bot

Add ssl sha512/blake2b wrappers

Summary: Adding sha512/blake2b evp wrappers for digest/hmac.

Reviewed By: yfeldblum

Differential Revision: D31220261

fbshipit-source-id: af190fef5d269dda6e7fed549641a6cffb3ce08d
parent eecfd465
......@@ -91,11 +91,13 @@
#define FOLLY_OPENSSL_HAS_ALPN 0
#endif
// OpenSSL 1.1.1 and above have TLS 1.3 support
// OpenSSL 1.1.1 and above have TLS 1.3 and BLAKE2B support
#if OPENSSL_VERSION_NUMBER >= 0x1010100fL
#define FOLLY_OPENSSL_HAS_TLS13 1
#define FOLLY_OPENSSL_HAS_BLAKE2B 1
#else
#define FOLLY_OPENSSL_HAS_TLS13 0
#define FOLLY_OPENSSL_HAS_BLAKE2B 0
#endif
#if FOLLY_OPENSSL_IS_110 && \
......
......@@ -144,6 +144,26 @@ class OpenSSLHash {
static void sha256(MutableByteRange out, const IOBuf& data) {
hash(out, EVP_sha256(), data);
}
static void sha512(MutableByteRange out, ByteRange data) {
hash(out, EVP_sha512(), data);
}
static void sha512(MutableByteRange out, const IOBuf& data) {
hash(out, EVP_sha512(), data);
}
#if FOLLY_OPENSSL_HAS_BLAKE2B
static void blake2s256(MutableByteRange out, ByteRange data) {
hash(out, EVP_blake2s256(), data);
}
static void blake2s256(MutableByteRange out, const IOBuf& data) {
hash(out, EVP_blake2s256(), data);
}
static void blake2b512(MutableByteRange out, ByteRange data) {
hash(out, EVP_blake2b512(), data);
}
static void blake2b512(MutableByteRange out, const IOBuf& data) {
hash(out, EVP_blake2b512(), data);
}
#endif
class Hmac {
public:
......@@ -270,6 +290,31 @@ class OpenSSLHash {
MutableByteRange out, ByteRange key, const IOBuf& data) {
hmac(out, EVP_sha256(), key, data);
}
static void hmac_sha512(MutableByteRange out, ByteRange key, ByteRange data) {
hmac(out, EVP_sha512(), key, data);
}
static void hmac_sha512(
MutableByteRange out, ByteRange key, const IOBuf& data) {
hmac(out, EVP_sha512(), key, data);
}
#if FOLLY_OPENSSL_HAS_BLAKE2B
static void hmac_blake2s256(
MutableByteRange out, ByteRange key, ByteRange data) {
hmac(out, EVP_blake2s256(), key, data);
}
static void hmac_blake2s256(
MutableByteRange out, ByteRange key, const IOBuf& data) {
hmac(out, EVP_blake2s256(), key, data);
}
static void hmac_blake2b512(
MutableByteRange out, ByteRange key, ByteRange data) {
hmac(out, EVP_blake2b512(), key, data);
}
static void hmac_blake2b512(
MutableByteRange out, ByteRange key, const IOBuf& data) {
hmac(out, EVP_blake2b512(), key, data);
}
#endif
private:
static inline void check_out_size(size_t size, MutableByteRange out) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment