Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1lRF2c-00015G-NZ for mharc-grub-devel@gnu.org; Tue, 30 Mar 2021 10:08:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53270) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lRF2a-0000yw-6V for grub-devel@gnu.org; Tue, 30 Mar 2021 10:08:20 -0400 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]:34795) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lRF2Y-0004OM-Ew for grub-devel@gnu.org; Tue, 30 Mar 2021 10:08:19 -0400 Received: by mail-pl1-x62c.google.com with SMTP id o2so6225291plg.1 for ; Tue, 30 Mar 2021 07:08:18 -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=cyL3DusrJHePR3FTFAb2aqs95LK63lK4HlXn3jghy/Y=; b=n3BvHT1SdlEqtUm7b4dU2UgXHww7ooI7ZSldQa3agEYs3KNbWOqPNx0RHK0j1c7jJt 4AWyTvM28EK64+OGS3BLEidH9xx4s6zrYuAGcXv0iuucT0wRBexelMFApKvyz5Dq2T9U rpWVwbFrcqOuarRAcg/KEVbAz4kUeui7Y9oC8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cyL3DusrJHePR3FTFAb2aqs95LK63lK4HlXn3jghy/Y=; b=GeQMdsCnj+wMQr4ncqkNV62MOUaqlx+DEf47D9F7NmV5ZlaCIaQ9j0/tNtM2MkL3oi /2CCRgtyBN4jqVnCHbXy0WKbGsDYyjKBHLROIZQezcPVHwnFmcW2W0hPyURy6eTdE647 gqjMRtx65X8akVjh1Oj0GekCrJfDHErtBwbHsE7wRsUIz08bogf149it25xl8rspstwo mWOWv6M2nPnv0M44YfKyOMZjTq+rJF6z9FAxmthzsy8CLFjlsVjgNUEj5NItssC9BPYm lLQFz+EgC0Qvns64RTGlHh7dFC7VzxBqN19p79XRcHyeCkZlyqhxIn1WcqGYH/Zjwpnt PWoQ== X-Gm-Message-State: AOAM530oa1vRpzyRehPJ3MAeBZ+smUAHUbLE9PtXoasXY/Uh/AXdJQKe QOMR1lJIBK4Tcjgoow3+ZtbBQtWCI7Ahvg== X-Google-Smtp-Source: ABdhPJwgQP3BE49ng1u8MW0yUygO9CMw/fpAXU7o3eXkLCzTXzUZsBRqUr23jtnvnlik26B6JNIeZg== X-Received: by 2002:a17:90a:c087:: with SMTP id o7mr4529825pjs.38.1617113296868; Tue, 30 Mar 2021 07:08:16 -0700 (PDT) Received: from localhost (2001-44b8-111e-5c00-cc4e-3d4e-f51c-bb52.static.ipv6.internode.on.net. [2001:44b8:111e:5c00:cc4e:3d4e:f51c:bb52]) by smtp.gmail.com with ESMTPSA id x25sm5392512pfn.81.2021.03.30.07.08.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Mar 2021 07:08:16 -0700 (PDT) From: Daniel Axtens To: grub-devel@gnu.org Cc: rashmica.g@gmail.com, alastair@d-silva.org, Daniel Axtens Subject: [PATCH 06/19] crypto: move storage for grub_crypto_pk_* to crypto.c Date: Wed, 31 Mar 2021 01:07:31 +1100 Message-Id: <20210330140744.176698-7-dja@axtens.net> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210330140744.176698-1-dja@axtens.net> References: <20210330140744.176698-1-dja@axtens.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2607:f8b0:4864:20::62c; envelope-from=dja@axtens.net; helo=mail-pl1-x62c.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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Mar 2021 14:08:20 -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 --- 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 2408db4994f6..355a43844acc 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 ca334d5a40e0..c578128a59db 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.27.0