inet6: only mark autoconf addresses tentative if detached
[dragonfly.git] / crypto / openssh / hash.c
blobb4f8f6c50d5e22006abe66c0ffd247a69d219fa6
1 /* $OpenBSD: hash.c,v 1.6 2019/11/29 00:11:21 djm Exp $ */
2 /*
3 * Public domain. Author: Christian Weisgerber <naddy@openbsd.org>
4 * API compatible reimplementation of function from nacl
5 */
7 #include "includes.h"
9 #include "crypto_api.h"
11 #include <stdarg.h>
13 #ifdef WITH_OPENSSL
14 #include <openssl/evp.h>
16 int
17 crypto_hash_sha512(unsigned char *out, const unsigned char *in,
18 unsigned long long inlen)
21 if (!EVP_Digest(in, inlen, out, NULL, EVP_sha512(), NULL))
22 return -1;
23 return 0;
26 #else
27 # ifdef HAVE_SHA2_H
28 # include <sha2.h>
29 # endif
31 int
32 crypto_hash_sha512(unsigned char *out, const unsigned char *in,
33 unsigned long long inlen)
36 SHA2_CTX ctx;
38 SHA512Init(&ctx);
39 SHA512Update(&ctx, in, inlen);
40 SHA512Final(out, &ctx);
41 return 0;
43 #endif /* WITH_OPENSSL */