[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v1 06/21] crypto: move storage for grub_crypto_pk_* to crypto.c
From: |
Sudhakar Kuppusamy |
Subject: |
[PATCH v1 06/21] crypto: move storage for grub_crypto_pk_* to crypto.c |
Date: |
Wed, 18 Dec 2024 20:26:32 +0530 |
From: Daniel Axtens <dja@axtens.net>
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 <dja@axtens.net>
Signed-off-by: Sudhakar Kuppusamy <sudhakar@linux.ibm.com>
---
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 b084dc9a2..a45c2213c 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 396f76410..d53ddbe2c 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.43.5
- [PATCH v1 01/21] powerpc-ieee1275: Add support for signing grub with an appended signature, (continued)
- [PATCH v1 01/21] powerpc-ieee1275: Add support for signing grub with an appended signature, Sudhakar Kuppusamy, 2024/12/18
- [PATCH v1 02/21] docs/grub: Document signing grub under UEFI, Sudhakar Kuppusamy, 2024/12/18
- [PATCH v1 03/21] docs/grub: Document signing grub with an appended signature, Sudhakar Kuppusamy, 2024/12/18
- [PATCH v1 04/21] dl: provide a fake grub_dl_set_persistent for the emu target, Sudhakar Kuppusamy, 2024/12/18
- [PATCH v1 05/21] pgp: factor out rsa_pad, Sudhakar Kuppusamy, 2024/12/18
- [PATCH v1 06/21] crypto: move storage for grub_crypto_pk_* to crypto.c,
Sudhakar Kuppusamy <=
- [PATCH v1 07/21] grub-install: support embedding x509 certificates, Sudhakar Kuppusamy, 2024/12/18
- [PATCH v1 09/21] appended signatures: parse PKCS#7 signedData and X.509 certificates, Sudhakar Kuppusamy, 2024/12/18
- [PATCH v1 08/21] appended signatures: import GNUTLS's ASN.1 description files, Sudhakar Kuppusamy, 2024/12/18
- [PATCH v1 14/21] ieee1275: Platform Keystore (PKS) Support, Sudhakar Kuppusamy, 2024/12/18
- [PATCH v1 15/21] ieee1275: Read the DB and DBX secure boot variables, Sudhakar Kuppusamy, 2024/12/18