diff options
author | Cem Keylan <cem@ckyln.com> | 2020-10-16 17:47:01 +0300 |
---|---|---|
committer | Cem Keylan <cem@ckyln.com> | 2020-10-16 17:47:01 +0300 |
commit | 5d69c6a2661bba0a22f3ecfd517e2e9767a38346 (patch) | |
tree | 1f479b2714e127835db7f33a3bfed4c38c52f883 /usr.bin/signify/crypto_api.c | |
parent | e2abcdca396661cbe0ae2ddb13d5c2b85682c13a (diff) | |
download | otools-5d69c6a2661bba0a22f3ecfd517e2e9767a38346.tar.gz |
add tools
Diffstat (limited to 'usr.bin/signify/crypto_api.c')
-rw-r--r-- | usr.bin/signify/crypto_api.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/usr.bin/signify/crypto_api.c b/usr.bin/signify/crypto_api.c new file mode 100644 index 0000000..d9d8791 --- /dev/null +++ b/usr.bin/signify/crypto_api.c @@ -0,0 +1,30 @@ +/* $OpenBSD: crypto_api.c,v 1.1 2014/01/08 03:59:46 tedu Exp $ */ +/* + * Public domain. Author: Ted Unangst <tedu@openbsd.org> + * API compatible reimplementation of functions from nacl + */ +#include <sys/cdefs.h> +#include <sys/types.h> + +#include <string.h> +#include <sha2.h> + +#include "crypto_api.h" + +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; +} + +int +crypto_verify_32(const unsigned char *x, const unsigned char *y) +{ + return timingsafe_bcmp(x, y, 32) ? -1 : 0; +} |