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"
17 
main(int argc,char ** argv)18 int main( int argc, char **argv )
19 {
20   uint8_t key[BLAKE2S_KEYBYTES];
21   uint8_t buf[KAT_LENGTH];
22 
23   for( size_t i = 0; i < BLAKE2S_KEYBYTES; ++i )
24     key[i] = ( uint8_t )i;
25 
26   for( size_t i = 0; i < KAT_LENGTH; ++i )
27     buf[i] = ( uint8_t )i;
28 
29   for( size_t i = 0; i < KAT_LENGTH; ++i )
30   {
31     uint8_t hash[BLAKE2S_OUTBYTES];
32     if( blake2sp( hash, buf, key, BLAKE2S_OUTBYTES, i, BLAKE2S_KEYBYTES ) < 0 ||
33         0 != memcmp( hash, blake2sp_keyed_kat[i], BLAKE2S_OUTBYTES ) )
34     {
35       puts( "error" );
36       return -1;
37     }
38   }
39 
40   puts( "ok" );
41   return 0;
42 }
43 
44