From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3B4A7C43467 for ; Mon, 19 Oct 2020 19:53:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DEB32222C2 for ; Mon, 19 Oct 2020 19:53:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=chronox.de header.i=@chronox.de header.b="aFymrRo8" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731467AbgJSTxS (ORCPT ); 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