diff options
Diffstat (limited to 'src/blake2.h')
-rw-r--r-- | src/blake2.h | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/blake2.h b/src/blake2.h new file mode 100644 index 0000000..1693b33 --- /dev/null +++ b/src/blake2.h @@ -0,0 +1,47 @@ +/***********************************************************************/ +/* */ +/* The Cryptokit library */ +/* */ +/* Xavier Leroy, Collège de France and Inria */ +/* */ +/* Copyright 2020 Institut National de Recherche en Informatique et */ +/* en Automatique. All rights reserved. This file is distributed */ +/* under the terms of the GNU Library General Public License, with */ +/* the special exception on linking described in file LICENSE. */ +/* */ +/***********************************************************************/ + +/* BLAKE2b hashing */ + +#define BLAKE2b_BLOCKSIZE 128 + +struct blake2b { + uint64_t h[8]; + uint64_t len[2]; + int numbytes; + unsigned char buffer[BLAKE2b_BLOCKSIZE]; +}; + +extern void blake2b_init(struct blake2b * s, + int hashlen, int keylen, unsigned char * key); +extern void blake2b_add_data(struct blake2b * s, + unsigned char * data, size_t len); +extern void blake2b_final(struct blake2b * s, + int hashlen, unsigned char * hash); + +#define BLAKE2s_BLOCKSIZE 64 + +struct blake2s { + uint32_t h[8]; + uint32_t len[2]; + int numbytes; + unsigned char buffer[BLAKE2s_BLOCKSIZE]; +}; + +extern void blake2s_init(struct blake2s * s, + int hashlen, int keylen, unsigned char * key); +extern void blake2s_add_data(struct blake2s * s, + unsigned char * data, size_t len); +extern void blake2s_final(struct blake2s * s, + int hashlen, unsigned char * hash); + |