Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1544524imu; Wed, 16 Jan 2019 22:29:11 -0800 (PST) X-Google-Smtp-Source: ALg8bN55cwBJjjsob69Tq6mzE5xJ1YAj7QrUsAox3pLe2y/yJCX5ADOc7ImEkB4r82VKYlKmVj8t X-Received: by 2002:a63:8149:: with SMTP id t70mr12548033pgd.172.1547706551827; Wed, 16 Jan 2019 22:29:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547706551; cv=none; d=google.com; s=arc-20160816; b=EnyBeLM6F/LW400FbWeSZHsqZJE6+fF7NSWvwNSgJHaxLo+JLZE68zZTVZvK7Xg7Qn Txh879S/m6bimvY0dMXslWuIrC6kfJGZJ9zAmM//tBNHSOBFk15NPgx2lIc8mfBs8KTW BrAzLk/aL64k57SdrMlflNV3xNr7iGIoWOt4+ORfq4smb6KqfkKqz8S/P219a/r98bg5 3/1roithuStqBHsMTz/RQf5l86lg+rndTIh8uyPwQcRYzqKNKL9QmAWhjJnPu/0p99OC NWHo+FNdf+fiXHZgORUNN1c/DDNd4TGjY4Ehna/L4Tl654Aaiu2Rk0iemSNo7ECcfOJQ 3/JA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:content-id:mime-version :subject:cc:to:references:in-reply-to:from:organization; bh=GinGbaKQW3IdtIwnN12wE6mDh2bFhsX3GcK+RXeDKGA=; b=I3BUdStCUkI3pj655LHGjTOgSIv3gcsXlcqjVLhhrSSNsT2UBAPFQ52CrCQQQj8YHB 6otAG3ZAYW4JQHPxYDuLzgMHHs9gH99pj4GVbxhx9wofj/Q4B3qozpnV9DFEituIsGyJ VZBZiRmGE4LJuBSCl+VoBj3/MHweC8Icy2bVHu72EEXZWLqIv9hgPdqehKBkIgCsIriF K6w9PHjWx/RHu9JvZIav4yRzlzLfaLFsDYoeD0mNnGFskliwSRFZgtMobVTHw1CgAsK2 nBuUccG+pImjJdOuEtu+XlVW1ymbgunr/7pgfhQRD0x8g6MNKqD4Cew9kYjqdnQn4GTc 6lgA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n34si797706pld.381.2019.01.16.22.28.56; Wed, 16 Jan 2019 22:29:11 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405877AbfAPRM2 (ORCPT + 99 others); Wed, 16 Jan 2019 12:12:28 -0500 Received: from mx1.redhat.com ([209.132.183.28]:57004 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728878AbfAPRM1 (ORCPT ); Wed, 16 Jan 2019 12:12:27 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F40755C9; Wed, 16 Jan 2019 17:12:26 +0000 (UTC) Received: from warthog.procyon.org.uk (ovpn-120-244.rdu2.redhat.com [10.10.120.244]) by smtp.corp.redhat.com (Postfix) with ESMTP id B63405C228; Wed, 16 Jan 2019 17:12:21 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 From: David Howells In-Reply-To: <20190116164703.9267-1-vt@altlinux.org> References: <20190116164703.9267-1-vt@altlinux.org> To: Vitaly Chikunov Cc: dhowells@redhat.com, Tudor Ambarus , Herbert Xu , "David S. Miller" , Maxime Coquelin , Alexandre Torgue , =?UTF-8?q?Horia=20Geant=C4=83?= , Aymen Sghaier , Tom Lendacky , Gary Hook , Giovanni Cabiddu , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, keyrings@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, qat-linux@intel.com Subject: Re: [RFC PATCH v2] akcipher: Introduce verify_rsa/verify for public key algorithms MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <24886.1547658740.1@warthog.procyon.org.uk> Date: Wed, 16 Jan 2019 17:12:20 +0000 Message-ID: <24887.1547658740@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 16 Jan 2019 17:12:27 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Umm... What do I apply this patch to? In your modified public_key_verify_signature(): > - sg_init_one(&digest_sg, output, outlen); > - akcipher_request_set_crypt(req, &sig_sg, &digest_sg, sig->s_size, > + sg_init_one(&output_sg, output, outlen); > + akcipher_request_set_crypt(req, &sig_sg, &output_sg, sig->s_size, > outlen); Why is the output necessary? It was there for the decoded hash to be placed in prior to comparison - but now that's not necessary. > - ret = crypto_wait_req(crypto_akcipher_verify(req), &cwait); > + ret = crypto_wait_req(crypto_akcipher_verify(req, sig->digest, > + sig->digest_size), &cwait); I see sig->digest is passed in here. Should it be passed in in place of output_sg above? > - inst->alg.verify = pkcs1pad_verify; > + inst->alg.verify_rsa = pkcs1pad_verify; Is there a reason that pkcs1pad_verify() can't do the comparison? > - .verify = rsa_verify, > + .verify_rsa = rsa_verify, Likewise verify_rsa()? Granted, this might involve pkcs1pad_verify() dressing up the signature in the appropriate wrappings and passing it along to verify_rsa() to do the actual comparison there (ie. what pkcs1pad_verify_complete() does). > - .verify = caam_rsa_enc, > + .verify_rsa = caam_rsa_enc, I presume this is the reason - because this reuses its encrypt operation directly. But could this instead perform the comparison upon completion, say in rsa_pub_done()? > - .verify = qat_rsa_enc, > + .verify_rsa = qat_rsa_enc, Again, this could do the comparison, say, in qat_rsa_cb(). David