Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1348545iob; Thu, 19 May 2022 04:57:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzncjfHlPwr885EEXamxLHt+b8YbbnTD5g+pxtplFrfFN7MqKAP2Sa7W7kjN1fN5l7seE5K X-Received: by 2002:a05:6402:5c9:b0:420:aac6:257b with SMTP id n9-20020a05640205c900b00420aac6257bmr4819280edx.128.1652961433368; Thu, 19 May 2022 04:57:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652961433; cv=none; d=google.com; s=arc-20160816; b=Lt+Ir6FSlo2+8Yl0XxdyktorhKQ3nQQTwmnTgUuD06JDbq4s03rbJBu0qXGayxiQQ+ HwcwiUF/QTgHto4mzQukWDQMPdJOqLadN/EK8TGXqcogSPiO22lI5zQV3+MWctfOrDQ6 L1LIYNVRDWAtWheBBhUi8AWSwUJe3Sp2eegazrqxjDEjr/WIkMTrAXEOsNdZUXNa+/DB AiQTQSB+QCFJ6pr31ir75ZEmtQb0DX1zzbyoAr6QuwLm4He986sTA5+dMtYSIecMDC60 8f9fquPkaqEovO8wKITXb55lK5LZIzJsdU2ch4l4OuMAWBmFomrPUlr7JJ0bDNBUp5km gH5g== 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:sender:dkim-signature; bh=VoByvcP7bL3erDKZ9eCF52S10ofQGaBH9DmhEc6wMHo=; b=Uxly2OA+IH7rjaC5GLEiwTlbd4M5oHzvtL88v018b8uzL7hskJ5jNmp4+8fZ/Gc2gi sQnWvuy5hkReT21wulP6GVh2CvcbNSb47yoZ2+Jp6btwXHBZsRXtBo+PVfQZGCjbPi0q dBFc9WFR/segnLdBNpFNzq1Xwou+LHbbu/22HI9YO/Y8u/8e6Hd5MN+GunwwOBwNhLXr a64n5uvDlhHvIwrsbr3T6+fUPWSi4EHkK1KksfrGnpJVyrl5F41bF8BvMePDARzZpjiC e0Y2BVtwr1oF+7XXMmK38raaMCNTaE8QaRYSsdM1HEYnHDurgulwyttIIx8kwLlqNIkj iC0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=o8phvVyt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-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 gk8-20020a17090790c800b006f3a9007c63si4002843ejb.946.2022.05.19.04.56.47; Thu, 19 May 2022 04:57:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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; dkim=pass header.i=@gmail.com header.s=20210112 header.b=o8phvVyt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233599AbiESGpp (ORCPT + 99 others); Thu, 19 May 2022 02:45:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229573AbiESGpl (ORCPT ); Thu, 19 May 2022 02:45:41 -0400 Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C73D94D9F3; Wed, 18 May 2022 23:45:39 -0700 (PDT) Received: by mail-ej1-x634.google.com with SMTP id n13so6109168ejv.1; Wed, 18 May 2022 23:45:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=VoByvcP7bL3erDKZ9eCF52S10ofQGaBH9DmhEc6wMHo=; b=o8phvVytMawY11PrJr5yMlH1aL6Pn8rQY9wZFrdDYSPBdSA2V4NdpDC84QfwzjZwYr 3esgMdEHOGv7ORU93HY591KCBfgicUeJCfIANLy/cl+HJeZyhX7+VxeX5lQw6/2f1gXi U/VWhwopUuKCyw9aco0y63LQIB0YeFmm5lUAxSHw8ELflVD4kAmkdGh0uPYRN3T0plBO H9LZco+FfksTH4qpXrHF647arG+fi1C56oMrVClhOFQBlIAI4wW66ggpgMEkm9+opho6 lw77XAw0lY46NIOaRMhNbJbgsprZY18tNqIDNctMV5bx3ikUAX2wO1iyTAoXLHnlk1dV W6LA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=VoByvcP7bL3erDKZ9eCF52S10ofQGaBH9DmhEc6wMHo=; b=PWMniPTEzhA68bFTQGysScwfhVG6RoUoCOpQr2MmfChrZt05FZHref/2YXAxJfj2Za AeMtSNV+DjeBw5BAAR1Immk3Yo7r692OqyDGMcw8+U+MeEmOvYOQTRIoz+mzjcMAw7lr 5Cvwn2JUulGk5HGhtV4YHC5hv6S0s6QTcFeqkqtAq2ZZ2apxGxNh7viI/o9aofcy1FWE E6NIy8pvU1W9/IBdziJISLChc2qCqMTGVIzPzHkiBVZFJVHpqLrfYVkydxrhjwetco3d RTXBWyhISHK1VhSmQC555Z70A/LELavcs4LRcrORJC7Dj0MnS0HJOYQNV+KU1e210RJO THhg== X-Gm-Message-State: AOAM532B24KLmbljH6YLmUPhzU8t1NnYX/Ly1SXOuV9XE6MbtMCM+ZrS JIUQDCanSy2bCTYpZM2pgMb2rGJvlItxwQ== X-Received: by 2002:a17:906:4ccc:b0:6fe:9155:47ae with SMTP id q12-20020a1709064ccc00b006fe915547aemr2754046ejt.246.1652942738312; Wed, 18 May 2022 23:45:38 -0700 (PDT) Received: from eldamar (c-82-192-242-114.customer.ggaweb.ch. [82.192.242.114]) by smtp.gmail.com with ESMTPSA id eo20-20020a1709069b1400b006f3ef214e58sm1739298ejc.190.2022.05.18.23.45.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 May 2022 23:45:37 -0700 (PDT) Sender: Salvatore Bonaccorso Date: Thu, 19 May 2022 08:45:36 +0200 From: Salvatore Bonaccorso To: Kees Cook Cc: David Howells , David Woodhouse , Eric Biggers , Shuah Khan , keyrings@vger.kernel.org, Adam Langley , Lee Jones , linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH v2] sign-file: Convert API usage to support OpenSSL v3 Message-ID: References: <20220518215129.264872-1-keescook@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220518215129.264872-1-keescook@chromium.org> X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Kees, On Wed, May 18, 2022 at 02:51:29PM -0700, Kees Cook wrote: > OpenSSL's ENGINE API is deprecated in OpenSSL v3.0, along with some > other functions. Remove the ENGINE use and a macro work-around for > ERR_get_error_line(). > > Cc: David Howells > Cc: David Woodhouse > Cc: Eric Biggers > Cc: Shuah Khan > Cc: Salvatore Bonaccorso > Cc: keyrings@vger.kernel.org > Suggested-by: Adam Langley > Co-developed-by: Lee Jones > Signed-off-by: Lee Jones > Signed-off-by: Kees Cook > --- > v1: https://lore.kernel.org/lkml/20211005161833.1522737-1-lee.jones@linaro.org/ > v2: https://lore.kernel.org/lkml/Yicwb+Ceiu8JjVIS@google.com/ > v3: > - Eliminate all the build warnings with OpenSSL 3 > - Fully remove ENGINE usage, if it can be optional, just drop it. > --- > scripts/sign-file.c | 49 ++++++++++----------------------------------- > 1 file changed, 11 insertions(+), 38 deletions(-) > > diff --git a/scripts/sign-file.c b/scripts/sign-file.c > index fbd34b8e8f57..2d633c5f57c3 100644 > --- a/scripts/sign-file.c > +++ b/scripts/sign-file.c > @@ -52,6 +52,10 @@ > #include > #endif > > +#if OPENSSL_VERSION_MAJOR >= 3 > +#define ERR_get_error_line(f, l) ERR_get_error_all(f, l, NULL, NULL, NULL) > +#endif > + > struct module_signature { > uint8_t algo; /* Public-key crypto algorithm [0] */ > uint8_t hash; /* Digest algorithm [0] */ > @@ -92,16 +96,6 @@ static void display_openssl_errors(int l) > } > } > > -static void drain_openssl_errors(void) > -{ > - const char *file; > - int line; > - > - if (ERR_peek_error() == 0) > - return; > - while (ERR_get_error_line(&file, &line)) {} > -} > - > #define ERR(cond, fmt, ...) \ > do { \ > bool __cond = (cond); \ > @@ -135,35 +129,14 @@ static int pem_pw_cb(char *buf, int len, int w, void *v) > static EVP_PKEY *read_private_key(const char *private_key_name) > { > EVP_PKEY *private_key; > + BIO *b; > > - if (!strncmp(private_key_name, "pkcs11:", 7)) { > - ENGINE *e; > - > - ENGINE_load_builtin_engines(); > - drain_openssl_errors(); > - e = ENGINE_by_id("pkcs11"); > - ERR(!e, "Load PKCS#11 ENGINE"); > - if (ENGINE_init(e)) > - drain_openssl_errors(); > - else > - ERR(1, "ENGINE_init"); > - if (key_pass) > - ERR(!ENGINE_ctrl_cmd_string(e, "PIN", key_pass, 0), > - "Set PKCS#11 PIN"); > - private_key = ENGINE_load_private_key(e, private_key_name, > - NULL, NULL); > - ERR(!private_key, "%s", private_key_name); > - } else { > - BIO *b; > - > - b = BIO_new_file(private_key_name, "rb"); > - ERR(!b, "%s", private_key_name); > - private_key = PEM_read_bio_PrivateKey(b, NULL, pem_pw_cb, > - NULL); > - ERR(!private_key, "%s", private_key_name); > - BIO_free(b); > - } > - > + b = BIO_new_file(private_key_name, "rb"); > + ERR(!b, "%s", private_key_name); > + private_key = PEM_read_bio_PrivateKey(b, NULL, pem_pw_cb, > + NULL); > + ERR(!private_key, "%s", private_key_name); > + BIO_free(b); > return private_key; > } Fixes for us as well the build warnings for sign-file.c (as you noted the other part is still in extract-cert.c). Tested-by: Salvatore Bonaccorso Regards, Salvatore