From 63b5018c7dedfc60825697710c9a2f202904a040 Mon Sep 17 00:00:00 2001 From: Chawye Hsu Date: Wed, 31 Mar 2021 01:10:32 +0800 Subject: [PATCH 1/2] fix: use C99 standard types instead of certain Unix types Signed-off-by: Chawye Hsu --- rmd160/rmd160.c | 48 ++++++++++++++++++++++++------------------------ rmd160/rmd160.h | 7 ++++--- 2 files changed, 28 insertions(+), 27 deletions(-) diff --git a/rmd160/rmd160.c b/rmd160/rmd160.c index ad257f0..6fd7f5f 100644 --- a/rmd160/rmd160.c +++ b/rmd160/rmd160.c @@ -92,7 +92,7 @@ initializes MDbuffer to "magic constants" */ static void -RMDinit (u_int32_t * MDbuf) +RMDinit (uint32_t * MDbuf) { MDbuf[0] = 0x67452301UL; MDbuf[1] = 0xefcdab89UL; @@ -107,11 +107,11 @@ RMDinit (u_int32_t * MDbuf) transforms MDbuf using message bytes X[0] through X[15] */ static void -RMDcompress (u_int32_t * MDbuf, u_int32_t * X) +RMDcompress (uint32_t * MDbuf, uint32_t * X) { - u_int32_t aa = MDbuf[0], bb = MDbuf[1], cc = MDbuf[2], + uint32_t aa = MDbuf[0], bb = MDbuf[1], cc = MDbuf[2], dd = MDbuf[3], ee = MDbuf[4]; - u_int32_t aaa = MDbuf[0], bbb = MDbuf[1], ccc = MDbuf[2], + uint32_t aaa = MDbuf[0], bbb = MDbuf[1], ccc = MDbuf[2], ddd = MDbuf[3], eee = MDbuf[4]; @@ -312,29 +312,29 @@ RMDcompress (u_int32_t * MDbuf, u_int32_t * X) note: there are (lswlen mod 64) bytes left in strptr. */ static void -RMDFinish (u_int32_t * MDbuf, u_int8_t * strptr, u_int32_t lswlen, - u_int32_t mswlen) +RMDFinish (uint32_t * MDbuf, uint8_t * strptr, uint32_t lswlen, + uint32_t mswlen) { - u_int32_t i; /* counter */ - u_int32_t X[16]; /* message words */ + uint32_t i; /* counter */ + uint32_t X[16]; /* message words */ - memset (X, 0, 16 * sizeof (u_int32_t)); + memset (X, 0, 16 * sizeof (uint32_t)); /* put bytes from strptr into X */ for (i = 0; i < (lswlen & 63); i++) { /* byte i goes into word X[i div 4] at pos. 8*(i mod 4) */ - X[i >> 2] ^= (u_int32_t) * strptr++ << (8 * (i & 3)); + X[i >> 2] ^= (uint32_t) * strptr++ << (8 * (i & 3)); } /* append the bit m_n == 1 */ - X[(lswlen >> 2) & 15] ^= (u_int32_t) 1 << (8 * (lswlen & 3) + 7); + X[(lswlen >> 2) & 15] ^= (uint32_t) 1 << (8 * (lswlen & 3) + 7); if ((lswlen & 63) > 55) { /* length goes to next block */ RMDcompress (MDbuf, X); - memset (X, 0, 16 * sizeof (u_int32_t)); + memset (X, 0, 16 * sizeof (uint32_t)); } /* append length in bits */ @@ -348,11 +348,11 @@ RMDFinish (u_int32_t * MDbuf, u_int8_t * strptr, u_int32_t lswlen, RIPEMD-160 spec (which follows MD4 conventions). */ static void -rmd160ByteSwap (u_int32_t * dest, u_int8_t const *src, unsigned int words) +rmd160ByteSwap (uint32_t * dest, uint8_t const *src, unsigned int words) { do { - *dest++ = (u_int32_t) ((unsigned) src[3] << 8 | src[2]) << 16 | + *dest++ = (uint32_t) ((unsigned) src[3] << 8 | src[2]) << 16 | ((unsigned) src[1] << 8 | src[0]); src += 4; } @@ -382,7 +382,7 @@ void RMD160Update(RMD160_CTX *ctx, const unsigned char *buf, unsigned int len) unsigned i; /* Update bitcount */ - u_int32_t t = ctx->bytesLo; + uint32_t t = ctx->bytesLo; if ((ctx->bytesLo = t + len) < t) ctx->bytesHi++; /* Carry from low to high */ @@ -391,14 +391,14 @@ void RMD160Update(RMD160_CTX *ctx, const unsigned char *buf, unsigned int len) /* i is always less than RIPEMD160_BLOCKBYTES. */ if (RIPEMD160_BLOCKBYTES - i > len) { - memcpy ((u_int8_t *) ctx->key + i, buf, len); + memcpy ((uint8_t *) ctx->key + i, buf, len); return; } if (i) { /* First chunk is an odd size */ - memcpy ((u_int8_t *) ctx->key + i, buf, RIPEMD160_BLOCKBYTES - i); - rmd160ByteSwap (ctx->key, (u_int8_t *) ctx->key, RIPEMD160_BLOCKWORDS); + memcpy ((uint8_t *) ctx->key + i, buf, RIPEMD160_BLOCKBYTES - i); + rmd160ByteSwap (ctx->key, (uint8_t *) ctx->key, RIPEMD160_BLOCKWORDS); RMDcompress (ctx->iv, ctx->key); buf += RIPEMD160_BLOCKBYTES - i; len -= RIPEMD160_BLOCKBYTES - i; @@ -426,17 +426,17 @@ void RMD160Final (unsigned char digest[20], RMD160_CTX * ctx) { int i; - u_int32_t t; + uint32_t t; - RMDFinish (ctx->iv, (u_int8_t *) ctx->key, ctx->bytesLo, ctx->bytesHi); + RMDFinish (ctx->iv, (uint8_t *) ctx->key, ctx->bytesLo, ctx->bytesHi); for (i = 0; i < RIPEMD160_HASHWORDS; i++) { t = ctx->iv[i]; - digest[i * 4 + 0] = (u_int8_t) t; - digest[i * 4 + 1] = (u_int8_t) (t >> 8); - digest[i * 4 + 2] = (u_int8_t) (t >> 16); - digest[i * 4 + 3] = (u_int8_t) (t >> 24); + digest[i * 4 + 0] = (uint8_t) t; + digest[i * 4 + 1] = (uint8_t) (t >> 8); + digest[i * 4 + 2] = (uint8_t) (t >> 16); + digest[i * 4 + 3] = (uint8_t) (t >> 24); } memset (ctx, 0, sizeof (RMD160_CTX)); /* In case it's sensitive */ diff --git a/rmd160/rmd160.h b/rmd160/rmd160.h index 7980015..225470e 100644 --- a/rmd160/rmd160.h +++ b/rmd160/rmd160.h @@ -3,6 +3,7 @@ #ifndef _RMD160_H_ #define _RMD160_H_ +#include #include #define RMD160_BLOCKBYTES 64 @@ -20,9 +21,9 @@ /* RIPEMD160 context. */ typedef struct RMD160Context { - u_int32_t key[RIPEMD160_BLOCKWORDS]; - u_int32_t iv[RIPEMD160_HASHWORDS]; - u_int32_t bytesHi, bytesLo; + uint32_t key[RIPEMD160_BLOCKWORDS]; + uint32_t iv[RIPEMD160_HASHWORDS]; + uint32_t bytesHi, bytesLo; } RMD160_CTX; #define RIPEMD160Context RMD160Context From 92289ece61b5ad3ea0b0d50f0a9bf06efbfaf686 Mon Sep 17 00:00:00 2001 From: Chawye Hsu Date: Wed, 31 Mar 2021 01:11:53 +0800 Subject: [PATCH 2/2] fix: fix missing Sleep function on Windows and fix type warning Signed-off-by: Chawye Hsu --- keyhunt.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/keyhunt.c b/keyhunt.c index 2661a2d..9b68227 100644 --- a/keyhunt.c +++ b/keyhunt.c @@ -20,6 +20,9 @@ email: alberto.bsd@gmail.com #include "custombloom/bloom.h" #include "sha3/sha3.h" #include "util.h" +#ifdef WIN32 + #include +#endif #define CRYPTO_NONE 0 #define CRYPTO_BTC 1 @@ -1458,7 +1461,7 @@ char *pubkeytopubaddress_eth(char *pkey,int length) { char *pubkeytopubaddress(char *pkey,int length) { char *pubaddress = calloc(MAXLENGTHADDRESS+10,1); char *digest = calloc(60,1); - long unsigned int pubaddress_size = MAXLENGTHADDRESS+10; + size_t pubaddress_size = MAXLENGTHADDRESS+10; if(pubaddress == NULL || digest == NULL) { fprintf(stderr,"error malloc()\n"); exit(0);