1 /*
2    BLAKE2 reference source code package - optimized C implementations
3 
4    Written in 2012 by Samuel Neves <sneves@dei.uc.pt>
5 
6    To the extent possible under law, the author(s) have dedicated all copyright
7    and related and neighboring rights to this software to the public domain
8    worldwide. This software is distributed without any warranty.
9 
10    You should have received a copy of the CC0 Public Domain Dedication along with
11    this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
12 */
13 #include <stdio.h>
14 #include <string.h>
15 #include "blake2.h"
16 #include "blake2-kat.h"
main(int argc,char ** argv)17 int main( int argc, char **argv )
18 {
19   uint8_t key[BLAKE2B_KEYBYTES];
20   uint8_t buf[KAT_LENGTH];
21 
22   for( size_t i = 0; i < BLAKE2B_KEYBYTES; ++i )
23     key[i] = ( uint8_t )i;
24 
25   for( size_t i = 0; i < KAT_LENGTH; ++i )
26     buf[i] = ( uint8_t )i;
27 
28   for( size_t i = 0; i < KAT_LENGTH; ++i )
29   {
30     uint8_t hash[BLAKE2B_OUTBYTES];
31 
32     if( blake2b( hash, buf, key, BLAKE2B_OUTBYTES, i, BLAKE2B_KEYBYTES ) < 0 ||
33         0 != memcmp( hash, blake2b_keyed_kat[i], BLAKE2B_OUTBYTES ) )
34     {
35       puts( "error" );
36       return -1;
37     }
38   }
39 
40   puts( "ok" );
41   return 0;
42 }
43 
44