Replace u_intxx types with c99 standard uintxx ones
This commit is contained in:
parent
bd4bc02238
commit
8e3f51c400
@ -20,10 +20,10 @@
|
|||||||
#include "autoconfig.h"
|
#include "autoconfig.h"
|
||||||
//#include <compat.h>
|
//#include <compat.h>
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include "md5.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "md5.h"
|
|
||||||
|
|
||||||
#define PUT_64BIT_LE(cp, value) do { \
|
#define PUT_64BIT_LE(cp, value) do { \
|
||||||
(cp)[7] = (value) >> 56; \
|
(cp)[7] = (value) >> 56; \
|
||||||
@ -41,7 +41,7 @@
|
|||||||
(cp)[1] = (value) >> 8; \
|
(cp)[1] = (value) >> 8; \
|
||||||
(cp)[0] = (value); } while (0)
|
(cp)[0] = (value); } while (0)
|
||||||
|
|
||||||
static u_int8_t PADDING[MD5_BLOCK_LENGTH] = {
|
static uint8_t PADDING[MD5_BLOCK_LENGTH] = {
|
||||||
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||||
@ -75,7 +75,7 @@ MD5Update(MD5_CTX *ctx, const unsigned char *input, size_t len)
|
|||||||
need = MD5_BLOCK_LENGTH - have;
|
need = MD5_BLOCK_LENGTH - have;
|
||||||
|
|
||||||
/* Update bitcount */
|
/* Update bitcount */
|
||||||
ctx->count += (u_int64_t)len << 3;
|
ctx->count += (uint64_t)len << 3;
|
||||||
|
|
||||||
if (len >= need) {
|
if (len >= need) {
|
||||||
if (have != 0) {
|
if (have != 0) {
|
||||||
@ -106,7 +106,7 @@ MD5Update(MD5_CTX *ctx, const unsigned char *input, size_t len)
|
|||||||
void
|
void
|
||||||
MD5Pad(MD5_CTX *ctx)
|
MD5Pad(MD5_CTX *ctx)
|
||||||
{
|
{
|
||||||
u_int8_t count[8];
|
uint8_t count[8];
|
||||||
size_t padlen;
|
size_t padlen;
|
||||||
|
|
||||||
/* Convert count to 8 bytes in little endian order. */
|
/* Convert count to 8 bytes in little endian order. */
|
||||||
@ -156,19 +156,19 @@ MD5Final(unsigned char digest[MD5_DIGEST_LENGTH], MD5_CTX *ctx)
|
|||||||
* the data and converts bytes into longwords for this routine.
|
* the data and converts bytes into longwords for this routine.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
MD5Transform(u_int32_t state[4], const u_int8_t block[MD5_BLOCK_LENGTH])
|
MD5Transform(uint32_t state[4], const uint8_t block[MD5_BLOCK_LENGTH])
|
||||||
{
|
{
|
||||||
u_int32_t a, b, c, d, in[MD5_BLOCK_LENGTH / 4];
|
uint32_t a, b, c, d, in[MD5_BLOCK_LENGTH / 4];
|
||||||
|
|
||||||
#ifndef WORDS_BIGENDIAN
|
#ifndef WORDS_BIGENDIAN
|
||||||
memcpy(in, block, sizeof(in));
|
memcpy(in, block, sizeof(in));
|
||||||
#else
|
#else
|
||||||
for (a = 0; a < MD5_BLOCK_LENGTH / 4; a++) {
|
for (a = 0; a < MD5_BLOCK_LENGTH / 4; a++) {
|
||||||
in[a] = (u_int32_t)(
|
in[a] = (uint32_t)(
|
||||||
(u_int32_t)(block[a * 4 + 0]) |
|
(uint32_t)(block[a * 4 + 0]) |
|
||||||
(u_int32_t)(block[a * 4 + 1]) << 8 |
|
(uint32_t)(block[a * 4 + 1]) << 8 |
|
||||||
(u_int32_t)(block[a * 4 + 2]) << 16 |
|
(uint32_t)(block[a * 4 + 2]) << 16 |
|
||||||
(u_int32_t)(block[a * 4 + 3]) << 24);
|
(uint32_t)(block[a * 4 + 3]) << 24);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@ -15,20 +15,23 @@
|
|||||||
#ifndef _MD5_H_
|
#ifndef _MD5_H_
|
||||||
#define _MD5_H_
|
#define _MD5_H_
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
#define MD5_BLOCK_LENGTH 64
|
#define MD5_BLOCK_LENGTH 64
|
||||||
#define MD5_DIGEST_LENGTH 16
|
#define MD5_DIGEST_LENGTH 16
|
||||||
#define MD5_DIGEST_STRING_LENGTH (MD5_DIGEST_LENGTH * 2 + 1)
|
#define MD5_DIGEST_STRING_LENGTH (MD5_DIGEST_LENGTH * 2 + 1)
|
||||||
|
|
||||||
typedef struct MD5Context {
|
typedef struct MD5Context {
|
||||||
u_int32_t state[4]; /* state */
|
uint32_t state[4]; /* state */
|
||||||
u_int64_t count; /* number of bits, mod 2^64 */
|
uint64_t count; /* number of bits, mod 2^64 */
|
||||||
u_int8_t buffer[MD5_BLOCK_LENGTH]; /* input buffer */
|
uint8_t buffer[MD5_BLOCK_LENGTH]; /* input buffer */
|
||||||
} MD5_CTX;
|
} MD5_CTX;
|
||||||
|
|
||||||
void MD5Init(MD5_CTX *);
|
void MD5Init(MD5_CTX *);
|
||||||
void MD5Update(MD5_CTX *, const u_int8_t *, size_t);
|
void MD5Update(MD5_CTX *, const uint8_t *, size_t);
|
||||||
void MD5Pad(MD5_CTX *);
|
void MD5Pad(MD5_CTX *);
|
||||||
void MD5Final(u_int8_t [MD5_DIGEST_LENGTH], MD5_CTX *);
|
void MD5Final(uint8_t [MD5_DIGEST_LENGTH], MD5_CTX *);
|
||||||
void MD5Transform(u_int32_t [4], const u_int8_t [MD5_BLOCK_LENGTH]);
|
void MD5Transform(uint32_t [4], const uint8_t [MD5_BLOCK_LENGTH]);
|
||||||
|
|
||||||
#endif /* _MD5_H_ */
|
#endif /* _MD5_H_ */
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user