Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp590492rdb; Fri, 6 Oct 2023 12:16:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGURQkvvtDVj4t2OHtLEkjqT86OLObZEbyJOjemY+vjbNso2UJaCFw6tSph3wl6CBO7zhhr X-Received: by 2002:a05:6a20:3d90:b0:15e:10e:12f3 with SMTP id s16-20020a056a203d9000b0015e010e12f3mr10616467pzi.0.1696619759658; Fri, 06 Oct 2023 12:15:59 -0700 (PDT) Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id eg7-20020a056a00800700b0069344f0eda3si2095356pfb.5.2023.10.06.12.15.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Oct 2023 12:15:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=QH8XumAe; arc=fail (signature failed); spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 94C6F806BF1F; Fri, 6 Oct 2023 12:15:34 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233308AbjJFTPa (ORCPT + 99 others); Fri, 6 Oct 2023 15:15:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231163AbjJFTP2 (ORCPT ); Fri, 6 Oct 2023 15:15:28 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4CCEE83; Fri, 6 Oct 2023 12:15:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1696619724; x=1728155724; h=date:from:to:cc:subject:message-id:references: in-reply-to:mime-version; bh=6kTkDjmUs95JUZZvjE9nSrNmnIaweUp/UvO956WBMVw=; b=QH8XumAe7ADSf61uekHhVfTM56KmdRYLv80GYeOUnFTRtPb9tfFesbGJ 4gp6zgq3YNHirEQ3S/cuK9Ma70p7nBYcT2QOYxqX6aT/IHtiMcM/10jxi lKoP73Re1T8WeNdndxsDn4vKcqwLn6124cHzZ4dvBAP0rTI9tFAmxjBKu l4R0F4xYAyK6PY8gGWeraQV6swnTtBoy0nCxsrZzJcSjKEy94WjxNeeCl +HnL3rx/r7g5DKQo2f2XENQ60Yj1dqk3SSSKKrI6uodz+nUKPrPr4zjE4 qs2CgmRfphye9W8bqJhkdFEjSxgzMQguQkg98jaqMSbt8L6hl55KfJL/Q Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10855"; a="382681035" X-IronPort-AV: E=Sophos;i="6.03,204,1694761200"; d="scan'208";a="382681035" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Oct 2023 12:15:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10855"; a="752283814" X-IronPort-AV: E=Sophos;i="6.03,204,1694761200"; d="scan'208";a="752283814" Received: from orsmsx603.amr.corp.intel.com ([10.22.229.16]) by orsmga002.jf.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 06 Oct 2023 12:15:23 -0700 Received: from orsmsx611.amr.corp.intel.com (10.22.229.24) by ORSMSX603.amr.corp.intel.com (10.22.229.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.32; Fri, 6 Oct 2023 12:15:23 -0700 Received: from orsmsx601.amr.corp.intel.com (10.22.229.14) by ORSMSX611.amr.corp.intel.com (10.22.229.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.32; Fri, 6 Oct 2023 12:15:22 -0700 Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) by orsmsx601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.32 via Frontend Transport; Fri, 6 Oct 2023 12:15:22 -0700 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (104.47.55.106) by edgegateway.intel.com (134.134.137.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.32; Fri, 6 Oct 2023 12:15:22 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TArxPudIKNDKjMkhWwHTX+ffPc894vkbjxQsXbtg94PRqEWZT2EHBHeDW2GewhBo3LcdCBHp2qVVLTj3ZA+HCzJ2Ayx+JcnNaTvNim8FqbhCU1RsKfCNhkzBaeeVJDvRdqe7GhpVj9uBreUcMavRyZLDYJF9CSLE5RXJTshEGY3vs6VidlZiWMd4BzmF3zyWQKqQlNi8HHiUb3onaCrHekXNAXCZwcxvosmgWZ/FN/tAljJHY+QAycfKdA3bRPSu/ZxE2rEsOLb1Pmgt5yuK3thlT3gcoBrSkewUmGemgH4+OplQU4vz59d/Q4t+JL67quFE1yCD51EYjL7FTfDVdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=VcKyCTe9/LsTEe7b0uJdHVXuYp7vUXGx/YB4h4FOz18=; b=GiKVVj8tu6kiO3MwggatuB3lvQttM1EmskUaNkWQCJMuRjR1ZSt1YR7P1Aj/g31elDqY4AT5acs3HyV9+rpbz6FeCZdi4wkB7Bl5escmDU3GZMS/VGlDeg4h5XTmwjWjWo3UMFNE8buR7qQN+k5Py1AaOwTFycAgL0HiHfXjD1WR/1GmbbUJKcUQKYhXfnjw3PLr/rjZluTgzJiVJQRq1LiM7aj5FTi53fOGtXuePScbvAGHu0g8qgco3h6O61X1RU1h9NuZyZLHY7Yj0eAQsT/2OtRWnLaNEbKwe8iHu81/mtySoEh7UAXNeUkUYvqd2lg/nF4KbDqfuLKcyc52Mw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from PH8PR11MB8107.namprd11.prod.outlook.com (2603:10b6:510:256::6) by CH3PR11MB8341.namprd11.prod.outlook.com (2603:10b6:610:178::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.28; Fri, 6 Oct 2023 19:15:19 +0000 Received: from PH8PR11MB8107.namprd11.prod.outlook.com ([fe80::acb0:6bd3:58a:c992]) by PH8PR11MB8107.namprd11.prod.outlook.com ([fe80::acb0:6bd3:58a:c992%5]) with mapi id 15.20.6838.033; Fri, 6 Oct 2023 19:15:19 +0000 Date: Fri, 6 Oct 2023 12:15:13 -0700 From: Dan Williams To: Lukas Wunner , Bjorn Helgaas , "David Howells" , David Woodhouse , Herbert Xu , "David S. Miller" , Alex Williamson , , , , , , CC: Jonathan Cameron , , David Box , Dan Williams , Dave Jiang , "Li, Ming" , Zhi Wang , Alistair Francis , "Wilfred Mallawa" , Alexey Kardashevskiy , "Tom Lendacky" , Sean Christopherson , Alexander Graf Subject: RE: [PATCH 03/12] X.509: Move certificate length retrieval into new helper Message-ID: <65205cc1c1f40_ae7e72949d@dwillia2-xfh.jf.intel.com.notmuch> References: <16c06528d13b2c0081229a45cacd4b1b9cdff738.1695921657.git.lukas@wunner.de> Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <16c06528d13b2c0081229a45cacd4b1b9cdff738.1695921657.git.lukas@wunner.de> X-ClientProxiedBy: DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) To PH8PR11MB8107.namprd11.prod.outlook.com (2603:10b6:510:256::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH8PR11MB8107:EE_|CH3PR11MB8341:EE_ X-MS-Office365-Filtering-Correlation-Id: 43a062e0-b42c-4e6d-6add-08dbc6a094b8 X-LD-Processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TqXnXyUcQksuTQgcHHLdRLa+JEmi6iOQwUI7HTFrIi/k3nu0a7HIUdy0RfROBHYiwwntf4oqnhQHKVsa3PWyFE00kfiP+SxsNDiUuSk9WcpnUdm+b/mcjwrP0q4VNRKwT0ji4uGhPIP23S+Sqou/DXDjDFUJT5VG17/WQPnslbUZyp3ycN8R+KfDS+VkP2EFBjxYwenWO5Oy2MQ9SKYwbWavcEf7TbBlRLaixc01USx6Tax1u2sLjkJrsVgkRlbJPuAQ7SPd034sC1jC0tTWq0dJSZme+Hc7H3J2ENQhYhzfjLiZC7tk5gugohNSKT6Hzu2x+bHQbjMQ+Dbni2hZ+LTHp6sIqvbQX4J/SGlfXxWVm4utqQx7H/lCsqyIhpYo3hr2caA1+KbzS8kf5GWTx3BLgVIZAhMzzunTtXgPrwg0Of+DkjWDJQnDut+M1q+BLDzhM4nwAY1DIW5g3Dvu8/T82yaqpIxAMrlc4ngkKKtsAyTmOelHEOETqTpussjwrMtyPe6XE48+Xw8ecXKW4U/2THfUhF0UFDWlCrk45MZxCT1UlV1eCFt8psoLtZwoa1FM/hKIUY1Hi27ZVfHmPl5lDvdtvK8svVibgse1pz8= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH8PR11MB8107.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(39860400002)(376002)(366004)(396003)(346002)(136003)(230922051799003)(1800799009)(186009)(64100799003)(451199024)(2906002)(83380400001)(26005)(38100700002)(82960400001)(86362001)(921005)(6666004)(316002)(41300700001)(8676002)(8936002)(4326008)(966005)(6486002)(5660300002)(110136005)(66946007)(7416002)(54906003)(66476007)(66556008)(478600001)(9686003)(6512007)(6506007);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?U5tG5jtgezDgejBJZB6ex1yumkhE+t7cH5w4Iir/0/paU3ZFsccDFxVXD9jG?= =?us-ascii?Q?6z9iy0vh9RPAjeWWGGpiec6Pmrsjh2mTW118oF4JJ4zZ74ntpWHbCIYot7QQ?= =?us-ascii?Q?VldSt98vSwgU6sEBO2oN+CmVrNX6nb5epUEBXospiQonmxadG4wWXYR9LnU9?= =?us-ascii?Q?muFjxtyrg1qXg/PSdlzUQFXxssf59WOoOVetbkhQjvRPVN9XLD4WeiF8/2DL?= =?us-ascii?Q?G/UthE7ZES8tQapYuxt/VBxL+jwD/zzhIbQOcdZY3HUz4JaUFIKBCeQJzrGK?= =?us-ascii?Q?QsWgXcSd+fsMcsKYfTf2RJw+mFCqRcTOmF90V4qSBKYOz6fB89et82RuOC0e?= =?us-ascii?Q?15jQd4A3blmGQdgpM7xqOMAdtSsnMBCjgByNbmI2464KUt+yPwcI/U6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Jgfjpaap8aRt1coS0N9AzsBFnmkqNpHq+vUj308k28C?= =?us-ascii?Q?zN+JxpZhJHHNj88rkwbi9K0hAPORuk9DeCE8G8Rkxj+dj33C0PO4Oi6jIRQA?= =?us-ascii?Q?PYv/IzeWAqhV8AwqIkF3X6jST7DZNqylRftxHCkhEveyygtTRP7kAsqT0BFR?= =?us-ascii?Q?co3TeHycC8z2BHOhvCM8rc/Krbc7NYAE3Cqse+N/VeeVBKOBJWvBFnPP7nPW?= =?us-ascii?Q?zzavxwkDI0bBdH2NovTw97wA/hovr1I06KfFijTKBOiqMheolmUojxiczEbX?= =?us-ascii?Q?lmN4MF9d1PHcWdGv9fyjYqZ3XDCAprB2HFZPsVS1ck9lL4mP9x9PbM9uRi/l?= =?us-ascii?Q?zg=3D=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: 43a062e0-b42c-4e6d-6add-08dbc6a094b8 X-MS-Exchange-CrossTenant-AuthSource: PH8PR11MB8107.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Oct 2023 19:15:19.6656 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: GL7QzQ+k8EqidABpoPBX8WX3w+fP7BvbWKcnVyrrGqQtKPWxfuc68AgN7CpBEePscU0jEKCgSZMOI1RtG7JOoR5Zc+8zDFnkYb6ebw9KODs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR11MB8341 X-OriginatorOrg: intel.com X-Spam-Status: No, score=2.7 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Fri, 06 Oct 2023 12:15:34 -0700 (PDT) X-Spam-Level: ** Lukas Wunner wrote: > The upcoming in-kernel SPDM library (Security Protocol and Data Model, > https://www.dmtf.org/dsp/DSP0274) needs to retrieve the length from > ASN.1 DER-encoded X.509 certificates. > > Such code already exists in x509_load_certificate_list(), so move it > into a new helper for reuse by SPDM. > > No functional change intended. > > Signed-off-by: Lukas Wunner > --- > crypto/asymmetric_keys/x509_loader.c | 38 +++++++++++++++++++--------- > include/keys/asymmetric-type.h | 2 ++ > 2 files changed, 28 insertions(+), 12 deletions(-) > > diff --git a/crypto/asymmetric_keys/x509_loader.c b/crypto/asymmetric_keys/x509_loader.c > index a41741326998..121460a0de46 100644 > --- a/crypto/asymmetric_keys/x509_loader.c > +++ b/crypto/asymmetric_keys/x509_loader.c > @@ -4,28 +4,42 @@ > #include > #include > > +int x509_get_certificate_length(const u8 *p, unsigned long buflen) > +{ > + int plen; > + > + /* Each cert begins with an ASN.1 SEQUENCE tag and must be more > + * than 256 bytes in size. > + */ > + if (buflen < 4) > + return -EINVAL; > + > + if (p[0] != 0x30 && > + p[1] != 0x82) > + return -EINVAL; > + > + plen = (p[2] << 8) | p[3]; > + plen += 4; > + if (plen > buflen) > + return -EINVAL; > + > + return plen; > +} > +EXPORT_SYMBOL_GPL(x509_get_certificate_length); Given CONFIG_PCI is a bool, is the export needed? Maybe save this export until the modular consumer arrives, or identify the modular consumer in the changelog? Other than that: Reviewed-by: Dan Williams