Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2471431rwd; Wed, 14 Jun 2023 03:23:43 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6khabA2+YBjoLWEU/ami9aJ/r67HKSnCYveiwwberzcsffFa0Rlt1yiVEPljj+bPFVeaL3 X-Received: by 2002:a05:6a20:a108:b0:111:77cf:96dd with SMTP id q8-20020a056a20a10800b0011177cf96ddmr18497185pzk.5.1686738223273; Wed, 14 Jun 2023 03:23:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686738223; cv=none; d=google.com; s=arc-20160816; b=BNdUjX/onuvCw80pbWKcwstvkfBGjD6Ke216fR3tSaaTST/cr22fHO4NM3XtZzxOp0 D6+8iEgWK74RvUYoQLgxgUmbX3B8ex3pykNek2JzCKUKXQCM2j9CtoUGE4KOTi819j0t EZcjoRzYM+QyEUNXTaZSPmAH0X0hHvMUGB0JkZ/JoOi2+sqkwtgfSh0UupWneHpP7qzL GSJn3ia7Bv8YIJ1dsAuKRTLWTzLy5qbOOulpuoAGUo9/0wlzkkM2u/dpeNWbl0FhL5hy LEZCHf3vIho0q2A4V39+Zpp1bkkBG1BxzEAzJ6uxwz1tups8WZFAkWNLwVIwIIIN2dDh mAVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=ZNYSd8uOhcCkSJAl03+k1KnicghZrkBQAzEtMuNG1eY=; b=WhQqx6nfI/hlc7I6rTfAAOvrEq1LTMsLKrLEB1sexTSrKJIz++vmJrZP/0WAHxpgWk uxATgihuQydz118GvAI1STrn4zzrYoUShJDyoMTmMbD9XnxW1RejzfFplv3ERnTapX9l S8DQ9g/6WGJ5BrImWGvUtZorpjbmGYc+X+8pl6ZB3Sx7WhX/DnKm18m0LHbB2qnxlXgW eyC0PrSnAFKNT1EmF33diQ8aA1NF/QJ2grgMO4UlKzsARj27hcxTzbeymcKDlFbRRDWi HdsiE8nUdEeyGL5qUwD0cwHpUMzEsMoyX5LYZW4x2kMX6A1hNtL5jNtUx3EIJtAE8bu6 RKMw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b19-20020aa79513000000b0065bede9ac7fsi10723708pfp.210.2023.06.14.03.23.30; Wed, 14 Jun 2023 03:23:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235785AbjFNKMy (ORCPT + 99 others); Wed, 14 Jun 2023 06:12:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234949AbjFNKMx (ORCPT ); Wed, 14 Jun 2023 06:12:53 -0400 Received: from 167-179-156-38.a7b39c.syd.nbn.aussiebb.net (167-179-156-38.a7b39c.syd.nbn.aussiebb.net [167.179.156.38]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 215C3E5; Wed, 14 Jun 2023 03:12:52 -0700 (PDT) Received: from loth.rohan.me.apana.org.au ([192.168.167.2]) by formenos.hmeau.com with smtp (Exim 4.94.2 #2 (Debian)) id 1q9NUO-002pFU-DZ; Wed, 14 Jun 2023 18:12:33 +0800 Received: by loth.rohan.me.apana.org.au (sSMTP sendmail emulation); Wed, 14 Jun 2023 18:12:32 +0800 Date: Wed, 14 Jun 2023 18:12:32 +0800 From: Herbert Xu To: David Howells Cc: Linus Torvalds , Roberto Sassu , Eric Biggers , Stefan Berger , Mimi Zohar , dmitry.kasatkin@gmail.com, Jarkko Sakkinen , Ard Biesheuvel , keyrings@vger.kernel.org, Linux Crypto Mailing List Subject: Re: [PATCH 4/5] KEYS: asymmetric: Move sm2 code into x509_public_key Message-ID: References: <570724.1686660603@warthog.procyon.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <570724.1686660603@warthog.procyon.org.uk> X-Spam-Status: No, score=2.7 required=5.0 tests=BAYES_00,HELO_DYNAMIC_IPADDR2, PDS_RDNS_DYNAMIC_FP,RDNS_DYNAMIC,SPF_HELO_NONE,SPF_PASS,TVD_RCVD_IP, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: ** X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Tue, Jun 13, 2023 at 01:50:03PM +0100, David Howells wrote: > Herbert Xu wrote: > > > +#include > > +#include > > +#include > > +#include > > +#include > > #include > > #include > > #include > > -#include > > -#include > > -#include > > -#include > > +#include > > Why rearrage the order? Why not leave the linux/ headers first? Then the > keys/ and then the crypto/. The standard under the crypto directory is that header files are sorted alphabetically. > > + if (strcmp(cert->pub->pkey_algo, "sm2") == 0) { > > + ret = strcmp(sig->hash_algo, "sm3") != 0 ? -EINVAL : > > + crypto_shash_init(desc) ?: > > + sm2_compute_z_digest(desc, cert->pub->key, > > + cert->pub->keylen, sig->digest) ?: > > + crypto_shash_init(desc) ?: > > + crypto_shash_update(desc, sig->digest, > > + sig->digest_size) ?: > > + crypto_shash_finup(desc, cert->tbs, cert->tbs_size, > > + sig->digest); > > Ewww... That's really quite hard to comprehend at a glance. :-) > > Should sm2_compute_z_digest() be something accessible through the crypto hooks > rather than being called directly? Yes that would be lovely but I don't have anything concrete to offer as this is the only algorithm that requires it. > > > + } else > > "} else {" please. OK. Thanks, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt