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

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