From 0b6b94e6b6152f15cf4c2247c5974f539aae28cd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 10 Apr 2024 21:49:46 +0200 Subject: Adding upstream version 1:9.6p1. Signed-off-by: Daniel Baumann --- hash.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 hash.c (limited to 'hash.c') diff --git a/hash.c b/hash.c new file mode 100644 index 0000000..b4f8f6c --- /dev/null +++ b/hash.c @@ -0,0 +1,43 @@ +/* $OpenBSD: hash.c,v 1.6 2019/11/29 00:11:21 djm Exp $ */ +/* + * Public domain. Author: Christian Weisgerber + * API compatible reimplementation of function from nacl + */ + +#include "includes.h" + +#include "crypto_api.h" + +#include + +#ifdef WITH_OPENSSL +#include + +int +crypto_hash_sha512(unsigned char *out, const unsigned char *in, + unsigned long long inlen) +{ + + if (!EVP_Digest(in, inlen, out, NULL, EVP_sha512(), NULL)) + return -1; + return 0; +} + +#else +# ifdef HAVE_SHA2_H +# include +# endif + +int +crypto_hash_sha512(unsigned char *out, const unsigned char *in, + unsigned long long inlen) +{ + + SHA2_CTX ctx; + + SHA512Init(&ctx); + SHA512Update(&ctx, in, inlen); + SHA512Final(out, &ctx); + return 0; +} +#endif /* WITH_OPENSSL */ -- cgit v1.2.3