Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp3808081pxu; Tue, 20 Oct 2020 00:33:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy4sdmdeye+K/+/Tb2azolLvvIHmHtM4ApGmzzbVUiz4Ui0DP94//+RQVvZ7zTTVG1xRfMJ X-Received: by 2002:a50:d987:: with SMTP id w7mr1401887edj.113.1603179226913; Tue, 20 Oct 2020 00:33:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603179226; cv=none; d=google.com; s=arc-20160816; b=pgXTHkvMdVXnmxgq4cvRzPuKzzqTwmivUUhgkpnNguUFOKEVGaegvtRvF1w+x1ZV1Y HSwTY674Q8o0N9/G1VZKL9sKwsboP+vlFuHzNDW6/nNT4Bmjl0f+Qsrz8BmKwTTJuhYn w93ihYCS12ceDoouI55EDG1fassV/cZumJ5WyJ8rMfQ/RlL20tbc1qV6cHyxmpqoWBKp IcwOAqq//i62x/4Ilfbt0ib+Bn0qN3Gugdj1gw38vZdUnLi0B5JMaswc+Su6jcDBSh5h h9JHWMP5I6WLUCsZrypR0LPljJFU7QNdHBsbcM6RwoqR4SVAQNCZZk8teQ9FXyOGad3F KJ0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=p/c4wY2BpgATfLLqFmyeUSjYkAeQ0oZyLAA6FSe5VDs=; b=zWRBmthd1PdB/KKVAdlJ3IG2V/wKf0TWZE+tOOWWo/3IZI8KDjcL3dB/Lq5X0JRcu3 kS6iwemfyz+1zWIyuix7ApkUoorpAm4IhPWpq8Q8ES4zbcXg3BMXxrn3VYUUGba9U9p2 v3PA4sTYH2RMBIfWcHsfIBf8/ZMTeWyDLkf4ZVqNxm7HHwjjMZ4ptpOZ4hvM1YJ3F2mL vmR0IRdsTOR/kTFX9sYeq0wMifK8SkC4Yns+/hBWRH3JmOedbbz50WW374meZc5dmM6G mTaOHUmTV0jnYGqNns7evj8DUhnqM08KFFhgfkd5cafqlq/8Sr/QzeCmAImuyX1w/dvK 3rzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chronox.de header.s=strato-dkim-0002 header.b=aFymrRo8; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i10si722323ejv.243.2020.10.20.00.33.24; Tue, 20 Oct 2020 00:33:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chronox.de header.s=strato-dkim-0002 header.b=aFymrRo8; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731467AbgJSTxS (ORCPT + 99 others); Mon, 19 Oct 2020 15:53:18 -0400 Received: from mo4-p04-ob.smtp.rzone.de ([85.215.255.122]:19933 "EHLO mo4-p04-ob.smtp.rzone.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731447AbgJSTwv (ORCPT ); Mon, 19 Oct 2020 15:52:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1603137167; s=strato-dkim-0002; d=chronox.de; h=References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: X-RZG-CLASS-ID:X-RZG-AUTH:From:Subject:Sender; bh=p/c4wY2BpgATfLLqFmyeUSjYkAeQ0oZyLAA6FSe5VDs=; b=aFymrRo8aybEok5qObCOsrHVTMgOXegGwTJdQKxlrTCvU6Pt/djK2OTBi+GJNTZ2dL QyQagDpfPgb6NohS3AFB4B4/nsSeMK2NpexrNNf9NnrSCWRf5X501UlXrNJlkLvgbmsu 2RcoQXcd1M9OraP33e5o88P3dPm/Pxi9dCChEBZU5DEfNL8lU9RkYNrCOlYpdv2uzDc6 /u6YvzsjezCxJT7wcuIVcfTmPQPkj5Hk91a3aNGBVO+P97C30RvTdw+TcJWvUQttOJqR i3fW5gEArEvJjKzAwyKCr3BfwrmLkBnfY4WJiEPngoaSyjDBv8NDAq1/4wDkCK2EhKUt d/qQ== X-RZG-AUTH: ":P2ERcEykfu11Y98lp/T7+hdri+uKZK8TKWEqNyiHySGSa9k9xmwdNnzGHXPbJPSb3t0=" X-RZG-CLASS-ID: mo00 Received: from positron.chronox.de by smtp.strato.de (RZmta 47.2.1 DYNA|AUTH) with ESMTPSA id C0b627w9JJpkU6t (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits)) (Client did not present a certificate); Mon, 19 Oct 2020 21:51:46 +0200 (CEST) From: Stephan =?ISO-8859-1?Q?M=FCller?= To: Torsten Duwe Cc: Willy Tarreau , "Theodore Y. Ts'o" , linux-crypto@vger.kernel.org, Nicolai Stange , LKML , Arnd Bergmann , Greg Kroah-Hartman , "Eric W. Biederman" , "Alexander E. Patrakov" , "Ahmed S. Darwish" , Matthew Garrett , Vito Caputo , Andreas Dilger , Jan Kara , Ray Strode , William Jon McCann , zhangjs , Andy Lutomirski , Florian Weimer , Lennart Poettering , Peter Matthias , Marcelo Henrique Cerri , Neil Horman , Randy Dunlap , Julia Lawall , Dan Carpenter , Andy Lavr , Eric Biggers , "Jason A. Donenfeld" , Petr Tesarik Subject: [PATCH v36 06/13] crypto: DRBG - externalize DRBG functions for LRNG Date: Mon, 19 Oct 2020 21:34:24 +0200 Message-ID: <5549894.MhkbZ0Pkbq@positron.chronox.de> In-Reply-To: <3073852.aeNJFYEL58@positron.chronox.de> References: <20200921075857.4424-1-nstange@suse.de> <20201016172619.GA18410@lst.de> <3073852.aeNJFYEL58@positron.chronox.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="iso-8859-1" Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org This patch allows several DRBG functions to be called by the LRNG kernel code paths outside the drbg.c file. CC: Torsten Duwe CC: "Eric W. Biederman" CC: "Alexander E. Patrakov" CC: "Ahmed S. Darwish" CC: "Theodore Y. Ts'o" CC: Willy Tarreau CC: Matthew Garrett CC: Vito Caputo CC: Andreas Dilger CC: Jan Kara CC: Ray Strode CC: William Jon McCann CC: zhangjs CC: Andy Lutomirski CC: Florian Weimer CC: Lennart Poettering CC: Nicolai Stange Reviewed-by: Roman Drahtmueller Tested-by: Roman Drahtm=FCller Tested-by: Marcelo Henrique Cerri Tested-by: Neil Horman Signed-off-by: Stephan Mueller =2D-- crypto/drbg.c | 16 ++++++++++------ include/crypto/drbg.h | 7 +++++++ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/crypto/drbg.c b/crypto/drbg.c index 3132967a1749..58b1de903def 100644 =2D-- a/crypto/drbg.c +++ b/crypto/drbg.c @@ -113,7 +113,7 @@ * the SHA256 / AES 256 over other ciphers. Thus, the favored * DRBGs are the latest entries in this array. */ =2Dstatic const struct drbg_core drbg_cores[] =3D { +const struct drbg_core drbg_cores[] =3D { #ifdef CONFIG_CRYPTO_DRBG_CTR { .flags =3D DRBG_CTR | DRBG_STRENGTH128, @@ -190,6 +190,7 @@ static const struct drbg_core drbg_cores[] =3D { }, #endif /* CONFIG_CRYPTO_DRBG_HMAC */ }; +EXPORT_SYMBOL(drbg_cores); =20 static int drbg_uninstantiate(struct drbg_state *drbg); =20 @@ -205,7 +206,7 @@ static int drbg_uninstantiate(struct drbg_state *drbg); * Return: normalized strength in *bytes* value or 32 as default * to counter programming errors */ =2Dstatic inline unsigned short drbg_sec_strength(drbg_flag_t flags) +unsigned short drbg_sec_strength(drbg_flag_t flags) { switch (flags & DRBG_STRENGTH_MASK) { case DRBG_STRENGTH128: @@ -218,6 +219,7 @@ static inline unsigned short drbg_sec_strength(drbg_fla= g_t flags) return 32; } } +EXPORT_SYMBOL(drbg_sec_strength); =20 /* * FIPS 140-2 continuous self test for the noise source @@ -1214,7 +1216,7 @@ static int drbg_seed(struct drbg_state *drbg, struct = drbg_string *pers, } =20 /* Free all substructures in a DRBG state without the DRBG state structure= */ =2Dstatic inline void drbg_dealloc_state(struct drbg_state *drbg) +void drbg_dealloc_state(struct drbg_state *drbg) { if (!drbg) return; @@ -1235,12 +1237,13 @@ static inline void drbg_dealloc_state(struct drbg_s= tate *drbg) drbg->fips_primed =3D false; } } +EXPORT_SYMBOL(drbg_dealloc_state); =20 /* * Allocate all sub-structures for a DRBG state. * The DRBG state structure must already be allocated. */ =2Dstatic inline int drbg_alloc_state(struct drbg_state *drbg) +int drbg_alloc_state(struct drbg_state *drbg) { int ret =3D -ENOMEM; unsigned int sb_size =3D 0; @@ -1321,6 +1324,7 @@ static inline int drbg_alloc_state(struct drbg_state = *drbg) drbg_dealloc_state(drbg); return ret; } +EXPORT_SYMBOL(drbg_alloc_state); =20 /************************************************************************* * DRBG interface functions @@ -1890,8 +1894,7 @@ static int drbg_kcapi_sym_ctr(struct drbg_state *drbg, * * return: flags */ =2Dstatic inline void drbg_convert_tfm_core(const char *cra_driver_name, =2D int *coreref, bool *pr) +void drbg_convert_tfm_core(const char *cra_driver_name, int *coreref, bool= *pr) { int i =3D 0; size_t start =3D 0; @@ -1918,6 +1921,7 @@ static inline void drbg_convert_tfm_core(const char *= cra_driver_name, } } } +EXPORT_SYMBOL(drbg_convert_tfm_core); =20 static int drbg_kcapi_init(struct crypto_tfm *tfm) { diff --git a/include/crypto/drbg.h b/include/crypto/drbg.h index c4165126937e..71d53e028e6d 100644 =2D-- a/include/crypto/drbg.h +++ b/include/crypto/drbg.h @@ -278,4 +278,11 @@ enum drbg_prefixes { DRBG_PREFIX3 }; =20 +extern int drbg_alloc_state(struct drbg_state *drbg); +extern void drbg_dealloc_state(struct drbg_state *drbg); +extern void drbg_convert_tfm_core(const char *cra_driver_name, int *corere= f, + bool *pr); +extern const struct drbg_core drbg_cores[]; +extern unsigned short drbg_sec_strength(drbg_flag_t flags); + #endif /* _DRBG_H */ =2D-=20 2.26.2