[ioquake3] 68/136: Fixed up some types in sha256.*

Simon McVittie smcv at debian.org
Thu Jun 15 09:09:10 UTC 2017


This is an automated email from the git hooks/post-receive script.

smcv pushed a commit to branch debian/master
in repository ioquake3.

commit a69020b21724fdd460120ab8d1e5764ce203dfd3
Author: Ryan C. Gordon <icculus at icculus.org>
Date:   Wed May 31 03:39:45 2017 -0400

    Fixed up some types in sha256.*
---
 code/autoupdater/sha256.c | 16 +++++++---------
 code/autoupdater/sha256.h | 24 ++++++++++++++++--------
 2 files changed, 23 insertions(+), 17 deletions(-)

diff --git a/code/autoupdater/sha256.c b/code/autoupdater/sha256.c
index eb9c5c0..0861860 100644
--- a/code/autoupdater/sha256.c
+++ b/code/autoupdater/sha256.c
@@ -29,7 +29,7 @@
 #define SIG1(x) (ROTRIGHT(x,17) ^ ROTRIGHT(x,19) ^ ((x) >> 10))
 
 /**************************** VARIABLES *****************************/
-static const WORD k[64] = {
+static const uint32 k[64] = {
 	0x428a2f98,0x71374491,0xb5c0fbcf,0xe9b5dba5,0x3956c25b,0x59f111f1,0x923f82a4,0xab1c5ed5,
 	0xd807aa98,0x12835b01,0x243185be,0x550c7dc3,0x72be5d74,0x80deb1fe,0x9bdc06a7,0xc19bf174,
 	0xe49b69c1,0xefbe4786,0x0fc19dc6,0x240ca1cc,0x2de92c6f,0x4a7484aa,0x5cb0a9dc,0x76f988da,
@@ -41,9 +41,9 @@ static const WORD k[64] = {
 };
 
 /*********************** FUNCTION DEFINITIONS ***********************/
-void sha256_transform(SHA256_CTX *ctx, const BYTE data[])
+void sha256_transform(SHA256_CTX *ctx, const uint8 data[])
 {
-	WORD a, b, c, d, e, f, g, h, i, j, t1, t2, m[64];
+	uint32 a, b, c, d, e, f, g, h, i, j, t1, t2, m[64];
 
 	for (i = 0, j = 0; i < 16; ++i, j += 4)
 		m[i] = (data[j] << 24) | (data[j + 1] << 16) | (data[j + 2] << 8) | (data[j + 3]);
@@ -96,9 +96,9 @@ void sha256_init(SHA256_CTX *ctx)
 	ctx->state[7] = 0x5be0cd19;
 }
 
-void sha256_update(SHA256_CTX *ctx, const BYTE data[], size_t len)
+void sha256_update(SHA256_CTX *ctx, const uint8 data[], size_t len)
 {
-	WORD i;
+	size_t i;
 
 	for (i = 0; i < len; ++i) {
 		ctx->data[ctx->datalen] = data[i];
@@ -111,11 +111,9 @@ void sha256_update(SHA256_CTX *ctx, const BYTE data[], size_t len)
 	}
 }
 
-void sha256_final(SHA256_CTX *ctx, BYTE hash[])
+void sha256_final(SHA256_CTX *ctx, uint8 hash[])
 {
-	WORD i;
-
-	i = ctx->datalen;
+	uint32 i = ctx->datalen;
 
 	// Pad whatever data is left in the buffer.
 	if (ctx->datalen < 56) {
diff --git a/code/autoupdater/sha256.h b/code/autoupdater/sha256.h
index 7123a30..fc9a09a 100644
--- a/code/autoupdater/sha256.h
+++ b/code/autoupdater/sha256.h
@@ -16,19 +16,27 @@
 #define SHA256_BLOCK_SIZE 32            // SHA256 outputs a 32 byte digest
 
 /**************************** DATA TYPES ****************************/
-typedef unsigned char BYTE;             // 8-bit byte
-typedef unsigned int  WORD;             // 32-bit word, change to "long" for 16-bit machines
+#ifdef _MSC_VER
+typedef unsigned __int8 uint8;
+typedef unsigned __int32 uint32;
+typedef unsigned __int64 uint64;
+#else
+#include <stdint.h>
+typedef uint8_t uint8;
+typedef uint32_t uint32;
+typedef uint64_t uint64;
+#endif
 
 typedef struct {
-	BYTE data[64];
-	WORD datalen;
-	unsigned long long bitlen;
-	WORD state[8];
+	uint8 data[64];
+	uint32 datalen;
+	uint64 bitlen;
+	uint32 state[8];
 } SHA256_CTX;
 
 /*********************** FUNCTION DECLARATIONS **********************/
 void sha256_init(SHA256_CTX *ctx);
-void sha256_update(SHA256_CTX *ctx, const BYTE data[], size_t len);
-void sha256_final(SHA256_CTX *ctx, BYTE hash[]);
+void sha256_update(SHA256_CTX *ctx, const uint8 data[], size_t len);
+void sha256_final(SHA256_CTX *ctx, uint8 hash[]);
 
 #endif   // SHA256_H

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/ioquake3.git



More information about the Pkg-games-commits mailing list