Note that this corrupts the shsInfo->data area */
-static void SHSTransform KRB5_PROTOTYPE((LONG *digest, LONG *data));
+static void SHSTransform KRB5_PROTOTYPE((SHS_LONG *digest, SHS_LONG *data));
static
void SHSTransform(digest, data)
- LONG *digest;
- LONG *data;
+ SHS_LONG *digest;
+ 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 ];
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;
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++ << ((3 - 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++;
+ *lp = (SHS_LONG) *buffer++ << 24;
+ *lp |= (SHS_LONG) *buffer++ << 16;
+ *lp |= (SHS_LONG) *buffer++ << 8;
+ *lp++ |= (SHS_LONG) *buffer++;
if ((count -= 4) < 4 && lp < shsInfo->data + 16) {
*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;
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;
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;
}
}
}
SHS_INFO *shsInfo;
{
int count;
- LONG *lp;
+ SHS_LONG *lp;
/* Compute number of bytes mod 64 */
count = (int) shsInfo->countLo;
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
/* Some useful types */
-typedef krb5_octet BYTE;
-
-/* Old DOS/Windows compilers are case-insensitive */
-#if !defined(_MSDOS) && !defined(_WIN32)
-typedef krb5_ui_4 LONG;
-#endif
-
+typedef krb5_octet SHS_BYTE;
+typedef krb5_ui_4 SHS_LONG;
/* Define the following to use the updated SHS implementation */
#define NEW_SHS /**/
/* The structure for storing SHS info */
typedef struct {
- LONG digest[ 5 ]; /* Message digest */
- LONG countLo, countHi; /* 64-bit bit count */
- LONG data[ 16 ]; /* SHS data buffer */
+ SHS_LONG digest[ 5 ]; /* Message digest */
+ SHS_LONG countLo, countHi; /* 64-bit bit count */
+ SHS_LONG data[ 16 ]; /* SHS data buffer */
} SHS_INFO;
/* Message digest functions (shs.c) */
void shsInit(SHS_INFO *shsInfo);
-void shsUpdate(SHS_INFO *shsInfo, BYTE *buffer, int count);
+void shsUpdate(SHS_INFO *shsInfo, SHS_BYTE *buffer, int count);
void shsFinal(SHS_INFO *shsInfo);
#ifdef NEW_SHS
-static LONG shsTestResults[][ 5 ] = {
+static SHS_LONG shsTestResults[][ 5 ] = {
{ 0xA9993E36L, 0x4706816AL, 0xBA3E2571L, 0x7850C26CL, 0x9CD0D89DL, },
{ 0x84983E44L, 0x1C3BD26EL, 0xBAAE4AA1L, 0xF95129E5L, 0xE54670F1L, },
{ 0x34AA973CL, 0xD4C4DAA4L, 0xF61EEB2BL, 0xDBAD2731L, 0x6534016FL, }
#else
-static LONG shsTestResults[][ 5 ] = {
+static SHS_LONG shsTestResults[][ 5 ] = {
{ 0x0164B8A9L, 0x14CD2A5EL, 0x74C4F7FFL, 0x082C4D97L, 0xF1EDF880L },
{ 0xD2516EE1L, 0xACFA5BAFL, 0x33DFC1C4L, 0x71E43844L, 0x9EF134C8L },
{ 0x3232AFFAL, 0x48628A26L, 0x653B5AAAL, 0x44541FD9L, 0x0D690603L }
unsigned int i;
#if 0
time_t secondCount;
- BYTE data[ 200 ];
+ SHS_BYTE data[ 200 ];
#endif
/* Make sure we've got the endianness set right. If the machine is
/* Test SHS against values given in SHS standards document */
printf( "Running SHS test 1 ... " );
shsInit( &shsInfo );
- shsUpdate( &shsInfo, ( BYTE * ) "abc", 3 );
+ shsUpdate( &shsInfo, ( SHS_BYTE * ) "abc", 3 );
shsFinal( &shsInfo );
if( compareSHSresults( &shsInfo, 0 ) == -1 )
{
printf( "Running SHS test 2 ... " );
shsInit( &shsInfo );
- shsUpdate( &shsInfo, ( BYTE * ) "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", 56 );
+ shsUpdate( &shsInfo, ( SHS_BYTE * ) "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", 56 );
shsFinal( &shsInfo );
if( compareSHSresults( &shsInfo, 1 ) == -1 )
{
printf( "Running SHS test 3 ... " );
shsInit( &shsInfo );
for( i = 0; i < 15625; i++ )
- shsUpdate( &shsInfo, ( BYTE * ) "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 64 );
+ shsUpdate( &shsInfo, ( SHS_BYTE * ) "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 64 );
shsFinal( &shsInfo );
if( compareSHSresults( &shsInfo, 2 ) == -1 )
{