From owner-freebsd-ports-bugs@FreeBSD.ORG Wed Jul 20 22:50:25 2005 Return-Path: X-Original-To: freebsd-ports-bugs@hub.freebsd.org Delivered-To: freebsd-ports-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 641E716A420 for ; Wed, 20 Jul 2005 22:50:25 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id BB16C43D58 for ; Wed, 20 Jul 2005 22:50:24 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.3/8.13.3) with ESMTP id j6KMoOgw084544 for ; Wed, 20 Jul 2005 22:50:24 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.3/8.13.1/Submit) id j6KMoORM084543; Wed, 20 Jul 2005 22:50:24 GMT (envelope-from gnats) Date: Wed, 20 Jul 2005 22:50:24 GMT Message-Id: <200507202250.j6KMoORM084543@freefall.freebsd.org> To: freebsd-ports-bugs@FreeBSD.org From: Vsevolod Stakhov Cc: Subject: Re: ports/76289: security/digest with sha256 output miss-match hash value. X-BeenThere: freebsd-ports-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Vsevolod Stakhov List-Id: Ports bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Jul 2005 22:50:25 -0000 The following reply was made to PR ports/76289; it has been noted by GNATS. From: Vsevolod Stakhov To: bug-followup@freebsd.org, morioka@openloop.co.jp, linimon@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.