Blame SOURCES/0160-crypto-move-storage-for-grub_crypto_pk_-to-crypto.c.patch

5593c8
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
5593c8
From: Daniel Axtens <dja@axtens.net>
5593c8
Date: Fri, 2 Oct 2020 10:49:26 +1000
5593c8
Subject: [PATCH] crypto: move storage for grub_crypto_pk_* to crypto.c
5593c8
5593c8
The way gcry_rsa and friends (the asymmetric ciphers) are loaded for the
5593c8
pgp module is a bit quirky.
5593c8
5593c8
include/grub/crypto.h contains:
5593c8
  extern struct gcry_pk_spec *grub_crypto_pk_rsa;
5593c8
5593c8
commands/pgp.c contains the actual storage:
5593c8
  struct gcry_pk_spec *grub_crypto_pk_rsa;
5593c8
5593c8
And the module itself saves to the storage in pgp.c:
5593c8
  GRUB_MOD_INIT(gcry_rsa)
5593c8
  {
5593c8
    grub_crypto_pk_rsa = &_gcry_pubkey_spec_rsa;
5593c8
  }
5593c8
5593c8
This is annoying: gcry_rsa now has a dependency on pgp!
5593c8
5593c8
We want to be able to bring in gcry_rsa without bringing in PGP,
5593c8
so move the storage to crypto.c.
5593c8
5593c8
Previously, gcry_rsa depended on pgp and mpi. Now it depends on
5593c8
crypto and mpi. As pgp depends on crypto, this doesn't add any new
5593c8
module dependencies using the PGP verfier.
5593c8
5593c8
[FWIW, the story is different for the symmetric ciphers. cryptodisk
5593c8
and friends (zfs encryption etc) use grub_crypto_lookup_cipher_by_name()
5593c8
to get a cipher handle. That depends on grub_ciphers being populated
5593c8
by people calling grub_cipher_register. import_gcry.py ensures that the
5593c8
symmetric ciphers call it.]
5593c8
5593c8
Signed-off-by: Daniel Axtens <dja@axtens.net>
5593c8
---
5593c8
 grub-core/commands/pgp.c | 4 ----
5593c8
 grub-core/lib/crypto.c   | 4 ++++
5593c8
 2 files changed, 4 insertions(+), 4 deletions(-)
5593c8
5593c8
diff --git a/grub-core/commands/pgp.c b/grub-core/commands/pgp.c
fd0330
index 2408db4994..355a43844a 100644
5593c8
--- a/grub-core/commands/pgp.c
5593c8
+++ b/grub-core/commands/pgp.c
5593c8
@@ -147,10 +147,6 @@ const char *hashes[] = {
5593c8
   [0x0b] = "sha224"
5593c8
 };
5593c8
 
5593c8
-struct gcry_pk_spec *grub_crypto_pk_dsa;
5593c8
-struct gcry_pk_spec *grub_crypto_pk_ecdsa;
5593c8
-struct gcry_pk_spec *grub_crypto_pk_rsa;
5593c8
-
5593c8
 static int
5593c8
 dsa_pad (gcry_mpi_t *hmpi, grub_uint8_t *hval,
5593c8
 	 const gcry_md_spec_t *hash, struct grub_public_subkey *sk);
5593c8
diff --git a/grub-core/lib/crypto.c b/grub-core/lib/crypto.c
fd0330
index ca334d5a40..c578128a59 100644
5593c8
--- a/grub-core/lib/crypto.c
5593c8
+++ b/grub-core/lib/crypto.c
5593c8
@@ -121,6 +121,10 @@ grub_md_unregister (gcry_md_spec_t *cipher)
5593c8
       }
5593c8
 }
5593c8
 
5593c8
+struct gcry_pk_spec *grub_crypto_pk_dsa;
5593c8
+struct gcry_pk_spec *grub_crypto_pk_ecdsa;
5593c8
+struct gcry_pk_spec *grub_crypto_pk_rsa;
5593c8
+
5593c8
 void
5593c8
 grub_crypto_hash (const gcry_md_spec_t *hash, void *out, const void *in,
5593c8
 		  grub_size_t inlen)