@@ -199,6 +199,19 @@ static int blake2b_init_param(hash_state *md, const unsigned char *P)
199199 return CRYPT_OK ;
200200}
201201
202+ /**
203+ Initialize the hash/MAC state
204+
205+ Use this function to init for arbitrary sizes.
206+
207+ Give a key and keylen to init for MAC mode.
208+
209+ @param md The hash state you wish to initialize
210+ @param outlen The desired output-length
211+ @param key The key of the MAC
212+ @param keylen The length of the key
213+ @return CRYPT_OK if successful
214+ */
202215int blake2b_init (hash_state * md , unsigned long outlen , const unsigned char * key , unsigned long keylen )
203216{
204217 unsigned char P [BLAKE2B_PARAM_SIZE ];
@@ -237,12 +250,32 @@ int blake2b_init(hash_state *md, unsigned long outlen, const unsigned char *key,
237250 return CRYPT_OK ;
238251}
239252
253+ /**
254+ Initialize the hash state
255+ @param md The hash state you wish to initialize
256+ @return CRYPT_OK if successful
257+ */
240258int blake2b_160_init (hash_state * md ) { return blake2b_init (md , 20 , NULL , 0 ); }
241259
260+ /**
261+ Initialize the hash state
262+ @param md The hash state you wish to initialize
263+ @return CRYPT_OK if successful
264+ */
242265int blake2b_256_init (hash_state * md ) { return blake2b_init (md , 32 , NULL , 0 ); }
243266
267+ /**
268+ Initialize the hash state
269+ @param md The hash state you wish to initialize
270+ @return CRYPT_OK if successful
271+ */
244272int blake2b_384_init (hash_state * md ) { return blake2b_init (md , 48 , NULL , 0 ); }
245273
274+ /**
275+ Initialize the hash state
276+ @param md The hash state you wish to initialize
277+ @return CRYPT_OK if successful
278+ */
246279int blake2b_512_init (hash_state * md ) { return blake2b_init (md , 64 , NULL , 0 ); }
247280
248281#define G (r , i , a , b , c , d ) \
@@ -328,6 +361,13 @@ static int blake2b_compress(hash_state *md, const unsigned char *buf)
328361}
329362#endif
330363
364+ /**
365+ Process a block of memory through the hash
366+ @param md The hash state
367+ @param in The data to hash
368+ @param inlen The length of the data (octets)
369+ @return CRYPT_OK if successful
370+ */
331371int blake2b_process (hash_state * md , const unsigned char * in , unsigned long inlen )
332372{
333373 LTC_ARGCHK (md != NULL );
@@ -360,6 +400,12 @@ int blake2b_process(hash_state *md, const unsigned char *in, unsigned long inlen
360400 return CRYPT_OK ;
361401}
362402
403+ /**
404+ Terminate the hash to get the digest
405+ @param md The hash state
406+ @param out [out] The destination of the hash (size depending on the length used on init)
407+ @return CRYPT_OK if successful
408+ */
363409int blake2b_done (hash_state * md , unsigned char * out )
364410{
365411 unsigned char buffer [BLAKE2B_OUTBYTES ] = { 0 };
0 commit comments