From 3fb24d9ff612538dd25c91ce56db2ebdeb6c3c63 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Niels=20M=C3=B6ller?= <nisse@lysator.liu.se>
Date: Mon, 5 Jul 2010 21:46:03 +0200
Subject: [PATCH] (initial_ctx): Deleted status value. (blowfish_encrypt):
 Ignore status attribute. (blowfish_decrypt): Likewise. (blowfish_set_key):
 return result from weak key check, without setting the status attribute.

Rev: nettle/blowfish.c:1.2
---
 blowfish.c | 16 ----------------
 1 file changed, 16 deletions(-)

diff --git a/blowfish.c b/blowfish.c
index 3cfb76c3..b8f7ca58 100644
--- a/blowfish.c
+++ b/blowfish.c
@@ -230,8 +230,6 @@ initial_ctx =
     0x082EFA98,0xEC4E6C89,0x452821E6,0x38D01377,0xBE5466CF,0x34E90C6C,
     0xC0AC29B7,0xC97C50DD,0x3F84D5B5,0xB5470917,0x9216D5D9,0x8979FB1B
   },
-  /* Initial value, reset after key is checked. */
-  BLOWFISH_WEAK_KEY
 };
 
 /* It's unfortunate to have to pick the bytes apart in the round
@@ -318,8 +316,6 @@ blowfish_encrypt(struct blowfish_ctx *bc, unsigned length,
 {
     uint32_t d1, d2;
 
-    assert(!bc->status);
-
     FOR_BLOCKS(length, outbuf, inbuf, BLOWFISH_BLOCK_SIZE)
       {
 	d1 = READ_UINT32(inbuf);
@@ -339,8 +335,6 @@ blowfish_decrypt(struct blowfish_ctx *bc, unsigned length,
 {
     uint32_t d1, d2;
 
-    assert(!bc->status);
-
     FOR_BLOCKS(length, outbuf, inbuf, BLOWFISH_BLOCK_SIZE)
       {
 	d1 = READ_UINT32(inbuf);
@@ -360,15 +354,6 @@ blowfish_set_key(struct blowfish_ctx *ctx,
     int i, j;
     uint32_t data, datal, datar;
 
-#if 0
-    static int initialized = 0;
-
-    if( !initialized ) {
-	initialized = 1;
-	assert(selftest());
-    }
-#endif
-
     *ctx = initial_ctx;
 
     for(i=j=0; i < _BLOWFISH_ROUNDS+2; i++ )
@@ -420,6 +405,5 @@ blowfish_set_key(struct blowfish_ctx *ctx,
 	    (ctx->s[2][i] == ctx->s[2][j]) || (ctx->s[3][i] == ctx->s[3][j]) )
 	  return 0;
     
-    ctx->status = BLOWFISH_OK;
     return 1;
 }
-- 
GitLab