Commit deb9aec0ed9d35eb102e20075b4b3d4bbe42c91c

Con Kolivas 2012-12-24T12:54:09

Remove the unused sha224 functions.

diff --git a/cgminer.c b/cgminer.c
index e0acbe5..2c74531 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -1345,8 +1345,8 @@ static void calc_midstate(struct work *work)
 	for (swapcounter = 0; swapcounter < 16; swapcounter++)
 		data.i[swapcounter] = swab32(((uint32_t*) (work->data))[swapcounter]);
 	sha2_context ctx;
-	sha2_starts( &ctx, 0 );
-	sha2_update( &ctx, data.c, 64 );
+	sha2_starts(&ctx);
+	sha2_update(&ctx, data.c, 64);
 	memcpy(work->midstate, ctx.state, sizeof(work->midstate));
 #if defined(__BIG_ENDIAN__) || defined(MIPSEB)
 	int i;
@@ -2156,8 +2156,8 @@ bool regeneratehash(const struct work *work)
 	for (i = 0; i < 80 / 4; i++)
 		swap32[i] = swab32(data32[i]);
 
-	sha2(swap, 80, hash1, false);
-	sha2(hash1, 32, (unsigned char *)(work->hash), false);
+	sha2(swap, 80, hash1);
+	sha2(hash1, 32, (unsigned char *)(work->hash));
 
 	difficulty = swab32(*((uint32_t *)(work->data + 72)));
 
@@ -4951,8 +4951,8 @@ static void gen_hash(unsigned char *data, unsigned char *hash, int len)
 {
 	unsigned char hash1[32];
 
-	sha2(data, len, hash1, false);
-	sha2(hash1, 32, hash, false);
+	sha2(data, len, hash1);
+	sha2(hash1, 32, hash);
 }
 
 /* Diff 1 is a 256 bit unsigned integer of
@@ -5132,8 +5132,8 @@ static bool hashtest(struct thr_info *thr, struct work *work)
 	bool ret = false;
 
 	flip80(swap32, data32);
-	sha2(swap, 80, hash1, false);
-	sha2(hash1, 32, hash2, false);
+	sha2(swap, 80, hash1);
+	sha2(hash1, 32, hash2);
 	flip32(work->hash, hash2_32);
 
 	/* Flipped or not, hash2_32[7] should be 0 */
diff --git a/driver-ztex.c b/driver-ztex.c
index ba3e7bb..23aa97e 100644
--- a/driver-ztex.c
+++ b/driver-ztex.c
@@ -171,8 +171,8 @@ static bool ztex_checkNonce(struct libztex_device *ztex,
 	for (i = 0; i < 80 / 4; i++)
 		swap32[i] = swab32(data32[i]);
 
-	sha2(swap, 80, hash1, false);
-	sha2(hash1, 32, hash2, false);
+	sha2(swap, 80, hash1);
+	sha2(hash1, 32, hash2);
 #if defined(__BIGENDIAN__) || defined(MIPSEB)
 	if (hash2_32[7] != ((hdata->hash7 + 0x5be0cd19) & 0xFFFFFFFF)) {
 #else
diff --git a/sha2.c b/sha2.c
index caad666..55a1b35 100644
--- a/sha2.c
+++ b/sha2.c
@@ -60,37 +60,19 @@
 /*
  * SHA-256 context setup
  */
-void sha2_starts( sha2_context *ctx, int is224 )
+void sha2_starts( sha2_context *ctx )
 {
     ctx->total[0] = 0;
     ctx->total[1] = 0;
 
-    if( is224 == 0 )
-    {
-        /* SHA-256 */
-        ctx->state[0] = 0x6A09E667;
-        ctx->state[1] = 0xBB67AE85;
-        ctx->state[2] = 0x3C6EF372;
-        ctx->state[3] = 0xA54FF53A;
-        ctx->state[4] = 0x510E527F;
-        ctx->state[5] = 0x9B05688C;
-        ctx->state[6] = 0x1F83D9AB;
-        ctx->state[7] = 0x5BE0CD19;
-    }
-    else
-    {
-        /* SHA-224 */
-        ctx->state[0] = 0xC1059ED8;
-        ctx->state[1] = 0x367CD507;
-        ctx->state[2] = 0x3070DD17;
-        ctx->state[3] = 0xF70E5939;
-        ctx->state[4] = 0xFFC00B31;
-        ctx->state[5] = 0x68581511;
-        ctx->state[6] = 0x64F98FA7;
-        ctx->state[7] = 0xBEFA4FA4;
-    }
-
-    ctx->is224 = is224;
+    ctx->state[0] = 0x6A09E667;
+    ctx->state[1] = 0xBB67AE85;
+    ctx->state[2] = 0x3C6EF372;
+    ctx->state[3] = 0xA54FF53A;
+    ctx->state[4] = 0x510E527F;
+    ctx->state[5] = 0x9B05688C;
+    ctx->state[6] = 0x1F83D9AB;
+    ctx->state[7] = 0x5BE0CD19;
 }
 
 static void sha2_process( sha2_context *ctx, const unsigned char data[64] )
@@ -306,19 +288,18 @@ void sha2_finish( sha2_context *ctx, unsigned char output[32] )
     PUT_ULONG_BE( ctx->state[5], output, 20 );
     PUT_ULONG_BE( ctx->state[6], output, 24 );
 
-    if( ctx->is224 == 0 )
-        PUT_ULONG_BE( ctx->state[7], output, 28 );
+    PUT_ULONG_BE( ctx->state[7], output, 28 );
 }
 
 /*
  * output = SHA-256( input buffer )
  */
 void sha2( const unsigned char *input, int ilen,
-           unsigned char output[32], int is224 )
+           unsigned char output[32] )
 {
     sha2_context ctx;
 
-    sha2_starts( &ctx, is224 );
+    sha2_starts( &ctx );
     sha2_update( &ctx, input, ilen );
     sha2_finish( &ctx, output );
 
diff --git a/sha2.h b/sha2.h
index e7299de..ec5142f 100644
--- a/sha2.h
+++ b/sha2.h
@@ -39,7 +39,6 @@ typedef struct
 
     unsigned char ipad[64];     /*!< HMAC: inner padding        */
     unsigned char opad[64];     /*!< HMAC: outer padding        */
-    int is224;                  /*!< 0 => SHA-256, else SHA-224 */
 }
 sha2_context;
 
@@ -51,9 +50,8 @@ extern "C" {
  * \brief          SHA-256 context setup
  *
  * \param ctx      context to be initialized
- * \param is224    0 = use SHA256, 1 = use SHA224
  */
-void sha2_starts( sha2_context *ctx, int is224 );
+void sha2_starts( sha2_context *ctx);
 
 /**
  * \brief          SHA-256 process buffer
@@ -68,7 +66,7 @@ void sha2_update( sha2_context *ctx, const unsigned char *input, int ilen );
  * \brief          SHA-256 final digest
  *
  * \param ctx      SHA-256 context
- * \param output   SHA-224/256 checksum result
+ * \param output   SHA-256 checksum result
  */
 void sha2_finish( sha2_context *ctx, unsigned char output[32] );
 
@@ -77,11 +75,10 @@ void sha2_finish( sha2_context *ctx, unsigned char output[32] );
  *
  * \param input    buffer holding the  data
  * \param ilen     length of the input data
- * \param output   SHA-224/256 checksum result
- * \param is224    0 = use SHA256, 1 = use SHA224
+ * \param output   SHA-256 checksum result
  */
 void sha2( const unsigned char *input, int ilen,
-           unsigned char output[32], int is224 );
+           unsigned char output[32]);
 
 #ifdef __cplusplus
 }