Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/lib/libalpm/md5.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libalpm/md5.c')
-rw-r--r--lib/libalpm/md5.c81
1 files changed, 41 insertions, 40 deletions
diff --git a/lib/libalpm/md5.c b/lib/libalpm/md5.c
index b4391a61..0d5ed9e0 100644
--- a/lib/libalpm/md5.c
+++ b/lib/libalpm/md5.c
@@ -33,33 +33,34 @@
* GPL. This is from version 1.0.0 of the library, and has been modified
* as following, which may be helpful for future updates:
* * remove "polarssl/config.h" include
- * * change include from "polarssl/sha2.h" to "sha2.h"
+ * * change include from "polarssl/md5.h" to "md5.h"
* * removal of HMAC code
* * removal of SELF_TEST code
- * * removal of ipad and opad from the md5_context struct in sha2.h
+ * * removal of ipad and opad from the md5_context struct in md5.h
* * increase the size of buffer for performance reasons
- * * various static changes
+ * * change 'unsigned long' to uint32_t
*/
#include <stdio.h>
+#include <stdint.h>
#include "md5.h"
/*
* 32-bit integer manipulation macros (little endian)
*/
-#ifndef GET_ULONG_LE
-#define GET_ULONG_LE(n,b,i) \
+#ifndef GET_U32_LE
+#define GET_U32_LE(n,b,i) \
{ \
- (n) = ( (unsigned long) (b)[(i) ] ) \
- | ( (unsigned long) (b)[(i) + 1] << 8 ) \
- | ( (unsigned long) (b)[(i) + 2] << 16 ) \
- | ( (unsigned long) (b)[(i) + 3] << 24 ); \
+ (n) = ( (uint32_t) (b)[(i) ] ) \
+ | ( (uint32_t) (b)[(i) + 1] << 8 ) \
+ | ( (uint32_t) (b)[(i) + 2] << 16 ) \
+ | ( (uint32_t) (b)[(i) + 3] << 24 ); \
}
#endif
-#ifndef PUT_ULONG_LE
-#define PUT_ULONG_LE(n,b,i) \
+#ifndef PUT_U32_LE
+#define PUT_U32_LE(n,b,i) \
{ \
(b)[(i) ] = (unsigned char) ( (n) ); \
(b)[(i) + 1] = (unsigned char) ( (n) >> 8 ); \
@@ -84,24 +85,24 @@ static void md5_starts( md5_context *ctx )
static void md5_process( md5_context *ctx, const unsigned char data[64] )
{
- unsigned long X[16], A, B, C, D;
-
- GET_ULONG_LE( X[ 0], data, 0 );
- GET_ULONG_LE( X[ 1], data, 4 );
- GET_ULONG_LE( X[ 2], data, 8 );
- GET_ULONG_LE( X[ 3], data, 12 );
- GET_ULONG_LE( X[ 4], data, 16 );
- GET_ULONG_LE( X[ 5], data, 20 );
- GET_ULONG_LE( X[ 6], data, 24 );
- GET_ULONG_LE( X[ 7], data, 28 );
- GET_ULONG_LE( X[ 8], data, 32 );
- GET_ULONG_LE( X[ 9], data, 36 );
- GET_ULONG_LE( X[10], data, 40 );
- GET_ULONG_LE( X[11], data, 44 );
- GET_ULONG_LE( X[12], data, 48 );
- GET_ULONG_LE( X[13], data, 52 );
- GET_ULONG_LE( X[14], data, 56 );
- GET_ULONG_LE( X[15], data, 60 );
+ uint32_t X[16], A, B, C, D;
+
+ GET_U32_LE( X[ 0], data, 0 );
+ GET_U32_LE( X[ 1], data, 4 );
+ GET_U32_LE( X[ 2], data, 8 );
+ GET_U32_LE( X[ 3], data, 12 );
+ GET_U32_LE( X[ 4], data, 16 );
+ GET_U32_LE( X[ 5], data, 20 );
+ GET_U32_LE( X[ 6], data, 24 );
+ GET_U32_LE( X[ 7], data, 28 );
+ GET_U32_LE( X[ 8], data, 32 );
+ GET_U32_LE( X[ 9], data, 36 );
+ GET_U32_LE( X[10], data, 40 );
+ GET_U32_LE( X[11], data, 44 );
+ GET_U32_LE( X[12], data, 48 );
+ GET_U32_LE( X[13], data, 52 );
+ GET_U32_LE( X[14], data, 56 );
+ GET_U32_LE( X[15], data, 60 );
#define S(x,n) ((x << n) | ((x & 0xFFFFFFFF) >> (32 - n)))
@@ -211,7 +212,7 @@ static void md5_process( md5_context *ctx, const unsigned char data[64] )
static void md5_update( md5_context *ctx, const unsigned char *input, size_t ilen )
{
size_t fill;
- unsigned long left;
+ uint32_t left;
if( ilen <= 0 )
return;
@@ -219,10 +220,10 @@ static void md5_update( md5_context *ctx, const unsigned char *input, size_t ile
left = ctx->total[0] & 0x3F;
fill = 64 - left;
- ctx->total[0] += (unsigned long) ilen;
+ ctx->total[0] += (uint32_t) ilen;
ctx->total[0] &= 0xFFFFFFFF;
- if( ctx->total[0] < (unsigned long) ilen )
+ if( ctx->total[0] < (uint32_t) ilen )
ctx->total[1]++;
if( left && ilen >= fill )
@@ -262,16 +263,16 @@ static const unsigned char md5_padding[64] =
*/
static void md5_finish( md5_context *ctx, unsigned char output[16] )
{
- unsigned long last, padn;
- unsigned long high, low;
+ uint32_t last, padn;
+ uint32_t high, low;
unsigned char msglen[8];
high = ( ctx->total[0] >> 29 )
| ( ctx->total[1] << 3 );
low = ( ctx->total[0] << 3 );
- PUT_ULONG_LE( low, msglen, 0 );
- PUT_ULONG_LE( high, msglen, 4 );
+ PUT_U32_LE( low, msglen, 0 );
+ PUT_U32_LE( high, msglen, 4 );
last = ctx->total[0] & 0x3F;
padn = ( last < 56 ) ? ( 56 - last ) : ( 120 - last );
@@ -279,10 +280,10 @@ static void md5_finish( md5_context *ctx, unsigned char output[16] )
md5_update( ctx, (unsigned char *) md5_padding, padn );
md5_update( ctx, msglen, 8 );
- PUT_ULONG_LE( ctx->state[0], output, 0 );
- PUT_ULONG_LE( ctx->state[1], output, 4 );
- PUT_ULONG_LE( ctx->state[2], output, 8 );
- PUT_ULONG_LE( ctx->state[3], output, 12 );
+ PUT_U32_LE( ctx->state[0], output, 0 );
+ PUT_U32_LE( ctx->state[1], output, 4 );
+ PUT_U32_LE( ctx->state[2], output, 8 );
+ PUT_U32_LE( ctx->state[3], output, 12 );
}
/*