From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6FF7AC2BA19 for ; Tue, 21 Apr 2020 09:20:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C728220857 for ; Tue, 21 Apr 2020 09:20:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=chronox.de header.i=@chronox.de header.b="ccuBKtj8" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726741AbgDUJUL (ORCPT ); Tue, 21 Apr 2020 05:20:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726600AbgDUJUK (ORCPT ); Tue, 21 Apr 2020 05:20:10 -0400 Received: from mo6-p00-ob.smtp.rzone.de (mo6-p00-ob.smtp.rzone.de [IPv6:2a01:238:20a:202:5300::10]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 66EDCC061A0F for ; Tue, 21 Apr 2020 02:20:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1587460806; s=strato-dkim-0002; d=chronox.de; h=References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: X-RZG-CLASS-ID:X-RZG-AUTH:From:Subject:Sender; bh=E9BJAvjzMhCklazXBZPYBfbuu7B+KuXrP8zNnSdB9RE=; b=ccuBKtj8J+wPD6HqtBK0lrHYVvwtapkbWBbRDGDh/X+1O6MeSksOf3hdmbAwhVteyB BrtU6hqE5DTbDUOmSbk9h9+JbTsFl19p2DhNHXxCEmdYg/Ante9SgpfW+0PnG72JeyM6 oSWdwaeAZuU00KEOMhx1Re/FuHFWEBygcfUafdnQL7j5m3e6hxlcLxWo8ItLk5IWmWMT /AiTNEeKNcMKMSw0MqBp66f2ek7PWBhRe7L+74eHTWErOKwIRje1xWlm07ADjNnShJzF 9/YB3i3yf4BnuJd6WbJfedeVdqjiM86KObEyF6GsJP5Y5364WXiArrCB39dHB8SUDmzJ aAHw== X-RZG-AUTH: ":P2ERcEykfu11Y98lp/T7+hdri+uKZK8TKWEqNyiHySGSa9k9xmwdNnzGHXPbJPSfZtvO" X-RZG-CLASS-ID: mo00 Received: from tauon.chronox.de by smtp.strato.de (RZmta 46.5.0 DYNA|AUTH) with ESMTPSA id c09283w3L9JbLgh (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits)) (Client did not present a certificate); Tue, 21 Apr 2020 11:19:37 +0200 (CEST) From: Stephan Mueller To: Ondrej =?utf-8?B?TW9zbsOhxI1law==?= Cc: linux-crypto@vger.kernel.org, Herbert Xu , Sahana Prasad , Tomas Mraz , Ard Biesheuvel Subject: Re: libkcapi tests are failing on kernels 5.5+ Date: Tue, 21 Apr 2020 11:19:36 +0200 Message-ID: <7154254.Uj1dk3xSE7@tauon.chronox.de> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="UTF-8" Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Am Dienstag, 21. April 2020, 10:08:14 CEST schrieb Ondrej Mosn=C3=A1=C4=8De= k: Hi Ondrej, > Hi all, >=20 > the libkcapi [1] tests are failing on kernels 5.5-rc1 and above [2]. > All encryption/decryption tests that use 'ctr(aes)' and a message size > that is not a multiple of 16 fail due to kcapi-enc returning different > output than expected. Confirmed. On the recent kernels, the data generated by kcapi-enc contains trailing ze= ro=20 bytes for data that is a fraction of the block size. I think the issue is in the following kernel code in _skcipher_recvmsg: unsigned int bs =3D crypto_skcipher_chunksize(tfm); /* * If more buffers are to be expected to be processed, process only * full block size buffers. */ if (ctx->more || len < ctx->used) len -=3D len % bs; The kernel truncates the size to be processed to the chunk size. As the=20 chunksize returns the block size of the underlying cipher (e.g. AES -> 16),= =20 the kernel code will not process non-aligned data. Herbert, could you help me identifying what exactly was the root cause for = the=20 patch 5b0fe9552336338acb52756daf65dd7a4eeca73f ? I.e. it seems that stream= =20 ciphers made out of a block cipher would not generate the data part that is= a=20 fraction of the block size (e.g. CTR, CTS). Ciao Stephan