Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
10 changes: 5 additions & 5 deletions sph/haval.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@
* ==========================(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
* without limitation the rights to use, copy, modify, merge, publish,
* 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.
Expand Down Expand Up @@ -634,7 +634,7 @@ haval_init(sph_haval_context *sc, unsigned olen, unsigned passes)
sc->count_high = 0;
sc->count_low = 0;
#endif

}

/*
Expand Down Expand Up @@ -980,4 +980,4 @@ sph_haval_5_comp(const sph_u32 msg[32], sph_u32 val[8])

#ifdef __cplusplus
}
#endif
#endif
31 changes: 18 additions & 13 deletions x21s.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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';
Expand Down