X-Git-Url: http://git.ozlabs.org/?p=ppp.git;a=blobdiff_plain;f=pppd%2Fsha1.c;h=f4f975cf516f6c9b58516f08a71152bdef62beca;hp=da142f1a7611b67a31e0ba39da5c36c70de8c1d5;hb=2b4ea140432eeba5a007c0d4e6236bd0e0c12ba4;hpb=7e1b44a2e4d84f1564d6a4ac4baa43a8d189ae38 diff --git a/pppd/sha1.c b/pppd/sha1.c index da142f1..f4f975c 100644 --- a/pppd/sha1.c +++ b/pppd/sha1.c @@ -18,6 +18,7 @@ #include #include /* htonl() */ +#include #include "sha1.h" static void @@ -121,18 +122,17 @@ SHA1_Update(SHA1_CTX *context, const unsigned char *data, unsigned int len) j = (context->count[0] >> 3) & 63; if ((context->count[0] += len << 3) < (len << 3)) context->count[1]++; context->count[1] += (len >> 29); - if ((j + len) > 63) { - memcpy(&context->buffer[j], data, (i = 64-j)); + i = 64 - j; + while (len >= i) { + memcpy(&context->buffer[j], data, i); SHA1_Transform(context->state, context->buffer); - for ( ; i + 63 < len; i += 64) { - SHA1_Transform(context->state, &data[i]); - } + data += i; + len -= i; + i = 64; j = 0; } - else - i = 0; - memcpy(&context->buffer[j], &data[i], len - i); + memcpy(&context->buffer[j], data, len); }