diff options
author | 1996-09-30 23:27:04 +0000 | |
---|---|---|
committer | 1996-09-30 23:27:04 +0000 | |
commit | ecda5c27aa6b19786341d8983cc9783aaa56812b (patch) | |
tree | 02d302ac2966603a7a2ec341f9bd4367d084968b /lib/libc/hash | |
parent | Fix byte order problem with sha1. (diff) | |
download | wireguard-openbsd-ecda5c27aa6b19786341d8983cc9783aaa56812b.tar.xz wireguard-openbsd-ecda5c27aa6b19786341d8983cc9783aaa56812b.zip |
export byte swapping routine.
Diffstat (limited to 'lib/libc/hash')
-rw-r--r-- | lib/libc/hash/sha1.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/lib/libc/hash/sha1.c b/lib/libc/hash/sha1.c index 5c90785a368..269a078f0fb 100644 --- a/lib/libc/hash/sha1.c +++ b/lib/libc/hash/sha1.c @@ -1,5 +1,5 @@ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: sha1.c,v 1.3 1996/09/30 04:01:30 millert Exp $"; +static char rcsid[] = "$OpenBSD: sha1.c,v 1.4 1996/09/30 23:27:05 millert Exp $"; #endif /* LIBC_SCCS and not lint */ /* @@ -206,7 +206,7 @@ void sha1Transform(sha1Info) makes for very slow code, so we rely on the user to sort out endianness at compile time */ -static void byteReverse(buffer, byteCount) +void sha1ByteReverse(buffer, byteCount) LONG *buffer; int byteCount; { @@ -243,7 +243,7 @@ void sha1Update(sha1Info, buffer, count) { memcpy( (void *) sha1Info->data, (void *) buffer, SHA1_BLOCKSIZE ); #if BYTE_ORDER == LITTLE_ENDIAN - byteReverse( sha1Info->data, SHA1_BLOCKSIZE ); + sha1ByteReverse( sha1Info->data, SHA1_BLOCKSIZE ); #endif /* LITTLE_ENDIAN */ sha1Transform( sha1Info ); buffer += SHA1_BLOCKSIZE; @@ -272,9 +272,9 @@ void sha1Final(sha1Info) if( count > 56 ) { /* Two lots of padding: Pad the first block to 64 bytes */ - memset( ( void * ) sha1Info->data + count, 0, 64 - count ); + memset( ( char * ) sha1Info->data + count, 0, 64 - count ); #if BYTE_ORDER == LITTLE_ENDIAN - byteReverse( sha1Info->data, SHA1_BLOCKSIZE ); + sha1ByteReverse( sha1Info->data, SHA1_BLOCKSIZE ); #endif /* LITTLE_ENDIAN */ sha1Transform( sha1Info ); @@ -283,9 +283,9 @@ void sha1Final(sha1Info) } else /* Pad block to 56 bytes */ - memset( ( void * ) sha1Info->data + count, 0, 56 - count ); + memset( ( char * ) sha1Info->data + count, 0, 56 - count ); #if BYTE_ORDER == LITTLE_ENDIAN - byteReverse( sha1Info->data, SHA1_BLOCKSIZE ); + sha1ByteReverse( sha1Info->data, SHA1_BLOCKSIZE ); #endif /* LITTLE_ENDIAN */ /* Append length in bits and transform */ @@ -294,7 +294,7 @@ void sha1Final(sha1Info) sha1Transform( sha1Info ); #if BYTE_ORDER == LITTLE_ENDIAN - byteReverse( sha1Info->data, SHA1_DIGESTSIZE ); + sha1ByteReverse( sha1Info->data, SHA1_DIGESTSIZE ); #endif /* LITTLE_ENDIAN */ } @@ -344,7 +344,7 @@ void main() /* Now perform time trial, generating MD for 10MB of data. First, initialize the test data */ - memset( data, 0, TEST_BLOCK_SIZE ); + memset( ( void * ) data, 0, TEST_BLOCK_SIZE ); /* Get start time */ printf( "SHA1 time trial. Processing %ld characters...\n", TEST_BYTES ); |