diff --git a/binding.gyp b/binding.gyp index d3295da..00cfc40 100644 --- a/binding.gyp +++ b/binding.gyp @@ -47,16 +47,19 @@ "sha3/sph_whirlpool.c", "sha3/sph_shabal.c", "sha3/hamsi.c", - "sha3/sha2.c", - "sha3/sph_sha2big.c", + "sha3/sha2.c", + "sha3/sph_sha2big.c", "whirlpoolx.c", "x11.c", "x11ghost.c", "x13.c", "x14.c", "x15.c", - "x16r.c", - "x21s.c", + "x16r.c", + "sph/haval.c", + "sph/tiger.c", + "sph/gost_streebog.c", + "x21s.c", "zr5.c", "crypto/oaes_lib.c", "crypto/c_keccak.c", diff --git a/sph/haval.c b/sph/haval.c index f9a8918..6630489 100644 --- a/sph/haval.c +++ b/sph/haval.c @@ -11,7 +11,7 @@ * ==========================(LICENSE BEGIN)============================ * * Copyright (c) 2007-2010 Projet RNRT SAPHIR - * + * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including @@ -19,10 +19,10 @@ * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: - * + * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. @@ -634,7 +634,7 @@ haval_init(sph_haval_context *sc, unsigned olen, unsigned passes) sc->count_high = 0; sc->count_low = 0; #endif - + } /* @@ -980,4 +980,4 @@ sph_haval_5_comp(const sph_u32 msg[32], sph_u32 val[8]) #ifdef __cplusplus } -#endif +#endif diff --git a/x21s.c b/x21s.c index 3896b5a..15fe103 100644 --- a/x21s.c +++ b/x21s.c @@ -47,18 +47,21 @@ static void getAlgoString(const uint8_t* prevblock, char *output) { strcpy(output, "0123456789ABCDEF"); - for(int i = 0; i < 16; i++){ - uint8_t b = (15 - i) >> 1; // 16 ascii hex chars, reversed - uint8_t algoDigit = (i & 1) ? prevblock[b] & 0xF : prevblock[b] >> 4; - - int offset = algoDigit; - // insert the nth character at the front - char oldVal = output[offset]; - for(int j=offset; j-->0;) { - output[j+1] = output[j]; - } - output[0] = oldVal; - } + int i; + + for (i = 0; i < 16; i++){ + uint8_t b = (15 - i) >> 1; // 16 ascii hex chars, reversed + uint8_t algoDigit = (i & 1) ? prevblock[b] & 0xF : prevblock[b] >> 4; + + int offset = algoDigit; + // insert the nth character at the front + char oldVal = output[offset]; + int j; + for (j = offset; j-->0;) { + output[j+1] = output[j]; + } + output[0] = oldVal; + } } void x21s_hash(const char* input, char* output, uint32_t len) { @@ -91,7 +94,9 @@ void x21s_hash(const char* input, char* output, uint32_t len) { getAlgoString(&input[4], hashOrder); - for (int i = 0; i < 16; i++) + int i; + + for (i = 0; i < 16; i++) { const char elem = hashOrder[i]; const uint8_t algo = elem >= 'A' ? elem - 'A' + 10 : elem - '0';