From owner-svn-src-all@freebsd.org Mon Feb 27 21:12:01 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 7C5EACEE3A2 for ; Mon, 27 Feb 2017 21:12:01 +0000 (UTC) (envelope-from 0100015a8166758f-6cf526bf-b390-40d6-afce-0d8a3b72b248-000000@amazonses.com) Received: from a8-13.smtp-out.amazonses.com (a8-13.smtp-out.amazonses.com [54.240.8.13]) (using TLSv1 with cipher ECDHE-RSA-AES128-SHA (128/128 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 41C17DEA for ; Mon, 27 Feb 2017 21:12:00 +0000 (UTC) (envelope-from 0100015a8166758f-6cf526bf-b390-40d6-afce-0d8a3b72b248-000000@amazonses.com) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=ae7m2yrxjw65l2cqdpjxuucyrvy564tn; d=tarsnap.com; t=1488229660; h=Subject:To:References:Cc:From:Message-ID:Date:MIME-Version:In-Reply-To:Content-Type:Content-Transfer-Encoding; bh=ug+jEsYIPhvDxpcreueQRI3XLnOiMpxh6gd4lc+iB7w=; b=Hzm8LrFwTDsqe/8PSZqhv8lDyfvzs2aryPFQfo3A7tN+bSfgfpbcHVMiYDtOw3uq ZW0tDXi9fgEmQN4R4VkZ+tFZmwJkXEFyI2G+b/jb3gHsG3rAu4yi1jQqTVbggQbzBao WAUA0Cvxnq+wuxF4j1CMNJl/BRJup8GZnlwkUs3Y= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=6gbrjpgwjskckoa6a5zn6fwqkn67xbtw; d=amazonses.com; t=1488229660; h=Subject:To:References:Cc:From:Message-ID:Date:MIME-Version:In-Reply-To:Content-Type:Content-Transfer-Encoding:Feedback-ID; bh=ug+jEsYIPhvDxpcreueQRI3XLnOiMpxh6gd4lc+iB7w=; b=fNRzGskv2LPOpW3Nt/K0mqQSLQXdOupx1c8R029qB6rXJlvHHlcqJkuQDqUbjbvF U3mZeZYe/Tg5TpJ37mRHIpJ99zXXLzMUieQN08dDf2xjI7bxp8eOl17Hcvo9NbJhv3G By6xatWR78zxFyVbIJGviqAhl+vGC0thcctWxAQo= Subject: Re: svn commit: r314335 - stable/10/sys/crypto/sha2 To: Ed Schouten , Andriy Gapon References: <201702271305.v1RD5HOi077424@repo.freebsd.org> Cc: src-committers , svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org From: Colin Percival Message-ID: <0100015a8166758f-6cf526bf-b390-40d6-afce-0d8a3b72b248-000000@email.amazonses.com> Date: Mon, 27 Feb 2017 21:07:40 +0000 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SES-Outgoing: 2017.02.27-54.240.8.13 Feedback-ID: 1.us-east-1.Lv9FVjaNvvR5llaqfLoOVbo2VxOELl7cjN0AOyXnPlk=:AmazonSES 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 21:12:01 -0000 On 02/27/17 06:01, Ed Schouten wrote: > 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. During every iteration of this loop, > RNDr() and MSCH() never go more than 16 elements back. > > Say, if you were to modify MSCH() to something like this: > >> +#define MSCH(W, ii) \ >> + W[ii] += 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. > RNDr() must then be adjusted to use W[i] instead of W[i + ii], of > course. W then only needs to hold 16 elements instead of 64 or 80. I tried this, and it was slower. The larger array avoids write-after-read accesses and results in better code being emitted due to more flexible instruction scheduling. -- Colin Percival Security Officer Emeritus, FreeBSD | The power to serve Founder, Tarsnap | www.tarsnap.com | Online backups for the truly paranoid