From owner-svn-src-stable-10@freebsd.org Mon Feb 27 21:07:45 2017 Return-Path: Delivered-To: svn-src-stable-10@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 D751ACEE326 for ; Mon, 27 Feb 2017 21:07:45 +0000 (UTC) (envelope-from 0100015a81666bf4-789e4f43-cbef-44e4-8a05-2fda5817223d-000000@amazonses.com) Received: from a8-56.smtp-out.amazonses.com (a8-56.smtp-out.amazonses.com [54.240.8.56]) (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 9C767BC9 for ; Mon, 27 Feb 2017 21:07:45 +0000 (UTC) (envelope-from 0100015a81666bf4-789e4f43-cbef-44e4-8a05-2fda5817223d-000000@amazonses.com) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=ae7m2yrxjw65l2cqdpjxuucyrvy564tn; d=tarsnap.com; t=1488229657; h=Subject:To:References:Cc:From:Message-ID:Date:MIME-Version:In-Reply-To:Content-Type:Content-Transfer-Encoding; bh=ug+jEsYIPhvDxpcreueQRI3XLnOiMpxh6gd4lc+iB7w=; b=er5G2w/t+gLUWGQU5PGkc7F/LVj9rLvxliwQUrguOtdaIzOK/uhqdqc1KsAIeT5T H/SAv4N8HHTTEtvMdml6EDu7d0TTBCgPdMrSK/TjmYeuqfonngsD8BXbABrGklttL9P XwJHT8R17oFAKVbBBbZk6UVx+Ec2Ebuu4QjXoHVc= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=6gbrjpgwjskckoa6a5zn6fwqkn67xbtw; d=amazonses.com; t=1488229657; 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=gejwxLlCI+4BIU0wMfUDx5PIAsKasZQZ2novUer4CbkusgTn3/BOpWdGgdbIVwwH pe1g5kUuaUzgjwtjXbPsvmPol1f2N3DBVB6OnK3zMq0KyVVOI71mtK+/cwVFc8XmS0U LBl9ake43QfiRm6k9wKa6WUR/FFAVax9Z5huWslk= 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: <0100015a81666bf4-789e4f43-cbef-44e4-8a05-2fda5817223d-000000@email.amazonses.com> Date: Mon, 27 Feb 2017 21:07:37 +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.56 Feedback-ID: 1.us-east-1.Lv9FVjaNvvR5llaqfLoOVbo2VxOELl7cjN0AOyXnPlk=:AmazonSES X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 27 Feb 2017 21:07:45 -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