Skip to content

Commit 1190307

Browse files
committed
Fix compiler warnings & scrypt hashing with variable length
1 parent a3bfc44 commit 1190307

File tree

9 files changed

+14
-20
lines changed

9 files changed

+14
-20
lines changed

groestl.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ void groestl_hash(const char* input, char* output, uint32_t len)
1717
sph_groestl512(&ctx_groestl, input, len);
1818
sph_groestl512_close(&ctx_groestl, hash1);
1919

20-
sph_groestl512_init(&ctx_groestl);
2120
sph_groestl512(&ctx_groestl, hash1, 64);
2221
sph_groestl512_close(&ctx_groestl, hash2);
2322

@@ -39,7 +38,7 @@ void groestl_myriad_hash(const char* input, char* output, uint32_t len)
3938
SHA256_CTX ctx_sha256;
4039
SHA256_Init(&ctx_sha256);
4140
SHA256_Update(&ctx_sha256, temp, 64);
42-
SHA256_Final(output, &ctx_sha256);
41+
SHA256_Final((unsigned char*) output, &ctx_sha256);
4342

4443
free(temp);
4544
}

quark.c

-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ void quark_hash(const char* input, char* output, uint32_t len)
114114
sph_jh512_context ctx_jh;
115115
sph_keccak512_context ctx_keccak;
116116
sph_skein512_context ctx_skein;
117-
static unsigned char pblank[1];
118117

119118
uint32_t mask = 8;
120119
uint32_t zero = 0;

scrypt.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ smix(uint8_t * B, size_t r, uint64_t N, uint32_t * V, uint32_t * XY)
223223
/* cpu and memory intensive function to transform a 80 byte buffer into a 32 byte output
224224
scratchpad size needs to be at least 63 + (128 * r * p) + (256 * r + 64) + (128 * r * N) bytes
225225
*/
226-
void scrypt_1024_1_1_256_sp(const char* input, char* output, char* scratchpad, size_t len)
226+
void scrypt_1024_1_1_256_sp(const char* input, char* output, char* scratchpad, uint32_t len)
227227
{
228228
uint8_t * B;
229229
uint32_t * V;
@@ -248,10 +248,10 @@ void scrypt_1024_1_1_256_sp(const char* input, char* output, char* scratchpad, s
248248
}
249249

250250
/* 5: DK <-- PBKDF2(P, B, 1, dkLen) */
251-
PBKDF2_SHA256((const uint8_t*)input, 80, B, p * 128 * r, 1, (uint8_t*)output, 32);
251+
PBKDF2_SHA256((const uint8_t*)input, len, B, p * 128 * r, 1, (uint8_t*)output, 32);
252252
}
253253

254-
void scrypt_1024_1_1_256(const char* input, char* output, size_t len)
254+
void scrypt_1024_1_1_256(const char* input, char* output, uint32_t len)
255255
{
256256
char scratchpad[131583];
257257
scrypt_1024_1_1_256_sp(input, output, scratchpad, len);

scrypt.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#ifndef SCRYPT_H
22
#define SCRYPT_H
33

4-
#include <stddef.h>
4+
#include <stdint.h>
55

6-
void scrypt_1024_1_1_256(const char* input, char* output, size_t len);
7-
void scrypt_1024_1_1_256_sp(const char* input, char* output, char* scratchpad, size_t len);
6+
void scrypt_1024_1_1_256(const char* input, char* output, uint32_t len);
7+
void scrypt_1024_1_1_256_sp(const char* input, char* output, char* scratchpad, uint32_t len);
88
#define scrypt_scratchpad_size 131583;
99

1010
#endif

scryptn.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ smix(uint8_t * B, size_t r, uint64_t N, uint32_t * V, uint32_t * XY)
217217
/* cpu and memory intensive function to transform a 80 byte buffer into a 32 byte output
218218
scratchpad size needs to be at least 63 + (128 * r * p) + (256 * r + 64) + (128 * r * N) bytes
219219
*/
220-
void scrypt_N_1_1_256_sp(const char* input, char* output, char* scratchpad, uint32_t N, size_t len)
220+
void scrypt_N_1_1_256_sp(const char* input, char* output, char* scratchpad, uint32_t N, uint32_t len)
221221
{
222222
uint8_t * B;
223223
uint32_t * V;
@@ -242,10 +242,10 @@ void scrypt_N_1_1_256_sp(const char* input, char* output, char* scratchpad, uint
242242
}
243243

244244
/* 5: DK <-- PBKDF2(P, B, 1, dkLen) */
245-
PBKDF2_SHA256((const uint8_t*)input, 80, B, p * 128 * r, 1, (uint8_t*)output, 32);
245+
PBKDF2_SHA256((const uint8_t*)input, len, B, p * 128 * r, 1, (uint8_t*)output, 32);
246246
}
247247

248-
void scrypt_N_1_1_256(const char* input, char* output, uint32_t N, size_t len)
248+
void scrypt_N_1_1_256(const char* input, char* output, uint32_t N, uint32_t len)
249249
{
250250
//char scratchpad[131583];
251251
char *scratchpad;

scryptn.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
extern "C" {
66
#endif
77

8-
void scrypt_N_1_1_256(const char* input, char* output, uint32_t N, size_t len);
9-
void scrypt_N_1_1_256_sp(const char* input, char* output, char* scratchpad, uint32_t N, size_t len);
8+
void scrypt_N_1_1_256(const char* input, char* output, uint32_t N, uint32_t len);
9+
void scrypt_N_1_1_256_sp(const char* input, char* output, char* scratchpad, uint32_t N, uint32_t len);
1010
//const int scrypt_scratchpad_size = 131583;
1111

1212
#ifdef __cplusplus

sha256.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -437,4 +437,4 @@ PBKDF2_SHA256(const uint8_t * passwd, size_t passwdlen, const uint8_t * salt,
437437
/* Clean PShctx, since we never called _Final on it. */
438438
memset(&PShctx, 0, sizeof(HMAC_SHA256_CTX));
439439
}
440-
#endif
440+
#endif

sha3/sph_groestl.c

-4
Original file line numberDiff line numberDiff line change
@@ -2813,7 +2813,6 @@ static void
28132813
groestl_small_close(sph_groestl_small_context *sc,
28142814
unsigned ub, unsigned n, void *dst, size_t out_len)
28152815
{
2816-
unsigned char *buf;
28172816
unsigned char pad[72];
28182817
size_t u, ptr, pad_len;
28192818
#if SPH_64
@@ -2824,7 +2823,6 @@ groestl_small_close(sph_groestl_small_context *sc,
28242823
unsigned z;
28252824
DECL_STATE_SMALL
28262825

2827-
buf = sc->buf;
28282826
ptr = sc->ptr;
28292827
z = 0x80 >> n;
28302828
pad[0] = ((ub & -z) | z) & 0xFF;
@@ -2949,7 +2947,6 @@ static void
29492947
groestl_big_close(sph_groestl_big_context *sc,
29502948
unsigned ub, unsigned n, void *dst, size_t out_len)
29512949
{
2952-
unsigned char *buf;
29532950
unsigned char pad[136];
29542951
size_t ptr, pad_len, u;
29552952
#if SPH_64
@@ -2960,7 +2957,6 @@ groestl_big_close(sph_groestl_big_context *sc,
29602957
unsigned z;
29612958
DECL_STATE_BIG
29622959

2963-
buf = sc->buf;
29642960
ptr = sc->ptr;
29652961
z = 0x80 >> n;
29662962
pad[0] = ((ub & -z) | z) & 0xFF;

skein.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ void skein_hash(const char* input, char* output, uint32_t len)
2121
SHA256_CTX ctx_sha256;
2222
SHA256_Init(&ctx_sha256);
2323
SHA256_Update(&ctx_sha256, temp, 64);
24-
SHA256_Final(output, &ctx_sha256);
24+
SHA256_Final((unsigned char*) output, &ctx_sha256);
2525

2626
free(temp);
2727
}

0 commit comments

Comments
 (0)