Fix compiler warnings & scrypt hashing with variable length
parent
a3bfc4415e
commit
1190307989
|
@ -17,7 +17,6 @@ void groestl_hash(const char* input, char* output, uint32_t len)
|
||||||
sph_groestl512(&ctx_groestl, input, len);
|
sph_groestl512(&ctx_groestl, input, len);
|
||||||
sph_groestl512_close(&ctx_groestl, hash1);
|
sph_groestl512_close(&ctx_groestl, hash1);
|
||||||
|
|
||||||
sph_groestl512_init(&ctx_groestl);
|
|
||||||
sph_groestl512(&ctx_groestl, hash1, 64);
|
sph_groestl512(&ctx_groestl, hash1, 64);
|
||||||
sph_groestl512_close(&ctx_groestl, hash2);
|
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_CTX ctx_sha256;
|
||||||
SHA256_Init(&ctx_sha256);
|
SHA256_Init(&ctx_sha256);
|
||||||
SHA256_Update(&ctx_sha256, temp, 64);
|
SHA256_Update(&ctx_sha256, temp, 64);
|
||||||
SHA256_Final(output, &ctx_sha256);
|
SHA256_Final((unsigned char*) output, &ctx_sha256);
|
||||||
|
|
||||||
free(temp);
|
free(temp);
|
||||||
}
|
}
|
||||||
|
|
1
quark.c
1
quark.c
|
@ -114,7 +114,6 @@ void quark_hash(const char* input, char* output, uint32_t len)
|
||||||
sph_jh512_context ctx_jh;
|
sph_jh512_context ctx_jh;
|
||||||
sph_keccak512_context ctx_keccak;
|
sph_keccak512_context ctx_keccak;
|
||||||
sph_skein512_context ctx_skein;
|
sph_skein512_context ctx_skein;
|
||||||
static unsigned char pblank[1];
|
|
||||||
|
|
||||||
uint32_t mask = 8;
|
uint32_t mask = 8;
|
||||||
uint32_t zero = 0;
|
uint32_t zero = 0;
|
||||||
|
|
6
scrypt.c
6
scrypt.c
|
@ -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
|
/* 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
|
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;
|
uint8_t * B;
|
||||||
uint32_t * V;
|
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) */
|
/* 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];
|
char scratchpad[131583];
|
||||||
scrypt_1024_1_1_256_sp(input, output, scratchpad, len);
|
scrypt_1024_1_1_256_sp(input, output, scratchpad, len);
|
||||||
|
|
6
scrypt.h
6
scrypt.h
|
@ -1,10 +1,10 @@
|
||||||
#ifndef SCRYPT_H
|
#ifndef SCRYPT_H
|
||||||
#define 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(const char* input, char* output, uint32_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_sp(const char* input, char* output, char* scratchpad, uint32_t len);
|
||||||
#define scrypt_scratchpad_size 131583;
|
#define scrypt_scratchpad_size 131583;
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -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
|
/* 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
|
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;
|
uint8_t * B;
|
||||||
uint32_t * V;
|
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) */
|
/* 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[131583];
|
||||||
char *scratchpad;
|
char *scratchpad;
|
||||||
|
|
|
@ -5,8 +5,8 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
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);
|
||||||
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);
|
||||||
//const int scrypt_scratchpad_size = 131583;
|
//const int scrypt_scratchpad_size = 131583;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
2
sha256.h
2
sha256.h
|
@ -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. */
|
/* Clean PShctx, since we never called _Final on it. */
|
||||||
memset(&PShctx, 0, sizeof(HMAC_SHA256_CTX));
|
memset(&PShctx, 0, sizeof(HMAC_SHA256_CTX));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -2813,7 +2813,6 @@ static void
|
||||||
groestl_small_close(sph_groestl_small_context *sc,
|
groestl_small_close(sph_groestl_small_context *sc,
|
||||||
unsigned ub, unsigned n, void *dst, size_t out_len)
|
unsigned ub, unsigned n, void *dst, size_t out_len)
|
||||||
{
|
{
|
||||||
unsigned char *buf;
|
|
||||||
unsigned char pad[72];
|
unsigned char pad[72];
|
||||||
size_t u, ptr, pad_len;
|
size_t u, ptr, pad_len;
|
||||||
#if SPH_64
|
#if SPH_64
|
||||||
|
@ -2824,7 +2823,6 @@ groestl_small_close(sph_groestl_small_context *sc,
|
||||||
unsigned z;
|
unsigned z;
|
||||||
DECL_STATE_SMALL
|
DECL_STATE_SMALL
|
||||||
|
|
||||||
buf = sc->buf;
|
|
||||||
ptr = sc->ptr;
|
ptr = sc->ptr;
|
||||||
z = 0x80 >> n;
|
z = 0x80 >> n;
|
||||||
pad[0] = ((ub & -z) | z) & 0xFF;
|
pad[0] = ((ub & -z) | z) & 0xFF;
|
||||||
|
@ -2949,7 +2947,6 @@ static void
|
||||||
groestl_big_close(sph_groestl_big_context *sc,
|
groestl_big_close(sph_groestl_big_context *sc,
|
||||||
unsigned ub, unsigned n, void *dst, size_t out_len)
|
unsigned ub, unsigned n, void *dst, size_t out_len)
|
||||||
{
|
{
|
||||||
unsigned char *buf;
|
|
||||||
unsigned char pad[136];
|
unsigned char pad[136];
|
||||||
size_t ptr, pad_len, u;
|
size_t ptr, pad_len, u;
|
||||||
#if SPH_64
|
#if SPH_64
|
||||||
|
@ -2960,7 +2957,6 @@ groestl_big_close(sph_groestl_big_context *sc,
|
||||||
unsigned z;
|
unsigned z;
|
||||||
DECL_STATE_BIG
|
DECL_STATE_BIG
|
||||||
|
|
||||||
buf = sc->buf;
|
|
||||||
ptr = sc->ptr;
|
ptr = sc->ptr;
|
||||||
z = 0x80 >> n;
|
z = 0x80 >> n;
|
||||||
pad[0] = ((ub & -z) | z) & 0xFF;
|
pad[0] = ((ub & -z) | z) & 0xFF;
|
||||||
|
|
2
skein.c
2
skein.c
|
@ -21,7 +21,7 @@ void skein_hash(const char* input, char* output, uint32_t len)
|
||||||
SHA256_CTX ctx_sha256;
|
SHA256_CTX ctx_sha256;
|
||||||
SHA256_Init(&ctx_sha256);
|
SHA256_Init(&ctx_sha256);
|
||||||
SHA256_Update(&ctx_sha256, temp, 64);
|
SHA256_Update(&ctx_sha256, temp, 64);
|
||||||
SHA256_Final(output, &ctx_sha256);
|
SHA256_Final((unsigned char*) output, &ctx_sha256);
|
||||||
|
|
||||||
free(temp);
|
free(temp);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue