Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp92293pxv; Tue, 13 Jul 2021 22:52:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz7MtFkFI4u5IaBH3lxpMqp1c9RduV1Z0Tmcq1Z2BwQmX3K3ScHN1y1qM7rM+VVm9acMGBV X-Received: by 2002:a5d:9c01:: with SMTP id 1mr5808655ioe.169.1626241961284; Tue, 13 Jul 2021 22:52:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626241961; cv=none; d=google.com; s=arc-20160816; b=srlIpZZ6weZzZ0nxJ4G5IkCzr8+wCiLs1xu/eUUOm9xfbyF913QdfIQ6ioAgtTC1IG YKjb58E+3CYLfdYlFXwEgbo7VDljL88d/4+bjz+rWIOsylFr6YDPGRpXSHf4+krRABwi hqecNUBaHWp6KuKok+NiZ2ZHiYs37vf51xj8BJYoAL3xLJK5XRSEEske3HGgPlLKNmB6 7oCLWDKwSTA+iUzaZu+LZiAoIvYuKhJFtIa1JdudRElP71CfTWTEeVt+3lOXF8ST1uwh 6i53/OuDoA8srn0F8z2vdOtf7dJPBITe9NVAaqV/q2dds+cArmtUXlEfrXcLft5doSkk KT0Q== 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=ANUmmsVUf35luvMSkbphAHdUuk6CMm4SPcN80eEShbs=; b=ZfzmhA9hTLoECA2VMcrAvjG5l9eekPejSZM6zDFb+mXUoi0PDNqYiIJxE/Ccdl9xYr E/0hNseHn7kfYqEsVJ59rgz3UMhj2PakidY7Cg5LNtFsy1n5rPmPckwPl133uAaR44EX RQsSNfM0/qaTpR+13qsKHtYV4MMclL2R838aLpg5sl1MJfD7pQvDxIdz/4dxSlX632m8 +XQ4mpcDuNFOc7pIL6Xs+DIs813OxbS4/6HPQ5RJcaP2p3scnuT1uWVdRiaVkrDrYBPY +6aQhlHWZOO/EP2fDc0/a52m7g2wLm6j5pgD/lZKCF31Jheq8PmLOGfkVg7MSWlvUTTR ULwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chronox.de header.s=strato-dkim-0002 header.b=BLAQ0ACE; 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 d14si1561726iow.80.2021.07.13.22.52.29; Tue, 13 Jul 2021 22:52:41 -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=BLAQ0ACE; 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 S238034AbhGNFzI (ORCPT + 99 others); Wed, 14 Jul 2021 01:55:08 -0400 Received: from mo4-p04-ob.smtp.rzone.de ([85.215.255.124]:33561 "EHLO mo4-p04-ob.smtp.rzone.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237986AbhGNFzB (ORCPT ); Wed, 14 Jul 2021 01:55:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1626241855; s=strato-dkim-0002; d=chronox.de; h=References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Cc:Date: From:Subject:Sender; bh=ANUmmsVUf35luvMSkbphAHdUuk6CMm4SPcN80eEShbs=; b=BLAQ0ACEMZYo9N98qRSB7R8V7MTvPmgvlHhAiACN5xj4HYhVRhQ4BEqjHvFgeVlVLv hdTtkD7f8l5c0s+6nyL9x6h3NZ9mNQ8y776ipfC/xJFmI66ckxAdz9WARAuaBMWhbSNz 1wLS/GRR2b/fUwxF1EwZAYNnXpS2yrAqIStDcE9CggDw5+T0JJoga3/oRFethm2mYoeq rQn1XJ+0670F7OoXGK+dHNSbG2lbeDON+VIzr1/AVfkQ4moGAzp0rAZ925xVH+UiTwWg jeR/3Rr6tbuDwkkNxS6nO+AMnwzvZhNVM3TKIwCtcFX4nbXuuETijHQC+8//EOrIkuqC l1dA== Authentication-Results: strato.com; dkim=none X-RZG-AUTH: ":P2ERcEykfu11Y98lp/T7+hdri+uKZK8TKWEqNyiHySGSa9k9xmwdNnzHHXPSI/SaRQ==" X-RZG-CLASS-ID: mo00 Received: from positron.chronox.de by smtp.strato.de (RZmta 47.28.1 DYNA|AUTH) with ESMTPSA id N0753fx6E5oswyX (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits)) (Client did not present a certificate); Wed, 14 Jul 2021 07:50:54 +0200 (CEST) From: Stephan =?ISO-8859-1?Q?M=FCller?= To: Tso Ted , linux-crypto@vger.kernel.org Cc: Willy Tarreau , 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 , John Haxby , Alexander Lobakin Subject: [PATCH v41 06/13] crypto: DRBG - externalize DRBG functions for LRNG Date: Wed, 14 Jul 2021 07:46:19 +0200 Message-ID: <4000005.Mq6vBQt3uU@positron.chronox.de> In-Reply-To: <7822794.ITf6fX9eNu@positron.chronox.de> References: <7822794.ITf6fX9eNu@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 CC: Alexander Lobakin 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 1b4587e0ddad..b7c962a882c4 100644 =2D-- a/crypto/drbg.c +++ b/crypto/drbg.c @@ -114,7 +114,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, @@ -191,6 +191,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 @@ -206,7 +207,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: @@ -219,6 +220,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 @@ -1215,7 +1217,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; @@ -1236,12 +1238,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; @@ -1322,6 +1325,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 @@ -1891,8 +1895,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; @@ -1919,6 +1922,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.31.1