#ifndef _LRAD_PROTO_H
#define _LRAD_PROTO_H
+#include "autoconf.h"
+
+#if HAVE_INTTYPES_H
+#include <inttypes.h>
+#endif
+
+#if HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+
+#if HAVE_STDINT_H
+#include <stdint.h>
+#endif
+
/* GLOBAL.H - RSAREF types and constants
*/
typedef unsigned char *POINTER;
#define _POINTER_T
-/* UINT2 defines a two byte word */
-typedef unsigned short int UINT2;
-#define _UINT2_T
-
-/* UINT4 defines a four byte word */
-#if defined(__alpha) && (defined(__osf__) || defined(__linux__))
-typedef unsigned int UINT4;
-#else
-typedef unsigned long int UINT4;
-#endif
-#define _UINT4_T
-
/* PROTO_LIST is defined depending on how PROTOTYPES is defined above.
If using PROTOTYPES, then PROTO_LIST returns the list, otherwise it
returns an empty list.
/* MD4 context. */
typedef struct {
- UINT4 state[4]; /* state (ABCD) */
- UINT4 count[2]; /* number of bits, modulo 2^64 (lsb first) */
+ uint32_t state[4]; /* state (ABCD) */
+ uint32_t count[2]; /* number of bits, modulo 2^64 (lsb first) */
unsigned char buffer[64]; /* input buffer */
} MD4_CTX;
#ifndef _LRAD_PROTO_H
#define _LRAD_PROTO_H
+#include "autoconf.h"
+
+#if HAVE_INTTYPES_H
+#include <inttypes.h>
+#endif
+
+#if HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+
+#if HAVE_STDINT_H
+#include <stdint.h>
+#endif
+
/* GLOBAL.H - RSAREF types and constants
*/
#endif
typedef const unsigned char *CONSTPOINTER;
-/* UINT2 defines a two byte word */
-#ifndef _UINT2_T
-typedef unsigned short int UINT2;
-#endif
-
-/* UINT4 defines a four byte word */
-#ifndef _UINT4_T
-#if defined(__alpha) && (defined(__osf__) || defined(__linux__))
-typedef unsigned int UINT4;
-#else
-typedef unsigned long int UINT4;
-#endif
-#endif
-
/* PROTO_LIST is defined depending on how PROTOTYPES is defined above.
If using PROTOTYPES, then PROTO_LIST returns the list, otherwise it
returns an empty list.
/* MD5 context. */
typedef struct {
- UINT4 state[4]; /* state (ABCD) */
- UINT4 count[2]; /* number of bits, modulo 2^64 (lsb first) */
+ uint32_t state[4]; /* state (ABCD) */
+ uint32_t count[2]; /* number of bits, modulo 2^64 (lsb first) */
unsigned char buffer[64]; /* input buffer */
} MD5_CTX;
#define S33 11
#define S34 15
-static void MD4Transform PROTO_LIST ((UINT4 [4], const unsigned char [64]));
+static void MD4Transform PROTO_LIST ((uint32_t [4], const unsigned char [64]));
static void Encode PROTO_LIST
- ((unsigned char *, const UINT4 *, unsigned int));
+ ((unsigned char *, const uint32_t *, unsigned int));
static void Decode PROTO_LIST
- ((UINT4 *, const unsigned char *, unsigned int));
+ ((uint32_t *, const unsigned char *, unsigned int));
static void MD4_memcpy PROTO_LIST ((POINTER, const POINTER, unsigned int));
static void MD4_memset PROTO_LIST ((POINTER, int, unsigned int));
(a) = ROTATE_LEFT ((a), (s)); \
}
#define GG(a, b, c, d, x, s) { \
- (a) += G ((b), (c), (d)) + (x) + (UINT4)0x5a827999; \
+ (a) += G ((b), (c), (d)) + (x) + (uint32_t)0x5a827999; \
(a) = ROTATE_LEFT ((a), (s)); \
}
#define HH(a, b, c, d, x, s) { \
- (a) += H ((b), (c), (d)) + (x) + (UINT4)0x6ed9eba1; \
+ (a) += H ((b), (c), (d)) + (x) + (uint32_t)0x6ed9eba1; \
(a) = ROTATE_LEFT ((a), (s)); \
}
/* Compute number of bytes mod 64 */
buffindex = (unsigned int)((context->count[0] >> 3) & 0x3F);
/* Update number of bits */
- if ((context->count[0] += ((UINT4)inputLen << 3))
- < ((UINT4)inputLen << 3))
+ if ((context->count[0] += ((uint32_t)inputLen << 3))
+ < ((uint32_t)inputLen << 3))
context->count[1]++;
- context->count[1] += ((UINT4)inputLen >> 29);
+ context->count[1] += ((uint32_t)inputLen >> 29);
partLen = 64 - buffindex;
/* MD4 basic transformation. Transforms state based on block.
*/
static void MD4Transform (state, block)
-UINT4 state[4];
+uint32_t state[4];
const unsigned char block[64];
{
- UINT4 a = state[0], b = state[1], c = state[2], d = state[3], x[16];
+ uint32_t a = state[0], b = state[1], c = state[2], d = state[3], x[16];
Decode (x, block, 64);
MD4_memset ((POINTER)x, 0, sizeof (x));
}
-/* Encodes input (UINT4) into output (unsigned char). Assumes len is
+/* Encodes input (uint32_t) into output (unsigned char). Assumes len is
a multiple of 4.
*/
static void Encode (output, input, len)
unsigned char *output;
-const UINT4 *input;
+const uint32_t *input;
unsigned int len;
{
unsigned int i, j;
}
}
-/* Decodes input (unsigned char) into output (UINT4). Assumes len is
+/* Decodes input (unsigned char) into output (uint32_t). Assumes len is
a multiple of 4.
*/
static void Decode (output, input, len)
-UINT4 *output;
+uint32_t *output;
const unsigned char *input;
unsigned int len;
{
unsigned int i, j;
for (i = 0, j = 0; j < len; i++, j += 4)
- output[i] = ((UINT4)input[j]) | (((UINT4)input[j+1]) << 8) |
- (((UINT4)input[j+2]) << 16) | (((UINT4)input[j+3]) << 24);
+ output[i] = ((uint32_t)input[j]) | (((uint32_t)input[j+1]) << 8) |
+ (((uint32_t)input[j+2]) << 16) | (((uint32_t)input[j+3]) << 24);
}
/* Note: Replace "for loop" with standard memcpy if possible.
void librad_md5_calc(unsigned char *output, unsigned char *input,
unsigned int inputlen);
-static void MD5Transform PROTO_LIST ((UINT4 [4], const unsigned char [64]));
+static void MD5Transform PROTO_LIST ((uint32_t [4], const unsigned char [64]));
static void Encode PROTO_LIST
- ((unsigned char *, const UINT4 *, unsigned int));
+ ((unsigned char *, const uint32_t *, unsigned int));
static void Decode PROTO_LIST
- ((UINT4 *, const unsigned char *, unsigned int));
+ ((uint32_t *, const unsigned char *, unsigned int));
static void MD5_memcpy PROTO_LIST ((POINTER, CONSTPOINTER, unsigned int));
static void MD5_memset PROTO_LIST ((POINTER, int, unsigned int));
Rotation is separate from addition to prevent recomputation.
*/
#define FF(a, b, c, d, x, s, ac) { \
- (a) += F ((b), (c), (d)) + (x) + (UINT4)(ac); \
+ (a) += F ((b), (c), (d)) + (x) + (uint32_t)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
#define GG(a, b, c, d, x, s, ac) { \
- (a) += G ((b), (c), (d)) + (x) + (UINT4)(ac); \
+ (a) += G ((b), (c), (d)) + (x) + (uint32_t)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
#define HH(a, b, c, d, x, s, ac) { \
- (a) += H ((b), (c), (d)) + (x) + (UINT4)(ac); \
+ (a) += H ((b), (c), (d)) + (x) + (uint32_t)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
#define II(a, b, c, d, x, s, ac) { \
- (a) += I ((b), (c), (d)) + (x) + (UINT4)(ac); \
+ (a) += I ((b), (c), (d)) + (x) + (uint32_t)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
idx = (unsigned int)((context->count[0] >> 3) & 0x3F);
/* Update number of bits */
- if ((context->count[0] += ((UINT4)inputLen << 3))
- < ((UINT4)inputLen << 3))
+ if ((context->count[0] += ((uint32_t)inputLen << 3))
+ < ((uint32_t)inputLen << 3))
context->count[1]++;
- context->count[1] += ((UINT4)inputLen >> 29);
+ context->count[1] += ((uint32_t)inputLen >> 29);
partLen = 64 - idx;
/* MD5 basic transformation. Transforms state based on block.
*/
static void MD5Transform (state, block)
-UINT4 state[4];
+uint32_t state[4];
const unsigned char block[64];
{
- UINT4 a = state[0], b = state[1], c = state[2], d = state[3], x[16];
+ uint32_t a = state[0], b = state[1], c = state[2], d = state[3], x[16];
Decode (x, block, 64);
MD5_memset ((POINTER)x, 0, sizeof (x));
}
-/* Encodes input (UINT4) into output (unsigned char). Assumes len is
+/* Encodes input (uint32_t) into output (unsigned char). Assumes len is
a multiple of 4.
*/
static void Encode (output, input, len)
unsigned char *output;
-const UINT4 *input;
+const uint32_t *input;
unsigned int len;
{
unsigned int i, j;
}
}
-/* Decodes input (unsigned char) into output (UINT4). Assumes len is
+/* Decodes input (unsigned char) into output (uint32_t). Assumes len is
a multiple of 4.
*/
static void Decode (output, input, len)
-UINT4 *output;
+uint32_t *output;
const unsigned char *input;
unsigned int len;
{
unsigned int i, j;
for (i = 0, j = 0; j < len; i++, j += 4)
- output[i] = ((UINT4)input[j]) | (((UINT4)input[j+1]) << 8) |
- (((UINT4)input[j+2]) << 16) | (((UINT4)input[j+3]) << 24);
+ output[i] = ((uint32_t)input[j]) | (((uint32_t)input[j+1]) << 8) |
+ (((uint32_t)input[j+2]) << 16) | (((uint32_t)input[j+3]) << 24);
}
/* Note: Replace "for loop" with standard memcpy if possible.