Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1745485imu; Thu, 24 Jan 2019 00:51:22 -0800 (PST) X-Google-Smtp-Source: ALg8bN6z8MJNfTRyke1ccjZFa/ljcoxaUz3b7XpWbVbaxp9fO6niWALW9l2NrJkCCADpuQDBydhL X-Received: by 2002:a62:22d4:: with SMTP id p81mr5782407pfj.16.1548319882290; Thu, 24 Jan 2019 00:51:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548319882; cv=none; d=google.com; s=arc-20160816; b=O+nB4hwKjbMNCzwxzbCp9SI1ic5Ts5/UgC/Ej5JBvjryjM5pRN6QFt7tfoF/ypMQ+t V0M0/C0fY4FM+dTtCPJ8CkWltWFuw203gMf7Up1JvI8LOSTA+gE/eriQPJWvmYsfrRnR p9O7VRv94zFF+DcoFlYLO6aetKhtWP9W+9AtJy0dHNvubchN9OncTSXI0kciRWNnSQZI AZP1PxATJlaW8Zjfwr2hXnD3AYPsAf9pOPYQcpLgDoiUgqIuD0PqR8Gha7JhRZmkOAdL HKbp+Zj9bAFC96bc6gvjkKdxNyBcp2eik3pQXUtwMuCfhkE3B2E2UoDhvX25b+mBJFr8 Nyig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=NeBjmcEQcLSRm+PBEl/b4/noK4xPD3Qj1B0PIa4vfWw=; b=zZAniqpzCannFI21iT4b/RFIyb/dkM9CMDL15I3suqK3H0l3uKGLNzDvP6NIj16Jl+ VuFufoFWUfbP8WP6sqfXbOV1/N3noKJOTsdZxvSvNiXdfr+Qf9lnJbV1+I+udjNxsIeM CfqYJk16kTu35srGu0FKlJS6P/5XgmWYKVvA59LSeo09n2pCAjdVX5T/N6wZW2yH+EBt fchgefmz60vQ9CTChOIkB+M9C/pO9/TEFOG3+NCdL3Unz1sCQUMjs7gb0SUma03QlT+U vvbH5ocekVM+ketMtgIfQM4HSttajepmTMv1HbcWGMbnN3Z3ZgDInwoKt6HSpox8OutD tO0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=aLGX5agY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q10si20826911pll.221.2019.01.24.00.51.06; Thu, 24 Jan 2019 00:51:22 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=aLGX5agY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727296AbfAXIut (ORCPT + 99 others); Thu, 24 Jan 2019 03:50:49 -0500 Received: from mail-io1-f68.google.com ([209.85.166.68]:33858 "EHLO mail-io1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725290AbfAXIus (ORCPT ); Thu, 24 Jan 2019 03:50:48 -0500 Received: by mail-io1-f68.google.com with SMTP id b16so4075843ior.1 for ; Thu, 24 Jan 2019 00:50:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=NeBjmcEQcLSRm+PBEl/b4/noK4xPD3Qj1B0PIa4vfWw=; b=aLGX5agYRusyXEk6oDb8v/KMpTJhNpQXOZdc02EHn46194vIu0rsW+SkgjXxmulSFN zfnsy5PgHHF4EhpMYtSCRFuDkwmGvJ9Nlt1Zl6Y6qDVFx6K91ilKvxxA1GlI2Bt/oJJ4 Ojo7PIN4Hc6v7bAqwjqNe2FONEyo3G5JNAN9k= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=NeBjmcEQcLSRm+PBEl/b4/noK4xPD3Qj1B0PIa4vfWw=; b=HHbVjJcpllDOYJYQOnMAdKDm6jWNic3TFtbBhiIUGfSnIzbfj2UTQP+1jlHbA1rhNO CsdvsYE78UH/ZI/fyk3hrXsEa4MRJoTWJoKuifPJfBvkdDC+71Xwe1IiGgHRvOR71gcx GSIm3mMEzDYwNaJmzNGiEe7lSDx0g/yEVAscM4Ow0XC3HbojWXBUzpmSaD9W47ND7Dev +XY3/hPgkFpBxQQ2HmHkyjXqI5eq7aEOCNJSvUeGjsXAOxUoKlVDHzgume28ghhqPVBg f/Dip547q7KuQwArwDB9L9R4fPdDkHJy+7lpYaAnfyeZYAzk5P4Olv7hCnGR4jAN/iQH gLbg== X-Gm-Message-State: AHQUAubJhf735V3ZCiLTxBuHBitgjzjgJ4ZvqDeTOTU9dOkICdlAVa9R NxyHzTfuA3HyQ9dxqB8ZayDlrFQ784hI+r0pEWcupYYnky4= X-Received: by 2002:a5d:8410:: with SMTP id i16mr3303666ion.173.1548319847341; Thu, 24 Jan 2019 00:50:47 -0800 (PST) MIME-Version: 1.0 References: <20190123224926.250525-1-ebiggers@kernel.org> <20190124084818.GA650@sol.localdomain> In-Reply-To: <20190124084818.GA650@sol.localdomain> From: Ard Biesheuvel Date: Thu, 24 Jan 2019 09:50:35 +0100 Message-ID: Subject: Re: [RFC/RFT PATCH 00/15] crypto: improved skcipher, aead, and hash tests To: Eric Biggers Cc: "open list:HARDWARE RANDOM NUMBER GENERATOR CORE" , Linux Kernel Mailing List , Herbert Xu , "Jason A . Donenfeld" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 24 Jan 2019 at 09:48, Eric Biggers wrote: > > On Wed, Jan 23, 2019 at 02:49:11PM -0800, Eric Biggers wrote: > > Hello, > > > > Crypto algorithms must produce the same output for the same input > > regardless of data layout, i.e. how the src and dst scatterlists are > > divided into chunks and how each chunk is aligned. Request flags such > > as CRYPTO_TFM_REQ_MAY_SLEEP must not affect the result either. > > > > However, testing of this currently has many gaps. For example, > > individual algorithms are responsible for providing their own chunked > > test vectors. But many don't bother to do this or test only one or two > > cases, providing poor test coverage. Also, other things such as > > misaligned IVs and CRYPTO_TFM_REQ_MAY_SLEEP are never tested at all. > > > > Test code is also duplicated between the chunked and non-chunked cases, > > making it difficult to make other improvements. > > > > To improve the situation, this patch series basically moves the chunk > > descriptions into the testmgr itself so that they are shared by all > > algorithms. However, it's done in an extensible way via a new struct > > 'testvec_config', which describes not just the scaled chunk lengths but > > also all other aspects of the crypto operation besides the data itself > > such as the buffer alignments, the request flags, whether the operation > > is in-place or not, the IV alignment, and for hash algorithms when to do > > each update() and when to use finup() vs. final() vs. digest(). > > > > Then, this patch series makes skcipher, aead, and hash algorithms be > > tested against a list of default testvec_configs, replacing the current > > test code. This improves overall test coverage, without reducing test > > performance too much. Note that the test vectors themselves are not > > changed, except for removing the chunk lists. > > > > This series also adds randomized fuzz tests, enabled by a new kconfig > > option intended for developer use only, where skcipher, aead, and hash > > algorithms are tested against many randomly generated testvec_configs. > > This provides much more comprehensive test coverage. > > > > These improved tests have already found many bugs. Patches 1-7 fix the > > bugs found so far (*). However, I've only tested implementations that I > > can easily test. There will be more bugs found, especially in > > hardware-specific drivers. Anyone reading this can help by applying > > these patches on your system (especially if it's non-x86 and/or has > > crypto accelerators), enabling CONFIG_CRYPTO_MANAGER_EXTRA_TESTS, and > > reporting or fixing any test failures. > > On an arm64 system with the crypto extensions, crct10dif-arm64-ce and ccm-aes-ce > are failing too: > > [ 1.632623] alg: hash: crct10dif-arm64-ce test failed (wrong result) on test vector 0, cfg="init+update+update+final two even splits" > [ 15.377921] alg: aead: ccm-aes-ce decryption failed with err -74 on test vector 11, cfg="uneven misaligned splits, may sleep" > > Ard, I'll fix these when I have time but feel free to get to them first. > Hi Eric, Thanks for yet another round of cleanup I'll look into these, but I'd like to clarify one thing first. IIUC, you are trying to deal with the case where a single scatterlist element describes a range that strides two pages, and I wonder if that is a valid use of scatterlists in the first place. Herbert?