diff options
Diffstat (limited to 'src/lib/crypto/sha1/shs.c')
-rw-r--r-- | src/lib/crypto/sha1/shs.c | 75 |
1 files changed, 38 insertions, 37 deletions
diff --git a/src/lib/crypto/sha1/shs.c b/src/lib/crypto/sha1/shs.c index 358e6ba..873f878 100644 --- a/src/lib/crypto/sha1/shs.c +++ b/src/lib/crypto/sha1/shs.c @@ -97,15 +97,15 @@ void shsInit(shsInfo) Note that this corrupts the shsInfo->data area */ -static void SHSTransform KRB5_PROTOTYPE((LONG *digest, LONG *data)); +static void SHSTransform (SHS_LONG *digest, const SHS_LONG *data); static void SHSTransform(digest, data) - LONG *digest; - LONG *data; + SHS_LONG *digest; + const SHS_LONG *data; { - LONG A, B, C, D, E; /* Local vars */ - LONG eData[ 16 ]; /* Expanded data */ + SHS_LONG A, B, C, D, E; /* Local vars */ + SHS_LONG eData[ 16 ]; /* Expanded data */ /* Set up first buffer and local data buffer */ A = digest[ 0 ]; @@ -217,16 +217,16 @@ void SHSTransform(digest, data) void shsUpdate(shsInfo, buffer, count) SHS_INFO *shsInfo; - BYTE *buffer; + SHS_BYTE *buffer; int count; { - LONG tmp; + SHS_LONG tmp; int dataCount, canfill; - LONG *lp; + SHS_LONG *lp; /* Update bitcount */ tmp = shsInfo->countLo; - shsInfo->countLo = tmp + (((LONG) count) << 3 ); + shsInfo->countLo = tmp + (((SHS_LONG) count) << 3 ); if ((shsInfo->countLo &= 0xffffffff) < tmp) shsInfo->countHi++; /* Carry from low to high */ shsInfo->countHi += count >> 29; @@ -237,37 +237,38 @@ void shsUpdate(shsInfo, buffer, count) /* Handle any leading odd-sized chunks */ if (dataCount) { lp = shsInfo->data + dataCount / 4; - canfill = (count >= dataCount); dataCount = SHS_DATASIZE - dataCount; + canfill = (count >= dataCount); if (dataCount % 4) { /* Fill out a full 32 bit word first if needed -- this is not very efficient (computed shift amount), but it shouldn't happen often. */ while (dataCount % 4 && count > 0) { - *lp |= (LONG) *buffer++ << ((3 - dataCount++ % 4) * 8); + *lp |= (SHS_LONG) *buffer++ << ((--dataCount % 4) * 8); count--; } lp++; } while (lp < shsInfo->data + 16) { - *lp = (LONG) *buffer++ << 24; - *lp |= (LONG) *buffer++ << 16; - *lp |= (LONG) *buffer++ << 8; - *lp++ |= (LONG) *buffer++; - if ((count -= 4) < 4 && lp < shsInfo->data + 16) { + if (count < 4) { *lp = 0; switch (count % 4) { case 3: - *lp |= (LONG) buffer[2] << 8; + *lp |= (SHS_LONG) buffer[2] << 8; case 2: - *lp |= (LONG) buffer[1] << 16; + *lp |= (SHS_LONG) buffer[1] << 16; case 1: - *lp |= (LONG) buffer[0] << 24; + *lp |= (SHS_LONG) buffer[0] << 24; } - break; count = 0; + break; /* out of while loop */ } + *lp = (SHS_LONG) *buffer++ << 24; + *lp |= (SHS_LONG) *buffer++ << 16; + *lp |= (SHS_LONG) *buffer++ << 8; + *lp++ |= (SHS_LONG) *buffer++; + count -= 4; } if (canfill) { SHSTransform(shsInfo->digest, shsInfo->data); @@ -278,10 +279,10 @@ void shsUpdate(shsInfo, buffer, count) while (count >= SHS_DATASIZE) { lp = shsInfo->data; while (lp < shsInfo->data + 16) { - *lp = ((LONG) *buffer++) << 24; - *lp |= ((LONG) *buffer++) << 16; - *lp |= ((LONG) *buffer++) << 8; - *lp++ |= (LONG) *buffer++; + *lp = ((SHS_LONG) *buffer++) << 24; + *lp |= ((SHS_LONG) *buffer++) << 16; + *lp |= ((SHS_LONG) *buffer++) << 8; + *lp++ |= (SHS_LONG) *buffer++; } SHSTransform(shsInfo->digest, shsInfo->data); count -= SHS_DATASIZE; @@ -290,22 +291,22 @@ void shsUpdate(shsInfo, buffer, count) if (count > 0) { lp = shsInfo->data; while (count > 4) { - *lp = ((LONG) *buffer++) << 24; - *lp |= ((LONG) *buffer++) << 16; - *lp |= ((LONG) *buffer++) << 8; - *lp++ |= (LONG) *buffer++; + *lp = ((SHS_LONG) *buffer++) << 24; + *lp |= ((SHS_LONG) *buffer++) << 16; + *lp |= ((SHS_LONG) *buffer++) << 8; + *lp++ |= (SHS_LONG) *buffer++; count -= 4; } *lp = 0; switch (count % 4) { case 0: - *lp |= ((LONG) buffer[3]); + *lp |= ((SHS_LONG) buffer[3]); case 3: - *lp |= ((LONG) buffer[2]) << 8; + *lp |= ((SHS_LONG) buffer[2]) << 8; case 2: - *lp |= ((LONG) buffer[1]) << 16; + *lp |= ((SHS_LONG) buffer[1]) << 16; case 1: - *lp |= ((LONG) buffer[0]) << 24; + *lp |= ((SHS_LONG) buffer[0]) << 24; } } } @@ -317,7 +318,7 @@ void shsFinal(shsInfo) SHS_INFO *shsInfo; { int count; - LONG *lp; + SHS_LONG *lp; /* Compute number of bytes mod 64 */ count = (int) shsInfo->countLo; @@ -328,16 +329,16 @@ void shsFinal(shsInfo) lp = shsInfo->data + count / 4; switch (count % 4) { case 3: - *lp++ |= (LONG) 0x80; + *lp++ |= (SHS_LONG) 0x80; break; case 2: - *lp++ |= (LONG) 0x80 << 8; + *lp++ |= (SHS_LONG) 0x80 << 8; break; case 1: - *lp++ |= (LONG) 0x80 << 16; + *lp++ |= (SHS_LONG) 0x80 << 16; break; case 0: - *lp++ = (LONG) 0x80 << 24; + *lp++ = (SHS_LONG) 0x80 << 24; } /* at this point, lp can point *past* shsInfo->data. If it points |