Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/BLAKE2/BLAKE2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Neves <sneves@dei.uc.pt>2016-10-12 17:19:55 +0300
committerSamuel Neves <sneves@dei.uc.pt>2016-10-12 17:19:55 +0300
commitc19dd2bd835ae98d8f40e7d712042476b4ad1ccf (patch)
tree53fd914ee1bce5f324ee6083162221a4d9a9e522 /sse/genkat-json.c
parent7a39ee4736dce7d9ded9cd4b0eaea7a7fe18d721 (diff)
formatting, more c89
Diffstat (limited to 'sse/genkat-json.c')
-rw-r--r--sse/genkat-json.c228
1 files changed, 112 insertions, 116 deletions
diff --git a/sse/genkat-json.c b/sse/genkat-json.c
index d8c4a17..6d6b341 100644
--- a/sse/genkat-json.c
+++ b/sse/genkat-json.c
@@ -1,14 +1,14 @@
/*
BLAKE2 reference source code package - reference C implementations
-
+
Copyright 2012, Samuel Neves <sneves@dei.uc.pt>. You may use this under the
terms of the CC0, the OpenSSL Licence, or the Apache Public License 2.0, at
your option. The terms of these licenses can be found at:
-
+
- CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0
- OpenSSL license : https://www.openssl.org/source/license.html
- Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0
-
+
More information about the BLAKE2 hash function can be found at
https://blake2.net.
*/
@@ -25,133 +25,129 @@
#define LENGTH 256
-#define MAKE_KAT(name,size_prefix) \
-do \
-{ \
- for( i = 0; i < LENGTH; ++i ) \
- { \
- printf("\n{\n");\
- \
- printf(" \"hash\": \"" #name "\",\n");\
- printf(" \"in\": \"");\
- for( j = 0; j < i; ++j ) printf( "%02x", in[j]);\
- \
- printf( "\",\n" ); \
- printf(" \"key\": \"\",\n");\
- printf(" \"out\": \"");\
- \
- name( hash, size_prefix ## _OUTBYTES, in, i, NULL, 0 ); \
- \
- for( j = 0; j < size_prefix ## _OUTBYTES; ++j ) \
- printf( "%02x", hash[j]);\
- printf( "\"\n" ); \
- printf( "}," ); \
- }\
-} while (0)
-
-#define MAKE_KEYED_KAT(name,size_prefix) \
-do \
-{ \
- for( i = 0; i < LENGTH; ++i ) \
- { \
- printf("\n{\n");\
- \
- printf(" \"hash\": \"" #name "\",\n");\
- printf(" \"in\": \"");\
- for( j = 0; j < i; ++j ) printf( "%02x", in[j]);\
- \
- printf( "\",\n" ); \
- printf(" \"key\": \"");\
- for( j = 0; j < size_prefix ## _KEYBYTES; ++j ) printf( "%02x", key[j]);\
- printf("\",\n");\
- printf(" \"out\": \"");\
- \
- name( hash, size_prefix ## _OUTBYTES, in, i, key, size_prefix ## _KEYBYTES ); \
- \
- for( j = 0; j < size_prefix ## _OUTBYTES; ++j ) \
- printf( "%02x", hash[j]);\
- printf( "\"\n" ); \
- printf( "}," ); \
- }\
-} while (0)
+#define MAKE_KAT(name, size_prefix) \
+ do { \
+ for (i = 0; i < LENGTH; ++i) { \
+ printf("\n{\n"); \
+ \
+ printf(" \"hash\": \"" #name "\",\n"); \
+ printf(" \"in\": \""); \
+ for (j = 0; j < i; ++j) \
+ printf("%02x", in[j]); \
+ \
+ printf("\",\n"); \
+ printf(" \"key\": \"\",\n"); \
+ printf(" \"out\": \""); \
+ \
+ name(hash, size_prefix##_OUTBYTES, in, i, NULL, 0); \
+ \
+ for (j = 0; j < size_prefix##_OUTBYTES; ++j) \
+ printf("%02x", hash[j]); \
+ printf("\"\n"); \
+ printf("},"); \
+ } \
+ } while (0)
-#define MAKE_XOF_KAT(name) \
-do \
-{ \
- for( i = 1; i <= LENGTH; ++i ) \
- { \
- printf("\n{\n");\
- \
- printf(" \"hash\": \"" #name "\",\n");\
- printf(" \"in\": \"");\
- for( j = 0; j < LENGTH; ++j ) printf( "%02x", in[j]);\
- \
- printf( "\",\n" ); \
- printf(" \"key\": \"\",\n");\
- printf(" \"out\": \"");\
- \
- name( hash, i, in, LENGTH, NULL, 0 ); \
- \
- for( j = 0; j < i; ++j ) \
- printf( "%02x", hash[j]);\
- printf( "\"\n" ); \
- printf( "}," ); \
- }\
-} while (0)
+#define MAKE_KEYED_KAT(name, size_prefix) \
+ do { \
+ for (i = 0; i < LENGTH; ++i) { \
+ printf("\n{\n"); \
+ \
+ printf(" \"hash\": \"" #name "\",\n"); \
+ printf(" \"in\": \""); \
+ for (j = 0; j < i; ++j) \
+ printf("%02x", in[j]); \
+ \
+ printf("\",\n"); \
+ printf(" \"key\": \""); \
+ for (j = 0; j < size_prefix##_KEYBYTES; ++j) \
+ printf("%02x", key[j]); \
+ printf("\",\n"); \
+ printf(" \"out\": \""); \
+ \
+ name(hash, size_prefix##_OUTBYTES, in, i, key, size_prefix##_KEYBYTES); \
+ \
+ for (j = 0; j < size_prefix##_OUTBYTES; ++j) \
+ printf("%02x", hash[j]); \
+ printf("\"\n"); \
+ printf("},"); \
+ } \
+ } while (0)
-#define MAKE_XOF_KEYED_KAT(name,size_prefix) \
-do \
-{ \
- for( i = 1; i <= LENGTH; ++i ) \
- { \
- printf("\n{\n");\
- \
- printf(" \"hash\": \"" #name "\",\n");\
- printf(" \"in\": \"");\
- for( j = 0; j < LENGTH; ++j ) printf( "%02x", in[j]);\
- \
- printf( "\",\n" ); \
- printf(" \"key\": \"");\
- for( j = 0; j < size_prefix ## _KEYBYTES; ++j ) printf( "%02x", key[j]);\
- printf("\",\n");\
- printf(" \"out\": \"");\
- \
- name( hash, i, in, LENGTH, key, size_prefix ## _KEYBYTES ); \
- \
- for( j = 0; j < i; ++j ) \
- printf( "%02x", hash[j]);\
- printf( "\"\n" ); \
- printf( "}," ); \
- }\
-} while (0)
+#define MAKE_XOF_KAT(name) \
+ do { \
+ for (i = 1; i <= LENGTH; ++i) { \
+ printf("\n{\n"); \
+ \
+ printf(" \"hash\": \"" #name "\",\n"); \
+ printf(" \"in\": \""); \
+ for (j = 0; j < LENGTH; ++j) \
+ printf("%02x", in[j]); \
+ \
+ printf("\",\n"); \
+ printf(" \"key\": \"\",\n"); \
+ printf(" \"out\": \""); \
+ \
+ name(hash, i, in, LENGTH, NULL, 0); \
+ \
+ for (j = 0; j < i; ++j) \
+ printf("%02x", hash[j]); \
+ printf("\"\n"); \
+ printf("},"); \
+ } \
+ } while (0)
+#define MAKE_XOF_KEYED_KAT(name, size_prefix) \
+ do { \
+ for (i = 1; i <= LENGTH; ++i) { \
+ printf("\n{\n"); \
+ \
+ printf(" \"hash\": \"" #name "\",\n"); \
+ printf(" \"in\": \""); \
+ for (j = 0; j < LENGTH; ++j) \
+ printf("%02x", in[j]); \
+ \
+ printf("\",\n"); \
+ printf(" \"key\": \""); \
+ for (j = 0; j < size_prefix##_KEYBYTES; ++j) \
+ printf("%02x", key[j]); \
+ printf("\",\n"); \
+ printf(" \"out\": \""); \
+ \
+ name(hash, i, in, LENGTH, key, size_prefix##_KEYBYTES); \
+ \
+ for (j = 0; j < i; ++j) \
+ printf("%02x", hash[j]); \
+ printf("\"\n"); \
+ printf("},"); \
+ } \
+ } while (0)
-int main()
-{
+int main() {
uint8_t key[64] = {0};
uint8_t in[LENGTH] = {0};
uint8_t hash[LENGTH] = {0};
size_t i, j;
- for( i = 0; i < sizeof( in ); ++i )
+ for (i = 0; i < sizeof(in); ++i)
in[i] = i;
- for( i = 0; i < sizeof( key ); ++i )
+ for (i = 0; i < sizeof(key); ++i)
key[i] = i;
printf("[");
- MAKE_KAT( blake2s, BLAKE2S );
- MAKE_KEYED_KAT( blake2s, BLAKE2S );
- MAKE_KAT( blake2b, BLAKE2B );
- MAKE_KEYED_KAT( blake2b, BLAKE2B );
- MAKE_KAT( blake2sp, BLAKE2S );
- MAKE_KEYED_KAT( blake2sp, BLAKE2S );
- MAKE_KAT( blake2bp, BLAKE2B );
- MAKE_KEYED_KAT( blake2bp, BLAKE2B );
- MAKE_XOF_KAT( blake2xs );
- MAKE_XOF_KEYED_KAT( blake2xs, BLAKE2S );
- MAKE_XOF_KAT( blake2xb );
- MAKE_XOF_KEYED_KAT( blake2xb, BLAKE2B );
+ MAKE_KAT(blake2s, BLAKE2S);
+ MAKE_KEYED_KAT(blake2s, BLAKE2S);
+ MAKE_KAT(blake2b, BLAKE2B);
+ MAKE_KEYED_KAT(blake2b, BLAKE2B);
+ MAKE_KAT(blake2sp, BLAKE2S);
+ MAKE_KEYED_KAT(blake2sp, BLAKE2S);
+ MAKE_KAT(blake2bp, BLAKE2B);
+ MAKE_KEYED_KAT(blake2bp, BLAKE2B);
+ MAKE_XOF_KAT(blake2xs);
+ MAKE_XOF_KEYED_KAT(blake2xs, BLAKE2S);
+ MAKE_XOF_KAT(blake2xb);
+ MAKE_XOF_KEYED_KAT(blake2xb, BLAKE2B);
printf("\n]\n");
fflush(stdout);
return 0;