Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1kXaj6-0000k1-7B for mharc-grub-devel@gnu.org; Tue, 27 Oct 2020 21:58:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46496) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kXaj3-0000bw-6I for grub-devel@gnu.org; Tue, 27 Oct 2020 21:58:09 -0400 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]:40997) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kXaiy-0007oC-Fn for grub-devel@gnu.org; Tue, 27 Oct 2020 21:58:08 -0400 Received: by mail-pl1-x644.google.com with SMTP id w11so1716287pll.8 for ; Tue, 27 Oct 2020 18:58:03 -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=CbMyfnvtQA9PY/H01AIWdQ5CP6uPHWRWuQjMVr9/kBIVSlFIbv1AjzztpXz5+ZhhSh y8qADJpJTXJTpQQrgMstG4F84vFTSnPr94J3n7Ew3UO0w/At5AiAb4gdbxb1akcZ6I7B 1QONUSzkiFD9fm2y4WTZKNijjP0yuw2BMbCEQ= 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=Bz3Vzy+StlqLG0fcFg8o29/V75AMdncbQ6XCUcK9PtIGNUjCr/8h9Rd6A91M0JZLvb dDr7kWtP1QAzgWvoBPYqXahgVv9IowBkv5EHg2m39Nm7Yi8oDI9UDhMTvdTNs25ctxcr 4LlBQjvXfbHPjr5jPdTRW0Ge2UhzW0JGU3gHrIlm4gv01GmIOlS48FNlweVqf8HpcGfe pfA2n2veLvNgguKthD03pQFWeYIB4rKvPWmWO2WEyDBCYBoMUFrYZ1R3Jug/K5jw6wnQ aVxOLA8rnGL0tcxcQHMxAEIWZomvCiYmWYVjaD6LX8UF2XmidNpOgVgju6d0Xp0GU4rk cIpA== X-Gm-Message-State: AOAM530RoUSBmNG0aSvd2p3mVJeCzTnDFvuU18LmlXcYpOHzBN98en1H tRtpD1JFUEVdXSTrHOx8SFUqNVN0FLE96Q== X-Google-Smtp-Source: ABdhPJxj7Zdn9JHLWgiuixfbHGXg9f+yLTCNS/hu8x2NIorYP6b21wkLp92AlmNP2Vm6ih8C+Xkz8g== X-Received: by 2002:a17:90a:db43:: with SMTP id u3mr4695291pjx.225.1603850283049; Tue, 27 Oct 2020 18:58:03 -0700 (PDT) Received: from localhost (2001-44b8-1113-6700-b4f7-e8d4-abaa-2197.static.ipv6.internode.on.net. [2001:44b8:1113:6700:b4f7:e8d4:abaa:2197]) by smtp.gmail.com with ESMTPSA id m13sm3055455pjr.30.2020.10.27.18.58.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Oct 2020 18:58:02 -0700 (PDT) From: Daniel Axtens To: grub-devel@gnu.org Cc: rashmica.g@gmail.com, alastair@d-silva.org, Daniel Axtens Subject: [PATCH v2 06/18] crypto: move storage for grub_crypto_pk_* to crypto.c Date: Wed, 28 Oct 2020 12:57:23 +1100 Message-Id: <20201028015735.1131291-7-dja@axtens.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201028015735.1131291-1-dja@axtens.net> References: <20201028015735.1131291-1-dja@axtens.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2607:f8b0:4864:20::644; envelope-from=dja@axtens.net; helo=mail-pl1-x644.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: Wed, 28 Oct 2020 01:58:09 -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