Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1m2vSI-0004ef-HG for mharc-grub-devel@gnu.org; Mon, 12 Jul 2021 08:54:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44460) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m2vSF-0004Y3-2E for grub-devel@gnu.org; Mon, 12 Jul 2021 08:54:35 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:60178 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m2vSC-0001ne-JK for grub-devel@gnu.org; Mon, 12 Jul 2021 08:54:34 -0400 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 16CCZU4Q147845; Mon, 12 Jul 2021 08:54:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=pp1; bh=2nXRuapI+O1CU8mR7geOuvFL7q0VE/G2IfgFb2CC8GE=; b=A+exaIpcTVLqLSCsU7gwgxQ3o5j46KOExGMN7TapUhnbTN9B7oLrXHPKkC6TxWznlvHr 5UeUva1qZ41alH2G3c2rFvjEMLb77gM3XAy4DKEBVOoM5+Ht21QWhVpL24IrT13v6A4z sE30wBpEY/PZn4/c9yLJfloLuVaaB7qZrZY0JYLWlq8qje9Hx4PKvsEsdWo7PlnQc00/ o2eSEW7bCW4khJbyDUjbxXFU3DA3FOmr0X37C9IRZ1iApOX8rAOmZmrx98FQiuoVGmKR Z3YFwXq2J+QPKU68eEcUgHubrldIpZFKS3ojBeoLVXGDlzkgAWtis//0lRcGI+p26uxB 6w== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 39qs650j0n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 12 Jul 2021 08:54:29 -0400 Received: from m0098420.ppops.net (m0098420.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 16CCZhqK148542; Mon, 12 Jul 2021 08:54:29 -0400 Received: from ppma03dal.us.ibm.com (b.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.11]) by mx0b-001b2d01.pphosted.com with ESMTP id 39qs650j0b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 12 Jul 2021 08:54:29 -0400 Received: from pps.filterd (ppma03dal.us.ibm.com [127.0.0.1]) by ppma03dal.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 16CCrrUx008529; Mon, 12 Jul 2021 12:54:28 GMT Received: from b01cxnp22034.gho.pok.ibm.com (b01cxnp22034.gho.pok.ibm.com [9.57.198.24]) by ppma03dal.us.ibm.com with ESMTP id 39rkgswsd3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 12 Jul 2021 12:54:28 +0000 Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp22034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 16CCsRsl38666596 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 12 Jul 2021 12:54:27 GMT Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4C22B112075; Mon, 12 Jul 2021 12:54:27 +0000 (GMT) Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4775711206F; Mon, 12 Jul 2021 12:54:27 +0000 (GMT) Received: from [9.47.158.152] (unknown [9.47.158.152]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTP; Mon, 12 Jul 2021 12:54:27 +0000 (GMT) Subject: Re: [PATCH v2 09/22] crypto: move storage for grub_crypto_pk_* to crypto.c To: The development of GNU GRUB , Daniel Axtens Cc: rashmica.g@gmail.com, alastair@d-silva.org, nayna@linux.ibm.com References: <20210630084031.2663622-1-dja@axtens.net> <20210630084031.2663622-10-dja@axtens.net> From: Stefan Berger Message-ID: <3dfe7798-c2b7-e651-672b-0ec2886373b5@linux.ibm.com> Date: Mon, 12 Jul 2021 08:54:27 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <20210630084031.2663622-10-dja@axtens.net> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: YE1IhtzCGtIjmrlxtajgYS_qwKLMP7HY X-Proofpoint-GUID: GaBVj21PY3s5sooqqQ5n8FUTXFDUnBWA X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391, 18.0.790 definitions=2021-07-12_07:2021-07-12, 2021-07-12 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 phishscore=0 adultscore=0 spamscore=0 malwarescore=0 priorityscore=1501 mlxlogscore=999 clxscore=1015 impostorscore=0 suspectscore=0 lowpriorityscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2107120099 Received-SPF: pass client-ip=148.163.158.5; envelope-from=stefanb@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, NICE_REPLY_A=-1.479, RCVD_IN_MSPIKE_H2=-0.001, 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: Mon, 12 Jul 2021 12:54:35 -0000 On 6/30/21 4:40 AM, Daniel Axtens wrote: > 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 Reviewed-by: Stefan Berger > --- > 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 2408db4994f6..355a43844acc 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)