cleanup
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
#include "global.h"
|
||||
#include "CryptMD5.h"
|
||||
#include "SDL_utils.h"
|
||||
|
||||
/*
|
||||
* MD5 implementation for PuTTY. Written directly from the spec by
|
||||
@@ -16,7 +15,7 @@
|
||||
#define H(x,y,z) ( (x) ^ (y) ^ (z) )
|
||||
#define I(x,y,z) ( (y) ^ ( (x) | ~(z) ) )
|
||||
|
||||
#define rol(x,y) ( ((x) << (y)) | (((Uint32)x) >> (32-y)) )
|
||||
#define rol(x,y) ( ((x) << (y)) | (((uint32_t)x) >> (32-y)) )
|
||||
|
||||
#define subround(f,w,x,y,z,k,s,ti) \
|
||||
w = x + rol(w + f(x,y,z) + block[k] + ti, s)
|
||||
@@ -29,9 +28,9 @@ static void MD5_Core_Init(MD5_Core_State * s)
|
||||
s->h[3] = 0x10325476;
|
||||
}
|
||||
|
||||
static void MD5_Block(MD5_Core_State * s, Uint32 * block)
|
||||
static void MD5_Block(MD5_Core_State * s, uint32_t * block)
|
||||
{
|
||||
Uint32 a, b, c, d;
|
||||
uint32_t a, b, c, d;
|
||||
|
||||
a = s->h[0];
|
||||
b = s->h[1];
|
||||
@@ -127,8 +126,8 @@ void MD5Init(struct MD5Context *s)
|
||||
void MD5Update(struct MD5Context *s, unsigned char const *p, unsigned len)
|
||||
{
|
||||
unsigned char *q = (unsigned char *) p;
|
||||
Uint32 wordblock[16];
|
||||
Uint32 lenw = len;
|
||||
uint32_t wordblock[16];
|
||||
uint32_t lenw = len;
|
||||
int i;
|
||||
|
||||
/*
|
||||
@@ -154,10 +153,10 @@ void MD5Update(struct MD5Context *s, unsigned char const *p, unsigned len)
|
||||
/* Now process the block. Gather bytes little-endian into words */
|
||||
for (i = 0; i < 16; i++) {
|
||||
wordblock[i] =
|
||||
(((Uint32) s->block[i * 4 + 3]) << 24) |
|
||||
(((Uint32) s->block[i * 4 + 2]) << 16) |
|
||||
(((Uint32) s->block[i * 4 + 1]) << 8) |
|
||||
(((Uint32) s->block[i * 4 + 0]) << 0);
|
||||
(((uint32_t) s->block[i * 4 + 3]) << 24) |
|
||||
(((uint32_t) s->block[i * 4 + 2]) << 16) |
|
||||
(((uint32_t) s->block[i * 4 + 1]) << 8) |
|
||||
(((uint32_t) s->block[i * 4 + 0]) << 0);
|
||||
}
|
||||
MD5_Block(&s->core, wordblock);
|
||||
s->blkused = 0;
|
||||
@@ -172,7 +171,7 @@ void MD5Final(unsigned char output[16], struct MD5Context *s)
|
||||
int i;
|
||||
unsigned pad;
|
||||
unsigned char c[64];
|
||||
Uint32 lenhi, lenlo;
|
||||
uint32_t lenhi, lenlo;
|
||||
|
||||
if (s->blkused >= 56)
|
||||
pad = 56 + 64 - s->blkused;
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
#ifndef SSHMD5_H
|
||||
#define SSHMD5_H
|
||||
|
||||
#include "SDL_utils.h"
|
||||
|
||||
typedef struct {
|
||||
Uint32 h[4];
|
||||
uint32_t h[4];
|
||||
} MD5_Core_State;
|
||||
|
||||
struct MD5Context {
|
||||
MD5_Core_State core;
|
||||
unsigned char block[64];
|
||||
int blkused;
|
||||
Uint32 lenhi, lenlo;
|
||||
uint32_t lenhi, lenlo;
|
||||
};
|
||||
|
||||
void MD5Init(struct MD5Context *context);
|
||||
|
||||
@@ -183,7 +183,7 @@ void SHA512_Bytes(SHA512_State *s, const void *p, int len)
|
||||
{
|
||||
unsigned char *q = (unsigned char *)p;
|
||||
uint64 wordblock[16];
|
||||
Uint32 lenw = len;
|
||||
uint32_t lenw = len;
|
||||
int i;
|
||||
|
||||
/*
|
||||
@@ -210,15 +210,15 @@ void SHA512_Bytes(SHA512_State *s, const void *p, int len)
|
||||
len -= BLKSIZE - s->blkused;
|
||||
/* Now process the block. Gather bytes big-endian into words */
|
||||
for (i = 0; i < 16; i++) {
|
||||
Uint32 h, l;
|
||||
h = ( ((Uint32)s->block[i*8+0]) << 24 ) |
|
||||
( ((Uint32)s->block[i*8+1]) << 16 ) |
|
||||
( ((Uint32)s->block[i*8+2]) << 8 ) |
|
||||
( ((Uint32)s->block[i*8+3]) << 0 );
|
||||
l = ( ((Uint32)s->block[i*8+4]) << 24 ) |
|
||||
( ((Uint32)s->block[i*8+5]) << 16 ) |
|
||||
( ((Uint32)s->block[i*8+6]) << 8 ) |
|
||||
( ((Uint32)s->block[i*8+7]) << 0 );
|
||||
uint32_t h, l;
|
||||
h = ( ((uint32_t)s->block[i*8+0]) << 24 ) |
|
||||
( ((uint32_t)s->block[i*8+1]) << 16 ) |
|
||||
( ((uint32_t)s->block[i*8+2]) << 8 ) |
|
||||
( ((uint32_t)s->block[i*8+3]) << 0 );
|
||||
l = ( ((uint32_t)s->block[i*8+4]) << 24 ) |
|
||||
( ((uint32_t)s->block[i*8+5]) << 16 ) |
|
||||
( ((uint32_t)s->block[i*8+6]) << 8 ) |
|
||||
( ((uint32_t)s->block[i*8+7]) << 0 );
|
||||
BUILD(wordblock[i], h, l);
|
||||
}
|
||||
SHA512_Block(s, wordblock);
|
||||
@@ -234,7 +234,7 @@ void SHA512_Final(SHA512_State *s, unsigned char *digest)
|
||||
int i;
|
||||
int pad;
|
||||
unsigned char c[BLKSIZE];
|
||||
Uint32 len[4];
|
||||
uint32_t len[4];
|
||||
|
||||
if (s->blkused >= BLKSIZE-16)
|
||||
pad = (BLKSIZE-16) + BLKSIZE - s->blkused;
|
||||
@@ -242,8 +242,8 @@ void SHA512_Final(SHA512_State *s, unsigned char *digest)
|
||||
pad = (BLKSIZE-16) - s->blkused;
|
||||
|
||||
for (i = 4; i-- ;) {
|
||||
Uint32 lenhi = s->len[i];
|
||||
Uint32 lenlo = i > 0 ? s->len[i-1] : 0;
|
||||
uint32_t lenhi = s->len[i];
|
||||
uint32_t lenlo = i > 0 ? s->len[i-1] : 0;
|
||||
len[i] = (lenhi << 3) | (lenlo >> (32-3));
|
||||
}
|
||||
|
||||
@@ -261,7 +261,7 @@ void SHA512_Final(SHA512_State *s, unsigned char *digest)
|
||||
SHA512_Bytes(s, &c, 16);
|
||||
|
||||
for (i = 0; i < 8; i++) {
|
||||
Uint32 h, l;
|
||||
uint32_t h, l;
|
||||
EXTRACT(h, l, s->h[i]);
|
||||
digest[i*8+0] = char((h >> 24) & 0xFF);
|
||||
digest[i*8+1] = char((h >> 16) & 0xFF);
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
#ifndef SSH_SHA512_H
|
||||
#define SSH_SHA512_H
|
||||
|
||||
#include "SDL_utils.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned long hi, lo;
|
||||
@@ -13,7 +11,7 @@ typedef struct
|
||||
uint64 h[8];
|
||||
unsigned char block[128];
|
||||
int blkused;
|
||||
Uint32 len[4];
|
||||
uint32_t len[4];
|
||||
} SHA512_State;
|
||||
|
||||
void SHA512_Init(SHA512_State * s);
|
||||
|
||||
@@ -12,9 +12,9 @@
|
||||
* Core SHA algorithm: processes 16-word blocks into a message digest.
|
||||
*/
|
||||
|
||||
#define rol(x,y) ( ((x) << (y)) | (((Uint32)x) >> (32-y)) )
|
||||
#define rol(x,y) ( ((x) << (y)) | (((uint32_t)x) >> (32-y)) )
|
||||
|
||||
static void SHA_Core_Init(Uint32 h[5])
|
||||
static void SHA_Core_Init(uint32_t h[5])
|
||||
{
|
||||
h[0] = 0x67452301;
|
||||
h[1] = 0xefcdab89;
|
||||
@@ -102,8 +102,8 @@ void SHA_Init(SHA_State * s)
|
||||
void SHA_Bytes(SHA_State * s, const void *p, int len)
|
||||
{
|
||||
unsigned char *q = (unsigned char *) p;
|
||||
Uint32 wordblock[16];
|
||||
Uint32 lenw = len;
|
||||
uint32_t wordblock[16];
|
||||
uint32_t lenw = len;
|
||||
int i;
|
||||
|
||||
/*
|
||||
@@ -129,10 +129,10 @@ void SHA_Bytes(SHA_State * s, const void *p, int len)
|
||||
/* Now process the block. Gather bytes big-endian into words */
|
||||
for (i = 0; i < 16; i++) {
|
||||
wordblock[i] =
|
||||
(((Uint32) s->block[i * 4 + 0]) << 24) |
|
||||
(((Uint32) s->block[i * 4 + 1]) << 16) |
|
||||
(((Uint32) s->block[i * 4 + 2]) << 8) |
|
||||
(((Uint32) s->block[i * 4 + 3]) << 0);
|
||||
(((uint32_t) s->block[i * 4 + 0]) << 24) |
|
||||
(((uint32_t) s->block[i * 4 + 1]) << 16) |
|
||||
(((uint32_t) s->block[i * 4 + 2]) << 8) |
|
||||
(((uint32_t) s->block[i * 4 + 3]) << 0);
|
||||
}
|
||||
SHATransform(s->h, wordblock);
|
||||
s->blkused = 0;
|
||||
@@ -147,7 +147,7 @@ void SHA_Final(SHA_State * s, unsigned char *output)
|
||||
int i;
|
||||
int pad;
|
||||
unsigned char c[64];
|
||||
Uint32 lenhi, lenlo;
|
||||
uint32_t lenhi, lenlo;
|
||||
|
||||
if (s->blkused >= 56)
|
||||
pad = 56 + 64 - s->blkused;
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
#ifndef SSHSHA_H
|
||||
#define SSHSHA_H
|
||||
|
||||
#include "SDL_utils.h"
|
||||
|
||||
typedef struct {
|
||||
Uint32 h[5];
|
||||
uint32_t h[5];
|
||||
unsigned char block[64];
|
||||
int blkused;
|
||||
Uint32 lenhi, lenlo;
|
||||
uint32_t lenhi, lenlo;
|
||||
} SHA_State;
|
||||
|
||||
void SHA_Init(SHA_State * s);
|
||||
|
||||
Reference in New Issue
Block a user