All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH 1/7] crypto: DRBG - remove internal reseeding operation
@ 2022-01-26 13:57 ` kernel test robot
  0 siblings, 0 replies; 8+ messages in thread
From: kernel test robot @ 2022-01-26 13:57 UTC (permalink / raw)
  Cc: kbuild-all, llvm

In-Reply-To: <2450379.h6RI2rZIcs@positron.chronox.de>
References: <2450379.h6RI2rZIcs@positron.chronox.de>
TO: "Stephan Müller" <smueller@chronox.de>
TO: herbert@gondor.apana.org.au
CC: linux-crypto@vger.kernel.org
CC: simo@redhat.com
CC: Nicolai Stange <nstange@suse.de>

Hi "Stephan,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on herbert-cryptodev-2.6/master]
[also build test ERROR on herbert-crypto-2.6/master linus/master v5.17-rc1 next-20220125]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Stephan-M-ller/Common-entropy-source-and-DRNG-management/20220126-150911
base:   https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git master
config: i386-randconfig-a006 (https://download.01.org/0day-ci/archive/20220126/202201262115.AVuVkS5I-lkp@intel.com/config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 2a1b7aa016c0f4b5598806205bdfbab1ea2d92c4)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/14ec08bbd20e04299353eb31a9d43d4ac9af2b22
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Stephan-M-ller/Common-entropy-source-and-DRNG-management/20220126-150911
        git checkout 14ec08bbd20e04299353eb31a9d43d4ac9af2b22
        # save the config file to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=i386 SHELL=/bin/bash

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

>> ld.lld: error: call to __compiletime_assert_220 marked "dontcall-error": BUILD_BUG_ON failed: ARRAY_SIZE(drbg_cores) != ARRAY_SIZE(drbg_algs)

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

^ permalink raw reply	[flat|nested] 8+ messages in thread
* Re: [PATCH 1/7] crypto: DRBG - remove internal reseeding operation
@ 2022-01-26 11:54 kernel test robot
  0 siblings, 0 replies; 8+ messages in thread
From: kernel test robot @ 2022-01-26 11:54 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 6310 bytes --]

CC: kbuild-all(a)lists.01.org
In-Reply-To: <2450379.h6RI2rZIcs@positron.chronox.de>
References: <2450379.h6RI2rZIcs@positron.chronox.de>
TO: "Stephan Müller" <smueller@chronox.de>
TO: herbert(a)gondor.apana.org.au
CC: linux-crypto(a)vger.kernel.org
CC: simo(a)redhat.com
CC: Nicolai Stange <nstange@suse.de>

Hi "Stephan,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on herbert-cryptodev-2.6/master]
[also build test WARNING on herbert-crypto-2.6/master linus/master v5.17-rc1 next-20220125]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Stephan-M-ller/Common-entropy-source-and-DRNG-management/20220126-150911
base:   https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git master
:::::: branch date: 5 hours ago
:::::: commit date: 5 hours ago
config: arc-randconfig-c004-20220124 (https://download.01.org/0day-ci/archive/20220126/202201261919.fUyJINhO-lkp(a)intel.com/config)
compiler: arc-elf-gcc (GCC) 11.2.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Julia Lawall <julia.lawall@lip6.fr>


cocci warnings: (new ones prefixed by >>)
>> crypto/drbg.c:1315:3-9: preceding lock on line 1303
   crypto/drbg.c:1322:3-9: preceding lock on line 1303

vim +1315 crypto/drbg.c

57225e6797885e Stephan Mueller 2015-06-09  1277  
541af946fe1360 Stephan Mueller 2014-05-31  1278  /*
541af946fe1360 Stephan Mueller 2014-05-31  1279   * DRBG instantiation function as required by SP800-90A - this function
14ec08bbd20e04 Stephan Müller  2022-01-26  1280   * sets up the DRBG handle if needed and seeds the DRBG with entropy. If the
14ec08bbd20e04 Stephan Müller  2022-01-26  1281   * DRBG is already instantiated, the DRBG is simply reseeded.
541af946fe1360 Stephan Mueller 2014-05-31  1282   *
14ec08bbd20e04 Stephan Müller  2022-01-26  1283   * @tfm: tfm cipher handle with DRBG state (may be uninitialized)
14ec08bbd20e04 Stephan Müller  2022-01-26  1284   * @seed: buffer with the entropy data to (re)seed the DRBG
14ec08bbd20e04 Stephan Müller  2022-01-26  1285   * @slen: length of seed buffer
541af946fe1360 Stephan Mueller 2014-05-31  1286   *
541af946fe1360 Stephan Mueller 2014-05-31  1287   * return
541af946fe1360 Stephan Mueller 2014-05-31  1288   *	0 on success
541af946fe1360 Stephan Mueller 2014-05-31  1289   *	error value otherwise
541af946fe1360 Stephan Mueller 2014-05-31  1290   */
14ec08bbd20e04 Stephan Müller  2022-01-26  1291  static int drbg_instantiate(struct crypto_rng *tfm,
14ec08bbd20e04 Stephan Müller  2022-01-26  1292  			    const u8 *seed, unsigned int slen)
541af946fe1360 Stephan Mueller 2014-05-31  1293  {
14ec08bbd20e04 Stephan Müller  2022-01-26  1294  	struct drbg_state *drbg = crypto_rng_ctx(tfm);
14ec08bbd20e04 Stephan Müller  2022-01-26  1295  	struct drbg_string seeddata;
14ec08bbd20e04 Stephan Müller  2022-01-26  1296  	LIST_HEAD(seedlist);
2a57e4241ec9a1 Herbert Xu      2015-04-20  1297  	int ret;
2a57e4241ec9a1 Herbert Xu      2015-04-20  1298  	bool reseed = true;
541af946fe1360 Stephan Mueller 2014-05-31  1299  
14ec08bbd20e04 Stephan Müller  2022-01-26  1300  	drbg_string_fill(&seeddata, seed, slen);
14ec08bbd20e04 Stephan Müller  2022-01-26  1301  	list_add_tail(&seeddata.list, &seedlist);
14ec08bbd20e04 Stephan Müller  2022-01-26  1302  
76899a41f830d1 Stephan Mueller 2015-04-18 @1303  	mutex_lock(&drbg->drbg_mutex);
541af946fe1360 Stephan Mueller 2014-05-31  1304  
541af946fe1360 Stephan Mueller 2014-05-31  1305  	/* 9.1 step 1 is implicit with the selected DRBG type */
14ec08bbd20e04 Stephan Müller  2022-01-26  1306  	/* 9.1 step 2 is implicit as no prediction resistance is supported */
541af946fe1360 Stephan Mueller 2014-05-31  1307  	/* 9.1 step 4 is implicit in  drbg_sec_strength */
541af946fe1360 Stephan Mueller 2014-05-31  1308  
2a57e4241ec9a1 Herbert Xu      2015-04-20  1309  	if (!drbg->core) {
14ec08bbd20e04 Stephan Müller  2022-01-26  1310  		struct crypto_tfm *tfm_base = crypto_rng_tfm(tfm);
14ec08bbd20e04 Stephan Müller  2022-01-26  1311  		int coreref = 0;
14ec08bbd20e04 Stephan Müller  2022-01-26  1312  
14ec08bbd20e04 Stephan Müller  2022-01-26  1313  		if (!slen) {
14ec08bbd20e04 Stephan Müller  2022-01-26  1314  			pr_warn("DRBG: initial seed missing\n");
14ec08bbd20e04 Stephan Müller  2022-01-26 @1315  			return -EINVAL;
14ec08bbd20e04 Stephan Müller  2022-01-26  1316  		}
14ec08bbd20e04 Stephan Müller  2022-01-26  1317  
14ec08bbd20e04 Stephan Müller  2022-01-26  1318  		pr_devel("DRBG: Initializing DRBG core %d\n", coreref);
14ec08bbd20e04 Stephan Müller  2022-01-26  1319  		ret = drbg_convert_tfm_core(
14ec08bbd20e04 Stephan Müller  2022-01-26  1320  			crypto_tfm_alg_driver_name(tfm_base), &coreref);
14ec08bbd20e04 Stephan Müller  2022-01-26  1321  		if (ret)
14ec08bbd20e04 Stephan Müller  2022-01-26  1322  			return ret;
2a57e4241ec9a1 Herbert Xu      2015-04-20  1323  		drbg->core = &drbg_cores[coreref];
2a57e4241ec9a1 Herbert Xu      2015-04-20  1324  
541af946fe1360 Stephan Mueller 2014-05-31  1325  		ret = drbg_alloc_state(drbg);
541af946fe1360 Stephan Mueller 2014-05-31  1326  		if (ret)
76899a41f830d1 Stephan Mueller 2015-04-18  1327  			goto unlock;
541af946fe1360 Stephan Mueller 2014-05-31  1328  
2a57e4241ec9a1 Herbert Xu      2015-04-20  1329  		reseed = false;
2a57e4241ec9a1 Herbert Xu      2015-04-20  1330  	}
2a57e4241ec9a1 Herbert Xu      2015-04-20  1331  
14ec08bbd20e04 Stephan Müller  2022-01-26  1332  	ret = drbg_seed(drbg, &seedlist, reseed);
541af946fe1360 Stephan Mueller 2014-05-31  1333  
76899a41f830d1 Stephan Mueller 2015-04-18  1334  unlock:
76899a41f830d1 Stephan Mueller 2015-04-18  1335  	mutex_unlock(&drbg->drbg_mutex);
541af946fe1360 Stephan Mueller 2014-05-31  1336  	return ret;
541af946fe1360 Stephan Mueller 2014-05-31  1337  }
541af946fe1360 Stephan Mueller 2014-05-31  1338  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

^ permalink raw reply	[flat|nested] 8+ messages in thread
* [PATCH 0/7] Common entropy source and DRNG management
@ 2022-01-26  7:02 Stephan Müller
  2022-01-26  7:03 ` [PATCH 1/7] crypto: DRBG - remove internal reseeding operation Stephan Müller
  0 siblings, 1 reply; 8+ messages in thread
From: Stephan Müller @ 2022-01-26  7:02 UTC (permalink / raw)
  To: herbert; +Cc: linux-crypto, simo, Nicolai Stange

The current code base of the kernel crypto API random number support
leaves the task to seed and reseed the DRNG to either the caller or
the DRNG implementation. The code in crypto/drbg.c implements its own
seeding strategy. crypto/ansi_cprng.c does not contain any seeding
operation. The implementation in arch/s390/crypto/prng.c has yet
another approach for seeding. Albeit the crypto_rng_reset() contains
a seeding logic from get_random_bytes, there is no management of
the DRNG to ensure proper reseeding or control which entropy sources
are used for pulling data from.

The task of seeding and reseeding a DRNG including the controlling
of the state of the entropy sources is security sensitive as the
strength of the data obtained from the DRNG rests in large parts on
the proper seeding. In addition, various aspects need to be considered
when (re)seeding a DRNG. This gap is filled with the Entropy Source and
DRNG Manager (ESDM) proposed by this patch set.

The ESDM consists of two managers: the manager for the DRNG(s) and
manager for the entropy sources. The DRNG manager ensures that DRNGs
are properly seeded before random numbers are obtained from them.
Similarly, the entropy source manager ensures that the available
entropy sources are properly initialized if needed, and that data
is obtained with an appropriately considered entropy rate.

Both, the DRNG and entropy source managers offer a pluggable interface
allowing to use different DRNG implementations as well as various
entropy sources. Each provided entropy source may be enabled during
compile time. The ESDM therefore provides flexibility in the future
to extend the set of entropy sources or the supported DRNGs to the
required algorithms.

The patch set consists of the following changes:

- Patch 1 removes the seeding and reseeding logic from the DRBG
  transforming it into a pure deterministic implementation.

- Patch 2 removes the special AF_ALG interface used to test
  the DRBG implementation which requires bypassing of the DRBG
  automated seeding from entropy sources. With patch 1 this is
  not needed any more.

- Patch 3 adds the ESDM with its DRNG and entropy source
  managers. It contains the support to use the kernel crypto
  API's DRNG implementations.

- Patches 4 and 5 use the existing Jitter RNG as an entropy
  source for the ESDM.

- Patch 6 provides the glue code to use the get_random_bytes
  function as entropy source to the ESDM.

- Patch 7 adds the ESDM interface to register it with the kernel
  crypto API RNG framework as "stdrng" with the highest priority.
  This way, the ESDM is used per default when using the call
  crypto_get_default_rng().

With this patch series, callers to the kernel crypto API would not
experience any difference. When using the RNG framework, the function
crypto_get_default_rng is commonly used. Instead of providing the
DRBG implementation, the ESDM is used which returns random numbers
from a properly seeded DRBG.

Stephan Mueller (7):
  crypto: DRBG - remove internal reseeding operation
  crypto: AF_ALG - remove ALG_SET_DRBG_ENTROPY interface
  crypto: Entropy Source and DRNG Manager
  crypto: move Jitter RNG header include dir
  crypto: ESDM - add Jitter RNG entropy source
  crypto: ESDM - add Kernel RNG entropy source
  crypto: ESDM - add kernel crypto API RNG interface

 crypto/Kconfig                                |  11 +-
 crypto/Makefile                               |   1 +
 crypto/af_alg.c                               |   7 -
 crypto/algif_rng.c                            |  74 +-
 crypto/drbg.c                                 | 640 ++++-------------
 crypto/esdm/Kconfig                           | 166 +++++
 crypto/esdm/Makefile                          |  15 +
 crypto/esdm/esdm_definitions.h                | 141 ++++
 crypto/esdm/esdm_drng_kcapi.c                 | 202 ++++++
 crypto/esdm/esdm_drng_kcapi.h                 |  13 +
 crypto/esdm/esdm_drng_mgr.c                   | 398 +++++++++++
 crypto/esdm/esdm_drng_mgr.h                   |  85 +++
 crypto/esdm/esdm_es_aux.c                     | 332 +++++++++
 crypto/esdm/esdm_es_aux.h                     |  44 ++
 crypto/esdm/esdm_es_jent.c                    | 128 ++++
 crypto/esdm/esdm_es_jent.h                    |  17 +
 crypto/esdm/esdm_es_krng.c                    | 120 ++++
 crypto/esdm/esdm_es_krng.h                    |  17 +
 crypto/esdm/esdm_es_mgr.c                     | 372 ++++++++++
 crypto/esdm/esdm_es_mgr.h                     |  46 ++
 crypto/esdm/esdm_es_mgr_cb.h                  |  73 ++
 crypto/esdm/esdm_interface_kcapi.c            |  91 +++
 crypto/esdm/esdm_sha.h                        |  14 +
 crypto/esdm/esdm_sha256.c                     |  72 ++
 crypto/jitterentropy-kcapi.c                  |   3 +-
 crypto/jitterentropy.c                        |   2 +-
 crypto/testmgr.c                              | 104 +--
 crypto/testmgr.h                              | 641 +-----------------
 include/crypto/drbg.h                         |  84 ---
 include/crypto/esdm.h                         | 115 ++++
 include/crypto/if_alg.h                       |   1 -
 .../crypto/internal}/jitterentropy.h          |   0
 include/crypto/internal/rng.h                 |   6 -
 include/crypto/rng.h                          |   4 -
 include/uapi/linux/if_alg.h                   |   2 +-
 35 files changed, 2615 insertions(+), 1426 deletions(-)
 create mode 100644 crypto/esdm/Kconfig
 create mode 100644 crypto/esdm/Makefile
 create mode 100644 crypto/esdm/esdm_definitions.h
 create mode 100644 crypto/esdm/esdm_drng_kcapi.c
 create mode 100644 crypto/esdm/esdm_drng_kcapi.h
 create mode 100644 crypto/esdm/esdm_drng_mgr.c
 create mode 100644 crypto/esdm/esdm_drng_mgr.h
 create mode 100644 crypto/esdm/esdm_es_aux.c
 create mode 100644 crypto/esdm/esdm_es_aux.h
 create mode 100644 crypto/esdm/esdm_es_jent.c
 create mode 100644 crypto/esdm/esdm_es_jent.h
 create mode 100644 crypto/esdm/esdm_es_krng.c
 create mode 100644 crypto/esdm/esdm_es_krng.h
 create mode 100644 crypto/esdm/esdm_es_mgr.c
 create mode 100644 crypto/esdm/esdm_es_mgr.h
 create mode 100644 crypto/esdm/esdm_es_mgr_cb.h
 create mode 100644 crypto/esdm/esdm_interface_kcapi.c
 create mode 100644 crypto/esdm/esdm_sha.h
 create mode 100644 crypto/esdm/esdm_sha256.c
 create mode 100644 include/crypto/esdm.h
 rename {crypto => include/crypto/internal}/jitterentropy.h (100%)

-- 
2.33.1





^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-01-26 13:57 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-01-26 13:57 [PATCH 1/7] crypto: DRBG - remove internal reseeding operation kernel test robot
2022-01-26 13:57 ` kernel test robot
  -- strict thread matches above, loose matches on Subject: below --
2022-01-26 11:54 kernel test robot
2022-01-26  7:02 [PATCH 0/7] Common entropy source and DRNG management Stephan Müller
2022-01-26  7:03 ` [PATCH 1/7] crypto: DRBG - remove internal reseeding operation Stephan Müller
2022-01-26 12:15   ` kernel test robot
2022-01-26 12:15     ` kernel test robot
2022-01-26 13:44     ` Stephan Mueller
2022-01-26 13:44       ` Stephan Mueller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.