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[BLAKE2B_KEYBYTES];
21 uint8_t buf[KAT_LENGTH];
22
23 for( size_t i = 0; i < BLAKE2B_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[BLAKE2B_OUTBYTES];
32
33 if( blake2bp( hash, buf, key, BLAKE2B_OUTBYTES, i, BLAKE2B_KEYBYTES ) < 0 ||
34 0 != memcmp( hash, blake2bp_keyed_kat[i], BLAKE2B_OUTBYTES ) )
35 {
36 puts( "error" );
37 return -1;
38 }
39 }
40
41 puts( "ok" );
42 return 0;
43 }
44
45