Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1kODOU-0003WG-6z for mharc-grub-devel@gnu.org; Fri, 02 Oct 2020 01:14:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:32922) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kODOH-0003NG-D5 for grub-devel@gnu.org; Fri, 02 Oct 2020 01:13:59 -0400 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]:43973) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kODOF-00056E-Nl for grub-devel@gnu.org; Fri, 02 Oct 2020 01:13:57 -0400 Received: by mail-pf1-x441.google.com with SMTP id f18so437769pfa.10 for ; Thu, 01 Oct 2020 22:13:55 -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=iKB4K8MCv9bisW0Ms9CoxeWDyO86uoY0CzeUJpiXipk=; b=bZqekp+noU9kujI8k4WFKLTAT6SygxBFaLVgi2wISohtMpU2Pr6uJcfqus/P9A5xSV yQ43JNxdTPlm7fdobUFDpnNJH3QJiFyI5HL6mG8Zb3iJNfLJHuVv7w+sJQQiWAkLAXB/ LizQDGO3+5vTwS44Xkw742tar1IkHB8jr0ZvQ= 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=iKB4K8MCv9bisW0Ms9CoxeWDyO86uoY0CzeUJpiXipk=; b=D23u1sYgWUV7LWNGKKVSwkbDJm0HpWSjQUqk9+Jnkw/ySMBwkJdK5gbFbwVXCNZ+NY zQht4o8QMO7HkUDaIlQ6g1/ntYdoDOZKgs0ZovZG+NH1+MwL+rfzffvTTF/STVzGRV8M qAf4NsFuC44AC6+pmgNfX8osX9u4T/wqKoea4b+P6AQXWyQ3/xh0Cu6AvnzyMzbsxS8G Dqr6L7jzFy66wfQYjSgoo+QIROR11LRavg+yVKV5i7oNkmJUrdNzDRjBHTXGynAmPDz5 6KhsbQnCZwEGQ+pKHWzl8JAkYKTqbmTyUYLnN0KEzoFoGeRu6s0QAVLhaXItv8FMhLqU LVkA== X-Gm-Message-State: AOAM533t0d2bPyZsW2ypQQkRMRw9RlcqstG0mM6rDsRa21td9gBnHNhE IsopgS/Azia4sfxQSRiJCyqOQf8CjlcL8Q== X-Google-Smtp-Source: ABdhPJx5VkusOTzGQ4F84kipTBaq/iTJtQiuRGJqOnJnXvM7IGiTx9L5qA0R4Ve2uUY4kTqwPacMww== X-Received: by 2002:a62:10a:0:b029:142:2501:39e1 with SMTP id 10-20020a62010a0000b0290142250139e1mr750498pfb.48.1601615634321; Thu, 01 Oct 2020 22:13:54 -0700 (PDT) Received: from localhost (2001-44b8-111e-5c00-804e-30c2-4157-6268.static.ipv6.internode.on.net. [2001:44b8:111e:5c00:804e:30c2:4157:6268]) by smtp.gmail.com with ESMTPSA id z1sm353566pfq.102.2020.10.01.22.13.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Oct 2020 22:13:53 -0700 (PDT) From: Daniel Axtens To: grub-devel@gnu.org Cc: rashmica.g@gmail.com, alastair@d-silva.org, Daniel Axtens Subject: [PATCH 06/18] crypto: move storage for grub_crypto_pk_* to crypto.c Date: Fri, 2 Oct 2020 15:13:09 +1000 Message-Id: <20201002051321.1538488-7-dja@axtens.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201002051321.1538488-1-dja@axtens.net> References: <20201002051321.1538488-1-dja@axtens.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2607:f8b0:4864:20::441; envelope-from=dja@axtens.net; helo=mail-pf1-x441.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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: Fri, 02 Oct 2020 05:13:59 -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 2032afa4ec69..4e0667c1cd0f 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.25.1