Commit df79080e by Adam Megacz Committed by Adam Megacz

shs.h, [...]: use uint<n>_t instead of LONG and BYTE

2002-02-06  Adam Megacz <adam@xwt.org>

        * shs.h, shs.cc, natSimpleSHSStream.cc: use uint<n>_t instead
        of LONG and BYTE

From-SVN: r49565
parent 4048d336
2002-02-06 Adam Megacz <adam@xwt.org> 2002-02-06 Adam Megacz <adam@xwt.org>
* shs.h, shs.cc, natSimpleSHSStream.cc: use uint<n>_t instead
of LONG and BYTE
2002-02-06 Adam Megacz <adam@xwt.org>
* name-finder.h: don't #include sys/wait.h unless HAVE_SYS_WAIT_H * name-finder.h: don't #include sys/wait.h unless HAVE_SYS_WAIT_H
2002-02-06 Anthony Green <green@redhat.com> 2002-02-06 Anthony Green <green@redhat.com>
......
...@@ -37,7 +37,7 @@ void ...@@ -37,7 +37,7 @@ void
gnu::gcj::io::SimpleSHSStream::shsUpdate (jbyteArray shs_info, jbyteArray buf, jint count) gnu::gcj::io::SimpleSHSStream::shsUpdate (jbyteArray shs_info, jbyteArray buf, jint count)
{ {
SHS_INFO *info = (SHS_INFO *)elements(shs_info); SHS_INFO *info = (SHS_INFO *)elements(shs_info);
BYTE *buffer = (BYTE *)elements(buf); uint8_t *buffer = (uint8_t *)elements(buf);
::shsUpdate (info, buffer, count); ::shsUpdate (info, buffer, count);
} }
......
...@@ -91,10 +91,10 @@ ...@@ -91,10 +91,10 @@
/* The two buffers of 5 32-bit words */ /* The two buffers of 5 32-bit words */
LONG h0, h1, h2, h3, h4; uint32_t h0, h1, h2, h3, h4;
LONG A, B, C, D, E; uint32_t A, B, C, D, E;
local void byteReverse OF((LONG *buffer, int byteCount)); local void byteReverse OF((uint32_t *buffer, int byteCount));
void shsTransform OF((SHS_INFO *shsInfo)); void shsTransform OF((SHS_INFO *shsInfo));
/* Initialize the SHS values */ /* Initialize the SHS values */
...@@ -120,7 +120,7 @@ void shsInit (SHS_INFO *shsInfo) ...@@ -120,7 +120,7 @@ void shsInit (SHS_INFO *shsInfo)
void shsTransform (SHS_INFO *shsInfo) void shsTransform (SHS_INFO *shsInfo)
{ {
LONG W [80], temp; uint32_t W [80], temp;
int i; int i;
/* Step A. Copy the data buffer into the local work buffer */ /* Step A. Copy the data buffer into the local work buffer */
...@@ -182,9 +182,9 @@ void shsTransform (SHS_INFO *shsInfo) ...@@ -182,9 +182,9 @@ void shsTransform (SHS_INFO *shsInfo)
shsInfo->digest [4] += E; shsInfo->digest [4] += E;
} }
local void byteReverse (LONG *buffer, int byteCount) local void byteReverse (uint32_t *buffer, int byteCount)
{ {
LONG value; uint32_t value;
int count; int count;
/* /*
...@@ -209,7 +209,7 @@ local void byteReverse (LONG *buffer, int byteCount) ...@@ -209,7 +209,7 @@ local void byteReverse (LONG *buffer, int byteCount)
if ((*(unsigned short *) ("@P") >> 8) == '@') if ((*(unsigned short *) ("@P") >> 8) == '@')
return; return;
byteCount /= sizeof (LONG); byteCount /= sizeof (uint32_t);
for (count = 0; count < byteCount; count++) { for (count = 0; count < byteCount; count++) {
value = (buffer [count] << 16) | (buffer [count] >> 16); value = (buffer [count] << 16) | (buffer [count] >> 16);
buffer [count] = ((value & 0xFF00FF00L) >> 8) | ((value & 0x00FF00FFL) << 8); buffer [count] = ((value & 0xFF00FF00L) >> 8) | ((value & 0x00FF00FFL) << 8);
...@@ -223,13 +223,13 @@ local void byteReverse (LONG *buffer, int byteCount) ...@@ -223,13 +223,13 @@ local void byteReverse (LONG *buffer, int byteCount)
* between calls to shsUpdate() * between calls to shsUpdate()
*/ */
void shsUpdate (SHS_INFO *shsInfo, BYTE *buffer, int count) void shsUpdate (SHS_INFO *shsInfo, uint8_t *buffer, int count)
{ {
/* Update bitcount */ /* Update bitcount */
if ((shsInfo->countLo + ((LONG) count << 3)) < shsInfo->countLo) if ((shsInfo->countLo + ((uint32_t) count << 3)) < shsInfo->countLo)
shsInfo->countHi++; /* Carry from low to high bitCount */ shsInfo->countHi++; /* Carry from low to high bitCount */
shsInfo->countLo += ((LONG) count << 3); shsInfo->countLo += ((uint32_t) count << 3);
shsInfo->countHi += ((LONG) count >> 29); shsInfo->countHi += ((uint32_t) count >> 29);
/* Process data in SHS_BLOCKSIZE chunks */ /* Process data in SHS_BLOCKSIZE chunks */
while (count >= SHS_BLOCKSIZE) { while (count >= SHS_BLOCKSIZE) {
...@@ -250,7 +250,7 @@ void shsUpdate (SHS_INFO *shsInfo, BYTE *buffer, int count) ...@@ -250,7 +250,7 @@ void shsUpdate (SHS_INFO *shsInfo, BYTE *buffer, int count)
void shsFinal (SHS_INFO *shsInfo) void shsFinal (SHS_INFO *shsInfo)
{ {
int count; int count;
LONG lowBitcount = shsInfo->countLo, highBitcount = shsInfo->countHi; uint32_t lowBitcount = shsInfo->countLo, highBitcount = shsInfo->countHi;
/* Compute number of bytes mod 64 */ /* Compute number of bytes mod 64 */
count = (int) ((shsInfo->countLo >> 3) & 0x3F); count = (int) ((shsInfo->countLo >> 3) & 0x3F);
...@@ -259,12 +259,12 @@ void shsFinal (SHS_INFO *shsInfo) ...@@ -259,12 +259,12 @@ void shsFinal (SHS_INFO *shsInfo)
* Set the first char of padding to 0x80. * Set the first char of padding to 0x80.
* This is safe since there is always at least one byte free * This is safe since there is always at least one byte free
*/ */
((BYTE *) shsInfo->data) [count++] = 0x80; ((uint8_t *) shsInfo->data) [count++] = 0x80;
/* Pad out to 56 mod 64 */ /* Pad out to 56 mod 64 */
if (count > 56) { if (count > 56) {
/* Two lots of padding: Pad the first block to 64 bytes */ /* Two lots of padding: Pad the first block to 64 bytes */
memset ((BYTE *) shsInfo->data + count, 0, 64 - count); memset ((uint8_t *) shsInfo->data + count, 0, 64 - count);
byteReverse (shsInfo->data, SHS_BLOCKSIZE); byteReverse (shsInfo->data, SHS_BLOCKSIZE);
shsTransform (shsInfo); shsTransform (shsInfo);
...@@ -272,7 +272,7 @@ void shsFinal (SHS_INFO *shsInfo) ...@@ -272,7 +272,7 @@ void shsFinal (SHS_INFO *shsInfo)
memset (shsInfo->data, 0, 56); memset (shsInfo->data, 0, 56);
} else } else
/* Pad block to 56 bytes */ /* Pad block to 56 bytes */
memset ((BYTE *) shsInfo->data + count, 0, 56 - count); memset ((uint8_t *) shsInfo->data + count, 0, 56 - count);
byteReverse (shsInfo->data, SHS_BLOCKSIZE); byteReverse (shsInfo->data, SHS_BLOCKSIZE);
/* Append length in bits and transform */ /* Append length in bits and transform */
......
...@@ -14,8 +14,14 @@ ...@@ -14,8 +14,14 @@
#ifndef SHS_H #ifndef SHS_H
#define SHS_H #define SHS_H
typedef unsigned char BYTE; #include<config.h>
typedef unsigned int LONG; /* A 32-bit type */ #if HAVE_INTTYPES_H
# include <inttypes.h>
#else
# if HAVE_STDINT_H
# include <stdint.h>
# endif
#endif
/* The SHS block size and message digest sizes, in bytes */ /* The SHS block size and message digest sizes, in bytes */
...@@ -25,9 +31,9 @@ typedef unsigned int LONG; /* A 32-bit type */ ...@@ -25,9 +31,9 @@ typedef unsigned int LONG; /* A 32-bit type */
/* The structure for storing SHS info */ /* The structure for storing SHS info */
typedef struct { typedef struct {
LONG digest [5]; /* Message digest */ uint32_t digest [5]; /* Message digest */
LONG countLo, countHi; /* 64-bit bit count */ uint32_t countLo, countHi; /* 64-bit bit count */
LONG data [16]; /* SHS data buffer */ uint32_t data [16]; /* SHS data buffer */
} SHS_INFO; } SHS_INFO;
/* Turn off prototypes if requested */ /* Turn off prototypes if requested */
...@@ -45,7 +51,7 @@ typedef struct { ...@@ -45,7 +51,7 @@ typedef struct {
#define local static #define local static
void shsInit OF((SHS_INFO *shsInfo)); void shsInit OF((SHS_INFO *shsInfo));
void shsUpdate OF((SHS_INFO *shsInfo, BYTE *buffer, int count)); void shsUpdate OF((SHS_INFO *shsInfo, uint8_t *buffer, int count));
void shsFinal OF((SHS_INFO *shsInfo)); void shsFinal OF((SHS_INFO *shsInfo));
#endif #endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment