From owner-svn-src-all@freebsd.org Mon Feb 27 15:15:17 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 282C5CF035D; Mon, 27 Feb 2017 15:15:17 +0000 (UTC) (envelope-from allanjude@FreeBSD.org) Received: from mx1.scaleengine.net (mx1.scaleengine.net [209.51.186.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0AD0794E; Mon, 27 Feb 2017 15:15:16 +0000 (UTC) (envelope-from allanjude@FreeBSD.org) Received: from [10.145.2.129] (unknown [209.171.88.129]) (Authenticated sender: allanjude.freebsd@scaleengine.com) by mx1.scaleengine.net (Postfix) with ESMTPSA id 98CB613480; Mon, 27 Feb 2017 15:15:12 +0000 (UTC) Date: Mon, 27 Feb 2017 07:15:07 -0800 User-Agent: K-9 Mail for Android In-Reply-To: References: <201702271305.v1RD5HOi077424@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: svn commit: r314335 - stable/10/sys/crypto/sha2 To: Ed Schouten , Andriy Gapon , cperciva@freebsd.org CC: src-committers , svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org From: Allan Jude Message-ID: X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 27 Feb 2017 15:15:17 -0000 On February 27, 2017 6:01:41 AM PST, Ed Schouten wrote: >Hi Andriy, > >2017-02-27 14:05 GMT+01:00 Andriy Gapon : >> +/* Message schedule computation */ >> +#define MSCH(W, ii, i) \ >> + W[i + ii + 16] =3D s1(W[i + ii + 14]) + W[i + ii + 9] + s0(W[i >+ ii + 1]) + W[i + ii] > >[snip] > >> uint32_t W[64]; > >[snip] > >> + for (i =3D 0; i < 64; i +=3D 16) { >> + RNDr(S, W, 1, i); >> + RNDr(S, W, 2, i); >> + RNDr(S, W, 3, i); >> + RNDr(S, W, 4, i); >> + RNDr(S, W, 5, i); >> + RNDr(S, W, 6, i); >> + RNDr(S, W, 7, i); >> + RNDr(S, W, 8, i); >> + RNDr(S, W, 9, i); >> + RNDr(S, W, 10, i); >> + RNDr(S, W, 11, i); >> + RNDr(S, W, 12, i); >> + RNDr(S, W, 13, i); >> + RNDr(S, W, 14, i); >> + RNDr(S, W, 15, i); >> + >> + if (i =3D=3D 48) >> + break; >> + MSCH(W, 0, i); >> + MSCH(W, 1, i); >> + MSCH(W, 2, i); >> + MSCH(W, 3, i); >> + MSCH(W, 4, i); >> + MSCH(W, 5, i); >> + MSCH(W, 6, i); >> + MSCH(W, 7, i); >> + MSCH(W, 8, i); >> + MSCH(W, 9, i); >> + MSCH(W, 10, i); >> + MSCH(W, 11, i); >> + MSCH(W, 12, i); >> + MSCH(W, 13, i); >> + MSCH(W, 14, i); >> + MSCH(W, 15, i); >> + } > >Something interesting that I noticed some time ago when comparing the >various SHA-{256,512} implementations: there is no need to store the >entire extended message in W=2E During every iteration of this loop, >RNDr() and MSCH() never go more than 16 elements back=2E > >Say, if you were to modify MSCH() to something like this: > >> +#define MSCH(W, ii) \ >> + W[ii] +=3D s1(W[(ii + 14) % 16]) + W[(ii + 9) % 16] + s0(W[(ii >+ 1)) % 16]) > >Then it will compute the next chunk of the extended message in-place=2E >RNDr() must then be adjusted to use W[i] instead of W[i + ii], of >course=2E W then only needs to hold 16 elements instead of 64 or 80=2E Add Colin, author of the original code --=20 Allan Jude