X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;ds=sidebyside;f=libraries%2Fliblutil%2Fsha1.c;h=9d97ceb169c165118afe8b363458c9095079cb1f;hb=583cbc8c25073b23ba2dec6254d9ecef21907a86;hp=7b0d9c4aa6f8fca64d634d52992afab6f4206f6e;hpb=e3d164d10ef2aab3124be345a101a6ee8296afd8;p=openldap diff --git a/libraries/liblutil/sha1.c b/libraries/liblutil/sha1.c index 7b0d9c4aa6..9d97ceb169 100644 --- a/libraries/liblutil/sha1.c +++ b/libraries/liblutil/sha1.c @@ -1,3 +1,8 @@ +/* $OpenLDAP$ */ +/* + * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ /* Acquired from: * $OpenBSD: sha1.c,v 1.9 1997/07/23 21:12:32 kstailey Exp $ */ @@ -15,6 +20,9 @@ * 34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F */ +/* + * This code assumes uint32 is 32 bits and char is 8 bits + */ #include "portable.h" #include @@ -22,12 +30,11 @@ /* include socket.h to get sys/types.h and/or winsock2.h */ #include -#if defined(HAVE_SYS_PARAM_H) -#include -#endif +#include #include "lutil_sha1.h" +/* undefining this will cause pointer alignment errors */ #define SHA1HANDSOFF /* Copies data before messing with it. */ #define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits)))) @@ -62,13 +69,11 @@ lutil_SHA1Transform( uint32 *state, const unsigned char *buffer ) { uint32 a, b, c, d, e; - /* Assumes u_int is 32 bits and char 8 bits. - * I don't know why uint32 isn't used (or what the difference is). */ #ifdef SHA1HANDSOFF - u_int block[16]; - (void)memcpy(block, buffer, 64); + uint32 block[16]; + (void)AC_MEMCPY(block, buffer, 64); #else - u_int *block = (u_int *)buffer; + uint32 *block = (u_int32 *) buffer; #endif /* Copy context->state[] to working vars */ @@ -146,7 +151,7 @@ lutil_SHA1Update( context->count[1] += (len>>29)+1; j = (j >> 3) & 63; if ((j + len) > 63) { - (void)memcpy(&context->buffer[j], data, (i = 64-j)); + (void)AC_MEMCPY(&context->buffer[j], data, (i = 64-j)); lutil_SHA1Transform(context->state, context->buffer); for ( ; i + 63 < len; i += 64) lutil_SHA1Transform(context->state, &data[i]); @@ -154,7 +159,7 @@ lutil_SHA1Update( } else { i = 0; } - (void)memcpy(&context->buffer[j], &data[i], len - i); + (void)AC_MEMCPY(&context->buffer[j], &data[i], len - i); }