mirror of
https://github.com/albertobsd/keyhunt.git
synced 2025-07-28 12:43:35 +02:00
fix: use C99 standard types instead of certain Unix types
Signed-off-by: Chawye Hsu <chawyehsu@hotmail.com>
This commit is contained in:
@@ -92,7 +92,7 @@
|
|||||||
initializes MDbuffer to "magic constants"
|
initializes MDbuffer to "magic constants"
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
RMDinit (u_int32_t * MDbuf)
|
RMDinit (uint32_t * MDbuf)
|
||||||
{
|
{
|
||||||
MDbuf[0] = 0x67452301UL;
|
MDbuf[0] = 0x67452301UL;
|
||||||
MDbuf[1] = 0xefcdab89UL;
|
MDbuf[1] = 0xefcdab89UL;
|
||||||
@@ -107,11 +107,11 @@ RMDinit (u_int32_t * MDbuf)
|
|||||||
transforms MDbuf using message bytes X[0] through X[15]
|
transforms MDbuf using message bytes X[0] through X[15]
|
||||||
*/
|
*/
|
||||||
static void
|
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];
|
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];
|
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.
|
note: there are (lswlen mod 64) bytes left in strptr.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
RMDFinish (u_int32_t * MDbuf, u_int8_t * strptr, u_int32_t lswlen,
|
RMDFinish (uint32_t * MDbuf, uint8_t * strptr, uint32_t lswlen,
|
||||||
u_int32_t mswlen)
|
uint32_t mswlen)
|
||||||
{
|
{
|
||||||
u_int32_t i; /* counter */
|
uint32_t i; /* counter */
|
||||||
u_int32_t X[16]; /* message words */
|
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 */
|
/* put bytes from strptr into X */
|
||||||
for (i = 0; i < (lswlen & 63); i++)
|
for (i = 0; i < (lswlen & 63); i++)
|
||||||
{
|
{
|
||||||
/* byte i goes into word X[i div 4] at pos. 8*(i mod 4) */
|
/* 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 */
|
/* 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)
|
if ((lswlen & 63) > 55)
|
||||||
{
|
{
|
||||||
/* length goes to next block */
|
/* length goes to next block */
|
||||||
RMDcompress (MDbuf, X);
|
RMDcompress (MDbuf, X);
|
||||||
memset (X, 0, 16 * sizeof (u_int32_t));
|
memset (X, 0, 16 * sizeof (uint32_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* append length in bits */
|
/* 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).
|
RIPEMD-160 spec (which follows MD4 conventions).
|
||||||
*/
|
*/
|
||||||
static void
|
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
|
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]);
|
((unsigned) src[1] << 8 | src[0]);
|
||||||
src += 4;
|
src += 4;
|
||||||
}
|
}
|
||||||
@@ -382,7 +382,7 @@ void RMD160Update(RMD160_CTX *ctx, const unsigned char *buf, unsigned int len)
|
|||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
/* Update bitcount */
|
/* Update bitcount */
|
||||||
u_int32_t t = ctx->bytesLo;
|
uint32_t t = ctx->bytesLo;
|
||||||
if ((ctx->bytesLo = t + len) < t)
|
if ((ctx->bytesLo = t + len) < t)
|
||||||
ctx->bytesHi++; /* Carry from low to high */
|
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. */
|
/* i is always less than RIPEMD160_BLOCKBYTES. */
|
||||||
if (RIPEMD160_BLOCKBYTES - i > len)
|
if (RIPEMD160_BLOCKBYTES - i > len)
|
||||||
{
|
{
|
||||||
memcpy ((u_int8_t *) ctx->key + i, buf, len);
|
memcpy ((uint8_t *) ctx->key + i, buf, len);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i)
|
if (i)
|
||||||
{ /* First chunk is an odd size */
|
{ /* First chunk is an odd size */
|
||||||
memcpy ((u_int8_t *) ctx->key + i, buf, RIPEMD160_BLOCKBYTES - i);
|
memcpy ((uint8_t *) ctx->key + i, buf, RIPEMD160_BLOCKBYTES - i);
|
||||||
rmd160ByteSwap (ctx->key, (u_int8_t *) ctx->key, RIPEMD160_BLOCKWORDS);
|
rmd160ByteSwap (ctx->key, (uint8_t *) ctx->key, RIPEMD160_BLOCKWORDS);
|
||||||
RMDcompress (ctx->iv, ctx->key);
|
RMDcompress (ctx->iv, ctx->key);
|
||||||
buf += RIPEMD160_BLOCKBYTES - i;
|
buf += RIPEMD160_BLOCKBYTES - i;
|
||||||
len -= RIPEMD160_BLOCKBYTES - i;
|
len -= RIPEMD160_BLOCKBYTES - i;
|
||||||
@@ -426,17 +426,17 @@ void
|
|||||||
RMD160Final (unsigned char digest[20], RMD160_CTX * ctx)
|
RMD160Final (unsigned char digest[20], RMD160_CTX * ctx)
|
||||||
{
|
{
|
||||||
int i;
|
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++)
|
for (i = 0; i < RIPEMD160_HASHWORDS; i++)
|
||||||
{
|
{
|
||||||
t = ctx->iv[i];
|
t = ctx->iv[i];
|
||||||
digest[i * 4 + 0] = (u_int8_t) t;
|
digest[i * 4 + 0] = (uint8_t) t;
|
||||||
digest[i * 4 + 1] = (u_int8_t) (t >> 8);
|
digest[i * 4 + 1] = (uint8_t) (t >> 8);
|
||||||
digest[i * 4 + 2] = (u_int8_t) (t >> 16);
|
digest[i * 4 + 2] = (uint8_t) (t >> 16);
|
||||||
digest[i * 4 + 3] = (u_int8_t) (t >> 24);
|
digest[i * 4 + 3] = (uint8_t) (t >> 24);
|
||||||
}
|
}
|
||||||
|
|
||||||
memset (ctx, 0, sizeof (RMD160_CTX)); /* In case it's sensitive */
|
memset (ctx, 0, sizeof (RMD160_CTX)); /* In case it's sensitive */
|
||||||
|
@@ -3,6 +3,7 @@
|
|||||||
#ifndef _RMD160_H_
|
#ifndef _RMD160_H_
|
||||||
#define _RMD160_H_
|
#define _RMD160_H_
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#define RMD160_BLOCKBYTES 64
|
#define RMD160_BLOCKBYTES 64
|
||||||
@@ -20,9 +21,9 @@
|
|||||||
|
|
||||||
/* RIPEMD160 context. */
|
/* RIPEMD160 context. */
|
||||||
typedef struct RMD160Context {
|
typedef struct RMD160Context {
|
||||||
u_int32_t key[RIPEMD160_BLOCKWORDS];
|
uint32_t key[RIPEMD160_BLOCKWORDS];
|
||||||
u_int32_t iv[RIPEMD160_HASHWORDS];
|
uint32_t iv[RIPEMD160_HASHWORDS];
|
||||||
u_int32_t bytesHi, bytesLo;
|
uint32_t bytesHi, bytesLo;
|
||||||
} RMD160_CTX;
|
} RMD160_CTX;
|
||||||
|
|
||||||
#define RIPEMD160Context RMD160Context
|
#define RIPEMD160Context RMD160Context
|
||||||
|
Reference in New Issue
Block a user