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=-13.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, UNWANTED_LANGUAGE_BODY,URIBL_BLOCKED autolearn=ham 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 6F8ADC433EF for ; Sat, 11 Sep 2021 14:26:01 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A1812611BF for ; Sat, 11 Sep 2021 14:26:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org A1812611BF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E88AA837F9; Sat, 11 Sep 2021 16:25:58 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="nS0D6JG2"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8FC74837F8; Sat, 11 Sep 2021 16:25:56 +0200 (CEST) Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 66607837F6 for ; Sat, 11 Sep 2021 16:25:53 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=ilias.apalodimas@linaro.org Received: by mail-wr1-x42f.google.com with SMTP id q26so7064312wrc.7 for ; Sat, 11 Sep 2021 07:25:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=wJAfVQktuKysgiuUFjPvbLRPbczahfJyaABSYw0p89w=; b=nS0D6JG2ah28+L0XghkuuDfrAc6q8/iNFM+qO05rRkr6B3dJ7dJBbiP1N1/l1NhYtD vEJXgYiJou3VtIR++Jptyj+6XB1KQ4NuZmQnwaLRqysE5FNxr52++xrzbZ4bdrEWBVKN xW7dQU7OPgE6f2MsUixT05TrVCFg2YuS2nP9n+2c3ec8go5Wa3NWZ2IqnalwAuza29/o D6MUqDh+/IpQ8tUOntlsuRBGkWOWEZOOvKPh/LXHx3Bcf/Wz0SAD4vSqwifZNyw70elo SJEmdMy9nSoHbpFd8iRbK4wvON+Rz2ESIL1R2cHCsIqUUHK60+BhdvWx2t6dvcd08NKr aobQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=wJAfVQktuKysgiuUFjPvbLRPbczahfJyaABSYw0p89w=; b=olPEWUsNbHGIECiS7Nnr0u5IqFMb8mMvyt0sZA+waKfAJUnPyiC1qy5D8ReDf9l14u ZOdatFF+QDrFNmxe8MvkVOKwGPTkHe7oYSchIV6FhxGbzx439kI0h9z8jo2JOx1zYhXq 59lWCbS20CePbjO4e/umLoot0wAqt/sYa2KnPGSoAcskwwrbWOuRLJdw+mkqZ2xWfD5H iHjZ41JBKiwJznpCst9EyGEpF7MG6ya7Sr5w47FBN99IAhCN93dRVlMNIODoW145vW9g VsuuQg+jWquYhHsTdN5kJv4gZw5hWsWc+pPlHODqYejsptoS0DnLfvCTGlCzZbqKFON0 VL6Q== X-Gm-Message-State: AOAM5335SGOaI3Q9H6S3nPZYZY4fFGKutI55/qcLIWniIjGKef052MYx cqiJyHB9w4ccy3l3tBgTcMbrDw== X-Google-Smtp-Source: ABdhPJzxwBSlmdKdTdNompRwRbO5OheZouYa+VKF2ugLmreXf2LlhyVJTVojPZKOD2ue1Em2w1mbmA== X-Received: by 2002:adf:ea90:: with SMTP id s16mr3369745wrm.235.1631370352987; Sat, 11 Sep 2021 07:25:52 -0700 (PDT) Received: from apalos.home (ppp-94-66-220-137.home.otenet.gr. [94.66.220.137]) by smtp.gmail.com with ESMTPSA id l15sm1633761wms.38.2021.09.11.07.25.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 Sep 2021 07:25:52 -0700 (PDT) Date: Sat, 11 Sep 2021 17:25:50 +0300 From: Ilias Apalodimas To: Heinrich Schuchardt Cc: u-boot@lists.denx.de, AKASHI Takahiro , Sughosh Ganu , Masahisa Kojima , Alexander Graf Subject: Re: [PATCH 3/4] efi_loader: simplify efi_sigstore_parse_sigdb() Message-ID: References: <20210911072832.16991-1-xypron.glpk@gmx.de> <20210911072832.16991-4-xypron.glpk@gmx.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210911072832.16991-4-xypron.glpk@gmx.de> X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean On Sat, Sep 11, 2021 at 09:28:31AM +0200, Heinrich Schuchardt wrote: > Simplify efi_sigstore_parse_sigdb() by using existing functions. > > Signed-off-by: Heinrich Schuchardt > --- > lib/efi_loader/efi_signature.c | 35 ++++++---------------------------- > 1 file changed, 6 insertions(+), 29 deletions(-) > > diff --git a/lib/efi_loader/efi_signature.c b/lib/efi_loader/efi_signature.c > index bdd09881fc..b741905a99 100644 > --- a/lib/efi_loader/efi_signature.c > +++ b/lib/efi_loader/efi_signature.c > @@ -7,6 +7,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -740,44 +741,20 @@ err: > */ > struct efi_signature_store *efi_sigstore_parse_sigdb(u16 *name) > { > - struct efi_signature_store *sigstore = NULL; > const efi_guid_t *vendor; > void *db; > efi_uintn_t db_size; > - efi_status_t ret; > > - if (!u16_strcmp(name, L"PK") || !u16_strcmp(name, L"KEK")) { > - vendor = &efi_global_variable_guid; > - } else if (!u16_strcmp(name, L"db") || !u16_strcmp(name, L"dbx")) { > - vendor = &efi_guid_image_security_database; > - } else { > + vendor = efi_auth_var_get_guid(name); > + if (!vendor) { > EFI_PRINT("unknown signature database, %ls\n", name); > return NULL; > } efi_auth_var_get_guid() will return &efi_global_variable_guid if the GUID for the variable name isn't found. > > - /* retrieve variable data */ > - db_size = 0; > - ret = EFI_CALL(efi_get_variable(name, vendor, NULL, &db_size, NULL)); > - if (ret == EFI_NOT_FOUND) { > - EFI_PRINT("variable, %ls, not found\n", name); > - sigstore = calloc(sizeof(*sigstore), 1); > - return sigstore; > - } else if (ret != EFI_BUFFER_TOO_SMALL) { > - EFI_PRINT("Getting variable, %ls, failed\n", name); > - return NULL; > - } > - > - db = malloc(db_size); > + db = efi_get_var(name, vendor, &db_size); > if (!db) { > - EFI_PRINT("Out of memory\n"); > - return NULL; > - } > - > - ret = EFI_CALL(efi_get_variable(name, vendor, NULL, &db_size, db)); > - if (ret != EFI_SUCCESS) { > - EFI_PRINT("Getting variable, %ls, failed\n", name); > - free(db); > - return NULL; > + EFI_PRINT("variable, %ls, not found\n", name); > + return calloc(sizeof(struct efi_signature_store), 1); > } > > return efi_build_signature_store(db, db_size); > -- > 2.30.2 >