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

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