ports/76289: security/digest with sha256 output miss-match hash value.

Vsevolod Stakhov vsevolod at highsecure.ru
Wed Jul 20 22:50:25 UTC 2005


The following reply was made to PR ports/76289; it has been noted by GNATS.

From: Vsevolod Stakhov <vsevolod at highsecure.ru>
To: bug-followup at freebsd.org, morioka at openloop.co.jp, linimon at freebsd.org
Cc:  
Subject: Re: ports/76289: security/digest with sha256 output miss-match hash value.
Date: Thu, 21 Jul 2005 02:44:55 +0400

 I've inspected the problem and prepared a patch:
 
 --- begin of patch-sha2.c ---
 --- sha2.c.orig	Thu Jul 21 00:39:56 2005
 +++ sha2.c	Thu Jul 21 02:30:00 2005
 @@ -588,7 +588,7 @@
  			/* Begin padding with a 1 bit: */
  			context->buffer[usedspace++] = 0x80;
  
 -			if (usedspace < SHA256_SHORT_BLOCK_LENGTH) {
 +			if (usedspace <= SHA256_SHORT_BLOCK_LENGTH) {
  				/* Set-up for the last transform: */
  				MEMSET_BZERO(&context->buffer[usedspace], SHA256_SHORT_BLOCK_LENGTH - usedspace);
  			} else {
 --- end of patch-sha2.c ---
 
 Please place it to files dir and rebuild port. Seems working for me.
 Result of tests:
 
 # echo -n aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa > /tmp/rnd
 #wc -c /tmp/rnd
       55 /tmp/rnd
 SHA256 (/tmp/rnd) = 9f4390f8d30c2dd92ec9f095b65e2b9ae9b0a925a5258e241c9f1e910f734318
 
 #echo -n aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa > /tmp/rnd
 #wc -c /tmp/rnd
       54 /tmp/rnd
 #digest sha256 /tmp/rnd
 SHA256 (/tmp/rnd) = a3f01b6939256127582ac8ae9fb47a382a244680806a3f613a118851c1ca1d47
 
 
 #echo -n aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab > /tmp/rnd
 #wc -c /tmp/rnd
       56 /tmp/rnd
 #digest sha256 /tmp/rnd
 SHA256 (/tmp/rnd) = 771c8bf33bbaea2ebc52d77cbd010185bc7ec53a0a44860cf8d3e352cebc446
 
 
 I've checked results with other sha256 implementation and results are equal.
 



More information about the freebsd-ports-bugs mailing list