Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1nhRXs-0003IH-Be for mharc-grub-devel@gnu.org; Thu, 21 Apr 2022 03:48:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36536) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nhRXT-0003AQ-H3 for grub-devel@gnu.org; Thu, 21 Apr 2022 03:47:43 -0400 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]:35446) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nhRXS-0001Bw-0Z for grub-devel@gnu.org; Thu, 21 Apr 2022 03:47:43 -0400 Received: by mail-pl1-x634.google.com with SMTP id b7so4101172plh.2 for ; Thu, 21 Apr 2022 00:47:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axtens.net; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=NqhmSIYZcw9jJiTE3QkdTOkXV9UdGj1h70eHYc3irOE=; b=rIPuohrjdhl4swDINEVm8GQ7vGeaO4DjjZsa5AIa/K6+JIZX5eCYOJY1dooGkU+lbk nPDNcHdc0U4JbTYxqF0hKstIZIjPSOy0/+0gGIftBISXUV0YZQZa1Bk96GdX3ecfO4H+ hzlCaLEfHgcxVpswer6+FrW/cCMvJMsKJkNXc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NqhmSIYZcw9jJiTE3QkdTOkXV9UdGj1h70eHYc3irOE=; b=u/ctk9V5NV3vzSBUZgfs/635tcx3GUa8+PGXQggbSBQ1XCbDt2huNLrQwzG/oN5Wdf Rnruum1IzY7wgqoHwgzUE/nXILTnJdCgaVPANq63Eo+2hR/F+Qvx9M1BWj0EPuKsLpvw Gr5BashDzx+EfD7cN4xH0iTw/vG0i/tBws5zudKJMiW7cSJOgzxhmWNYLoWnifA3mPKQ F9bPcPQ7d8pjmfn+OgSEMJ+2OTEj70snLuvQMHMw0XEPDY0EE3G8FtdlmPrueHfKBLB7 s7tQl4VU10PuE5hZyq1CDSFX5zMy32L6N2H/FtcvQOrVwx/kctemqCJgLDEJbaC4bnzC GK9A== X-Gm-Message-State: AOAM533xUc2vQZZ2qaeonjWq2wWyuIgfS1GlWdgzK2nFxjAELU3UEeOP 3f5Z4gtbRLPcI1ThuL1YoVmAUG6mCQ2cPg== X-Google-Smtp-Source: ABdhPJx0IiM7FJFs01Sj86YpIMLMvLTB5wf4tXKW2q7DCHqQOCKZ3MGhCH28tb9PZmneQTAtS4iv6A== X-Received: by 2002:a17:902:bd05:b0:158:544d:6557 with SMTP id p5-20020a170902bd0500b00158544d6557mr24883704pls.70.1650527260501; Thu, 21 Apr 2022 00:47:40 -0700 (PDT) Received: from localhost ([2001:4479:e000:e400:4260:be14:52a8:8c94]) by smtp.gmail.com with ESMTPSA id n13-20020a654ccd000000b0039db6f73e9dsm22389470pgt.28.2022.04.21.00.47.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Apr 2022 00:47:40 -0700 (PDT) From: Daniel Axtens To: grub-devel@gnu.org Cc: rashmica.g@gmail.com, alastair@d-silva.org, nayna@linux.ibm.com, sudhakar@linux.ibm.com, Daniel Axtens , Stefan Berger Subject: [PATCH v3 06/19] crypto: move storage for grub_crypto_pk_* to crypto.c Date: Thu, 21 Apr 2022 17:47:01 +1000 Message-Id: <20220421074714.1561049-7-dja@axtens.net> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220421074714.1561049-1-dja@axtens.net> References: <20220421074714.1561049-1-dja@axtens.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2607:f8b0:4864:20::634; envelope-from=dja@axtens.net; helo=mail-pl1-x634.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Apr 2022 07:47:44 -0000 The way gcry_rsa and friends (the asymmetric ciphers) are loaded for the pgp module is a bit quirky. include/grub/crypto.h contains: extern struct gcry_pk_spec *grub_crypto_pk_rsa; commands/pgp.c contains the actual storage: struct gcry_pk_spec *grub_crypto_pk_rsa; And the module itself saves to the storage in pgp.c: GRUB_MOD_INIT(gcry_rsa) { grub_crypto_pk_rsa = &_gcry_pubkey_spec_rsa; } This is annoying: gcry_rsa now has a dependency on pgp! We want to be able to bring in gcry_rsa without bringing in PGP, so move the storage to crypto.c. Previously, gcry_rsa depended on pgp and mpi. Now it depends on crypto and mpi. As pgp depends on crypto, this doesn't add any new module dependencies using the PGP verfier. [FWIW, the story is different for the symmetric ciphers. cryptodisk and friends (zfs encryption etc) use grub_crypto_lookup_cipher_by_name() to get a cipher handle. That depends on grub_ciphers being populated by people calling grub_cipher_register. import_gcry.py ensures that the symmetric ciphers call it.] Signed-off-by: Daniel Axtens Reviewed-by: Stefan Berger --- grub-core/commands/pgp.c | 4 ---- grub-core/lib/crypto.c | 4 ++++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/grub-core/commands/pgp.c b/grub-core/commands/pgp.c index b084dc9a22f5..a45c2213c4ac 100644 --- a/grub-core/commands/pgp.c +++ b/grub-core/commands/pgp.c @@ -147,10 +147,6 @@ const char *hashes[] = { [0x0b] = "sha224" }; -struct gcry_pk_spec *grub_crypto_pk_dsa; -struct gcry_pk_spec *grub_crypto_pk_ecdsa; -struct gcry_pk_spec *grub_crypto_pk_rsa; - static int dsa_pad (gcry_mpi_t *hmpi, grub_uint8_t *hval, const gcry_md_spec_t *hash, struct grub_public_subkey *sk); diff --git a/grub-core/lib/crypto.c b/grub-core/lib/crypto.c index 396f7641080f..d53ddbe2c441 100644 --- a/grub-core/lib/crypto.c +++ b/grub-core/lib/crypto.c @@ -121,6 +121,10 @@ grub_md_unregister (gcry_md_spec_t *cipher) } } +struct gcry_pk_spec *grub_crypto_pk_dsa; +struct gcry_pk_spec *grub_crypto_pk_ecdsa; +struct gcry_pk_spec *grub_crypto_pk_rsa; + void grub_crypto_hash (const gcry_md_spec_t *hash, void *out, const void *in, grub_size_t inlen) -- 2.32.0