Fix compiler warnings & scrypt hashing with variable length

master
Lucas Jones 2014-04-19 20:15:34 +01:00
parent a3bfc4415e
commit 1190307989
9 changed files with 14 additions and 20 deletions

View File

@ -17,7 +17,6 @@ void groestl_hash(const char* input, char* output, uint32_t len)
sph_groestl512(&ctx_groestl, input, len);
sph_groestl512_close(&ctx_groestl, hash1);
sph_groestl512_init(&ctx_groestl);
sph_groestl512(&ctx_groestl, hash1, 64);
sph_groestl512_close(&ctx_groestl, hash2);
@ -39,7 +38,7 @@ void groestl_myriad_hash(const char* input, char* output, uint32_t len)
SHA256_CTX ctx_sha256;
SHA256_Init(&ctx_sha256);
SHA256_Update(&ctx_sha256, temp, 64);
SHA256_Final(output, &ctx_sha256);
SHA256_Final((unsigned char*) output, &ctx_sha256);
free(temp);
}

View File

@ -114,7 +114,6 @@ void quark_hash(const char* input, char* output, uint32_t len)
sph_jh512_context ctx_jh;
sph_keccak512_context ctx_keccak;
sph_skein512_context ctx_skein;
static unsigned char pblank[1];
uint32_t mask = 8;
uint32_t zero = 0;

View File

@ -223,7 +223,7 @@ smix(uint8_t * B, size_t r, uint64_t N, uint32_t * V, uint32_t * XY)
/* cpu and memory intensive function to transform a 80 byte buffer into a 32 byte output
scratchpad size needs to be at least 63 + (128 * r * p) + (256 * r + 64) + (128 * r * N) bytes
*/
void scrypt_1024_1_1_256_sp(const char* input, char* output, char* scratchpad, size_t len)
void scrypt_1024_1_1_256_sp(const char* input, char* output, char* scratchpad, uint32_t len)
{
uint8_t * B;
uint32_t * V;
@ -248,10 +248,10 @@ void scrypt_1024_1_1_256_sp(const char* input, char* output, char* scratchpad, s
}
/* 5: DK <-- PBKDF2(P, B, 1, dkLen) */
PBKDF2_SHA256((const uint8_t*)input, 80, B, p * 128 * r, 1, (uint8_t*)output, 32);
PBKDF2_SHA256((const uint8_t*)input, len, B, p * 128 * r, 1, (uint8_t*)output, 32);
}
void scrypt_1024_1_1_256(const char* input, char* output, size_t len)
void scrypt_1024_1_1_256(const char* input, char* output, uint32_t len)
{
char scratchpad[131583];
scrypt_1024_1_1_256_sp(input, output, scratchpad, len);

View File

@ -1,10 +1,10 @@
#ifndef SCRYPT_H
#define SCRYPT_H
#include <stddef.h>
#include <stdint.h>
void scrypt_1024_1_1_256(const char* input, char* output, size_t len);
void scrypt_1024_1_1_256_sp(const char* input, char* output, char* scratchpad, size_t len);
void scrypt_1024_1_1_256(const char* input, char* output, uint32_t len);
void scrypt_1024_1_1_256_sp(const char* input, char* output, char* scratchpad, uint32_t len);
#define scrypt_scratchpad_size 131583;
#endif

View File

@ -217,7 +217,7 @@ smix(uint8_t * B, size_t r, uint64_t N, uint32_t * V, uint32_t * XY)
/* cpu and memory intensive function to transform a 80 byte buffer into a 32 byte output
scratchpad size needs to be at least 63 + (128 * r * p) + (256 * r + 64) + (128 * r * N) bytes
*/
void scrypt_N_1_1_256_sp(const char* input, char* output, char* scratchpad, uint32_t N, size_t len)
void scrypt_N_1_1_256_sp(const char* input, char* output, char* scratchpad, uint32_t N, uint32_t len)
{
uint8_t * B;
uint32_t * V;
@ -242,10 +242,10 @@ void scrypt_N_1_1_256_sp(const char* input, char* output, char* scratchpad, uint
}
/* 5: DK <-- PBKDF2(P, B, 1, dkLen) */
PBKDF2_SHA256((const uint8_t*)input, 80, B, p * 128 * r, 1, (uint8_t*)output, 32);
PBKDF2_SHA256((const uint8_t*)input, len, B, p * 128 * r, 1, (uint8_t*)output, 32);
}
void scrypt_N_1_1_256(const char* input, char* output, uint32_t N, size_t len)
void scrypt_N_1_1_256(const char* input, char* output, uint32_t N, uint32_t len)
{
//char scratchpad[131583];
char *scratchpad;

View File

@ -5,8 +5,8 @@
extern "C" {
#endif
void scrypt_N_1_1_256(const char* input, char* output, uint32_t N, size_t len);
void scrypt_N_1_1_256_sp(const char* input, char* output, char* scratchpad, uint32_t N, size_t len);
void scrypt_N_1_1_256(const char* input, char* output, uint32_t N, uint32_t len);
void scrypt_N_1_1_256_sp(const char* input, char* output, char* scratchpad, uint32_t N, uint32_t len);
//const int scrypt_scratchpad_size = 131583;
#ifdef __cplusplus

View File

@ -437,4 +437,4 @@ PBKDF2_SHA256(const uint8_t * passwd, size_t passwdlen, const uint8_t * salt,
/* Clean PShctx, since we never called _Final on it. */
memset(&PShctx, 0, sizeof(HMAC_SHA256_CTX));
}
#endif
#endif

View File

@ -2813,7 +2813,6 @@ static void
groestl_small_close(sph_groestl_small_context *sc,
unsigned ub, unsigned n, void *dst, size_t out_len)
{
unsigned char *buf;
unsigned char pad[72];
size_t u, ptr, pad_len;
#if SPH_64
@ -2824,7 +2823,6 @@ groestl_small_close(sph_groestl_small_context *sc,
unsigned z;
DECL_STATE_SMALL
buf = sc->buf;
ptr = sc->ptr;
z = 0x80 >> n;
pad[0] = ((ub & -z) | z) & 0xFF;
@ -2949,7 +2947,6 @@ static void
groestl_big_close(sph_groestl_big_context *sc,
unsigned ub, unsigned n, void *dst, size_t out_len)
{
unsigned char *buf;
unsigned char pad[136];
size_t ptr, pad_len, u;
#if SPH_64
@ -2960,7 +2957,6 @@ groestl_big_close(sph_groestl_big_context *sc,
unsigned z;
DECL_STATE_BIG
buf = sc->buf;
ptr = sc->ptr;
z = 0x80 >> n;
pad[0] = ((ub & -z) | z) & 0xFF;

View File

@ -21,7 +21,7 @@ void skein_hash(const char* input, char* output, uint32_t len)
SHA256_CTX ctx_sha256;
SHA256_Init(&ctx_sha256);
SHA256_Update(&ctx_sha256, temp, 64);
SHA256_Final(output, &ctx_sha256);
SHA256_Final((unsigned char*) output, &ctx_sha256);
free(temp);
}