summaryrefslogtreecommitdiff
path: root/Modules/_blake2/impl/blake2bp-test.c
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/_blake2/impl/blake2bp-test.c')
-rw-r--r--Modules/_blake2/impl/blake2bp-test.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/Modules/_blake2/impl/blake2bp-test.c b/Modules/_blake2/impl/blake2bp-test.c
new file mode 100644
index 0000000000..849666cc1d
--- /dev/null
+++ b/Modules/_blake2/impl/blake2bp-test.c
@@ -0,0 +1,44 @@
+/*
+ BLAKE2 reference source code package - optimized C implementations
+
+ Written in 2012 by Samuel Neves <sneves@dei.uc.pt>
+
+ To the extent possible under law, the author(s) have dedicated all copyright
+ and related and neighboring rights to this software to the public domain
+ worldwide. This software is distributed without any warranty.
+
+ You should have received a copy of the CC0 Public Domain Dedication along with
+ this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
+*/
+#include <stdio.h>
+#include <string.h>
+#include "blake2.h"
+#include "blake2-kat.h"
+
+int main( int argc, char **argv )
+{
+ uint8_t key[BLAKE2B_KEYBYTES];
+ uint8_t buf[KAT_LENGTH];
+
+ for( size_t i = 0; i < BLAKE2B_KEYBYTES; ++i )
+ key[i] = ( uint8_t )i;
+
+ for( size_t i = 0; i < KAT_LENGTH; ++i )
+ buf[i] = ( uint8_t )i;
+
+ for( size_t i = 0; i < KAT_LENGTH; ++i )
+ {
+ uint8_t hash[BLAKE2B_OUTBYTES];
+
+ if( blake2bp( hash, buf, key, BLAKE2B_OUTBYTES, i, BLAKE2B_KEYBYTES ) < 0 ||
+ 0 != memcmp( hash, blake2bp_keyed_kat[i], BLAKE2B_OUTBYTES ) )
+ {
+ puts( "error" );
+ return -1;
+ }
+ }
+
+ puts( "ok" );
+ return 0;
+}
+