1 /* $OpenBSD: crypto_api.c,v 1.1 2014/01/08 03:59:46 tedu Exp $ */ 2 /* 3 * Public domain. Author: Ted Unangst <tedu@openbsd.org> 4 * API compatible reimplementation of functions from nacl 5 */ 6 #include <sys/types.h> 7 8 #include <string.h> 9 #include <sha2.h> 10 11 #include "crypto_api.h" 12 13 int 14 crypto_hash_sha512(unsigned char *out, const unsigned char *in, 15 unsigned long long inlen) 16 { 17 SHA2_CTX ctx; 18 19 SHA512Init(&ctx); 20 SHA512Update(&ctx, in, inlen); 21 SHA512Final(out, &ctx); 22 return 0; 23 } 24 25 int 26 crypto_verify_32(const unsigned char *x, const unsigned char *y) 27 { 28 return timingsafe_bcmp(x, y, 32) ? -1 : 0; 29 } 30