summaryrefslogtreecommitdiffstats
path: root/hash.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 11:13:18 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 11:13:18 +0000
commit9e7e4ab6617fef1d1681fc2d3e02554264ccc954 (patch)
tree336445493163aa0370cb7830d97ebd8819b2e2c5 /hash.c
parentInitial commit. (diff)
downloadopenssh-9e7e4ab6617fef1d1681fc2d3e02554264ccc954.tar.xz
openssh-9e7e4ab6617fef1d1681fc2d3e02554264ccc954.zip
Adding upstream version 1:8.4p1.upstream/1%8.4p1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--hash.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/hash.c b/hash.c
new file mode 100644
index 0000000..fb81e47
--- /dev/null
+++ b/hash.c
@@ -0,0 +1,45 @@
+/* $OpenBSD: hash.c,v 1.4 2017/12/14 21:07:39 naddy Exp $ */
+
+/* $OpenBSD: hash.c,v 1.6 2019/11/29 00:11:21 djm Exp $ */
+/*
+ * Public domain. Author: Christian Weisgerber <naddy@openbsd.org>
+ * API compatible reimplementation of function from nacl
+ */
+
+#include "includes.h"
+
+#include "crypto_api.h"
+
+#include <stdarg.h>
+
+#ifdef WITH_OPENSSL
+#include <openssl/evp.h>
+
+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 <sha2.h>
+# 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 */