All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/18] crypto: dh - infrastructure for NVM in-band auth and FIPS conformance
@ 2021-12-01  0:48 Nicolai Stange
  2021-12-01  0:48 ` [PATCH 01/18] crypto: dh - remove struct dh's ->q member Nicolai Stange
                   ` (17 more replies)
  0 siblings, 18 replies; 51+ messages in thread
From: Nicolai Stange @ 2021-12-01  0:48 UTC (permalink / raw)
  To: Herbert Xu, David S. Miller
  Cc: Stephan Müller, Hannes Reinecke, Torsten Duwe, Zaibo Xu,
	Giovanni Cabiddu, David Howells, Jarkko Sakkinen, linux-crypto,
	linux-kernel, qat-linux, keyrings, Nicolai Stange

Hi all,

first of all, to the people primarily interested in security/keys/, there's
a rather trivial change to security/keys/dh.c in patch 2/18. It would be
great to get ACKs for that...


Hannes' recent work on NVME in-band authentication ([1]) needs access to
the RFC 7919 DH group parameters and also some means to generate ephemeral
keys. He currently implements both as part of his patchset (patches 3/12
and 8/12). After some internal discussion, we decided to split off the bits
needed from crypto/dh into a separate series, i.e. this one here:
 - for the RFC 7919 DH group parameters, it's undesirable from a
   performance POV to serialize the well-known domain parameters via
   crypto_dh_encode_key() just to deserialize them shortly after again,
 - from an architectural POV, it would be preferrable to have the key
   generation code in crypto/dh.c rather than in drivers/nvme/,
   just in analogy to how key generation is supported by crypto/ecdh.c
   already.

Patches 1-13/18 implement all that is needed for the NVME in-band
authentication support. 

Unfortunately, due to the lack of HW, I have not been able to test
the changes to the QAT or HPRE drivers (other than mere compile tests).
Yet I figured it would be a good idea to have them behave consistently with
dh_generic, and so I chose to introduce support for privkey generation to
these as well.


By coincidence, NIST SP800-56Arev3 compliance effectively requires that
the domain parameters are checked against an approved set, which happens
to consists of those safe-prime group parameters specified in RFC 7919,
among others. Thus, introducing the RFC 7919 parameters to the kernel
allows for making the DH implementation to conform to SP800-56Arev3 with
only little effort. I used the opportunity to work crypto/dh towards
SP800-56Arev3 conformance with the rest of this patch series, i.e.
patches 14-18/18. I can split these into another series on its own, if you
like. But as they depend on the earlier patches 1-13/18, I sent them
alongside for now.

This patchset has been tested with and without fips_enabled on x86_64,
ppc64le and s390x, the latter being a big endian machine, which is relevant
for the new test vectors.

Thanks,

Nicolai

[1] https://lkml.kernel.org/r/20211123123801.73197-1-hare@suse.de

Nicolai Stange (18):
  crypto: dh - remove struct dh's ->q member
  crypto: dh - constify struct dh's pointer members
  crypto: dh - optimize domain parameter serialization for well-known
    groups
  crypto: dh - introduce RFC 7919 safe-prime groups
  crypto: testmgr - add DH RFC 7919 ffdhe2048 test vector
  crypto: dh - introduce RFC 3526 safe-prime groups
  crypto: testmgr - add DH RFC 3526 modp2048 test vector
  crypto: testmgr - run only subset of DH vectors based on config
  crypto: dh - implement private key generation primitive
  crypto: dh - introduce support for ephemeral key generation to
    dh-generic
  crypto: dh - introduce support for ephemeral key generation to hpre
    driver
  crypto: dh - introduce support for ephemeral key generation to qat
    driver
  crypto: testmgr - add DH test vectors for key generation
  lib/mpi: export mpi_rshift
  crypto: dh - store group id in dh-generic's dh_ctx
  crypto: dh - calculate Q from P for the full public key verification
  crypto: dh - try to match domain parameters to a known safe-prime
    group
  crypto: dh - accept only approved safe-prime groups in FIPS mode

 crypto/Kconfig                                |  20 +-
 crypto/dh.c                                   |  73 +-
 crypto/dh_helper.c                            | 691 +++++++++++++++++-
 crypto/testmgr.h                              | 342 ++++++++-
 drivers/crypto/hisilicon/hpre/hpre_crypto.c   |  11 +
 drivers/crypto/qat/qat_common/qat_asym_algs.c |   9 +
 include/crypto/dh.h                           |  52 +-
 lib/mpi/mpi-bit.c                             |   1 +
 security/keys/dh.c                            |   2 +-
 9 files changed, 1141 insertions(+), 60 deletions(-)

-- 
2.26.2


^ permalink raw reply	[flat|nested] 51+ messages in thread
* Re: [PATCH 17/18] crypto: dh - try to match domain parameters to a known safe-prime group
@ 2021-12-07  7:06 kernel test robot
  0 siblings, 0 replies; 51+ messages in thread
From: kernel test robot @ 2021-12-07  7:06 UTC (permalink / raw)
  To: kbuild

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

CC: kbuild-all(a)lists.01.org
In-Reply-To: <20211201004858.19831-18-nstange@suse.de>
References: <20211201004858.19831-18-nstange@suse.de>
TO: Nicolai Stange <nstange@suse.de>
TO: Herbert Xu <herbert@gondor.apana.org.au>
TO: "David S. Miller" <davem@davemloft.net>
CC: netdev(a)vger.kernel.org
CC: "Stephan Müller" <smueller@chronox.de>
CC: Hannes Reinecke <hare@suse.de>
CC: Torsten Duwe <duwe@suse.de>
CC: Zaibo Xu <xuzaibo@huawei.com>
CC: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
CC: David Howells <dhowells@redhat.com>
CC: Jarkko Sakkinen <jarkko@kernel.org>

Hi Nicolai,

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 jmorris-security/next-testing v5.16-rc4 next-20211206]
[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/Nicolai-Stange/crypto-dh-infrastructure-for-NVM-in-band-auth-and-FIPS-conformance/20211201-085159
base:   https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git master
:::::: branch date: 6 days ago
:::::: commit date: 6 days ago
config: arm-randconfig-m031-20211128 (https://download.01.org/0day-ci/archive/20211207/202112071438.gJPtedGv-lkp(a)intel.com/config)
compiler: arm-linux-gnueabi-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: Dan Carpenter <dan.carpenter@oracle.com>

New smatch warnings:
crypto/dh_helper.c:493 lookup_group_id() warn: we never enter this loop

Old smatch warnings:
crypto/dh_helper.c:466 get_safe_prime_group() warn: we never enter this loop

vim +493 crypto/dh_helper.c

802c7f1c84e4b5a Salvatore Benedetto 2016-06-22  473  
2048fab14cfd860 Nicolai Stange      2021-12-01  474  static enum dh_group_id lookup_group_id(const char *g, size_t g_size,
2048fab14cfd860 Nicolai Stange      2021-12-01  475  					const char *p, size_t p_size)
2048fab14cfd860 Nicolai Stange      2021-12-01  476  {
2048fab14cfd860 Nicolai Stange      2021-12-01  477  	int i;
2048fab14cfd860 Nicolai Stange      2021-12-01  478  
2048fab14cfd860 Nicolai Stange      2021-12-01  479  	/* All safe-prime groups use a generator of g == 2. */
2048fab14cfd860 Nicolai Stange      2021-12-01  480  	while (g_size && !*g) {
2048fab14cfd860 Nicolai Stange      2021-12-01  481  		++g;
2048fab14cfd860 Nicolai Stange      2021-12-01  482  		--g_size;
2048fab14cfd860 Nicolai Stange      2021-12-01  483  	}
2048fab14cfd860 Nicolai Stange      2021-12-01  484  
2048fab14cfd860 Nicolai Stange      2021-12-01  485  	if (g_size != 1 || *g != 2)
2048fab14cfd860 Nicolai Stange      2021-12-01  486  		return dh_group_id_unknown;
2048fab14cfd860 Nicolai Stange      2021-12-01  487  
2048fab14cfd860 Nicolai Stange      2021-12-01  488  	while (p_size && !*p) {
2048fab14cfd860 Nicolai Stange      2021-12-01  489  		++p;
2048fab14cfd860 Nicolai Stange      2021-12-01  490  		--p_size;
2048fab14cfd860 Nicolai Stange      2021-12-01  491  	}
2048fab14cfd860 Nicolai Stange      2021-12-01  492  
2048fab14cfd860 Nicolai Stange      2021-12-01 @493  	for (i = 0; i < ARRAY_SIZE(safe_prime_groups); ++i) {
2048fab14cfd860 Nicolai Stange      2021-12-01  494  		if (safe_prime_groups[i].p_size != p_size)
2048fab14cfd860 Nicolai Stange      2021-12-01  495  			continue;
2048fab14cfd860 Nicolai Stange      2021-12-01  496  
2048fab14cfd860 Nicolai Stange      2021-12-01  497  		if (!memcmp(safe_prime_groups[i].p, p, p_size))
2048fab14cfd860 Nicolai Stange      2021-12-01  498  			return safe_prime_groups[i].group_id;
2048fab14cfd860 Nicolai Stange      2021-12-01  499  	}
2048fab14cfd860 Nicolai Stange      2021-12-01  500  
2048fab14cfd860 Nicolai Stange      2021-12-01  501  	return dh_group_id_unknown;
2048fab14cfd860 Nicolai Stange      2021-12-01  502  }
2048fab14cfd860 Nicolai Stange      2021-12-01  503  

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

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

end of thread, other threads:[~2021-12-09  9:26 UTC | newest]

Thread overview: 51+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-01  0:48 [PATCH 00/18] crypto: dh - infrastructure for NVM in-band auth and FIPS conformance Nicolai Stange
2021-12-01  0:48 ` [PATCH 01/18] crypto: dh - remove struct dh's ->q member Nicolai Stange
2021-12-01  7:11   ` Hannes Reinecke
2021-12-01  0:48 ` [PATCH 02/18] crypto: dh - constify struct dh's pointer members Nicolai Stange
2021-12-01  7:13   ` Hannes Reinecke
2021-12-01  0:48 ` [PATCH 03/18] crypto: dh - optimize domain parameter serialization for well-known groups Nicolai Stange
2021-12-01  7:17   ` Hannes Reinecke
2021-12-09  9:08     ` Nicolai Stange
2021-12-01  0:48 ` [PATCH 04/18] crypto: dh - introduce RFC 7919 safe-prime groups Nicolai Stange
2021-12-01  7:23   ` Hannes Reinecke
2021-12-09  9:10     ` Nicolai Stange
2021-12-01  0:48 ` [PATCH 05/18] crypto: testmgr - add DH RFC 7919 ffdhe2048 test vector Nicolai Stange
2021-12-01  7:24   ` Hannes Reinecke
2021-12-01  0:48 ` [PATCH 06/18] crypto: dh - introduce RFC 3526 safe-prime groups Nicolai Stange
2021-12-01  7:24   ` Hannes Reinecke
2021-12-01  0:48 ` [PATCH 07/18] crypto: testmgr - add DH RFC 3526 modp2048 test vector Nicolai Stange
2021-12-01  7:25   ` Hannes Reinecke
2021-12-01  0:48 ` [PATCH 08/18] crypto: testmgr - run only subset of DH vectors based on config Nicolai Stange
2021-12-01  7:28   ` Hannes Reinecke
2021-12-09  9:18     ` Nicolai Stange
2021-12-01  0:48 ` [PATCH 09/18] crypto: dh - implement private key generation primitive Nicolai Stange
2021-12-01  7:28   ` Hannes Reinecke
2021-12-05  5:52   ` Stephan Müller
2021-12-08  6:20     ` Nicolai Stange
2021-12-08  7:16       ` Stephan Mueller
2021-12-01  0:48 ` [PATCH 10/18] crypto: dh - introduce support for ephemeral key generation to dh-generic Nicolai Stange
2021-12-01  7:29   ` Hannes Reinecke
2021-12-05  6:11   ` Stephan Müller
2021-12-08  6:32     ` Nicolai Stange
2021-12-01  0:48 ` [PATCH 11/18] crypto: dh - introduce support for ephemeral key generation to hpre driver Nicolai Stange
2021-12-01  7:30   ` Hannes Reinecke
2021-12-05  6:11   ` Stephan Müller
2021-12-01  0:48 ` [PATCH 12/18] crypto: dh - introduce support for ephemeral key generation to qat driver Nicolai Stange
2021-12-01  7:30   ` Hannes Reinecke
2021-12-05  6:11   ` Stephan Müller
2021-12-01  0:48 ` [PATCH 13/18] crypto: testmgr - add DH test vectors for key generation Nicolai Stange
2021-12-01  7:31   ` Hannes Reinecke
2021-12-01  0:48 ` [PATCH 14/18] lib/mpi: export mpi_rshift Nicolai Stange
2021-12-01  7:32   ` Hannes Reinecke
2021-12-01  0:48 ` [PATCH 15/18] crypto: dh - store group id in dh-generic's dh_ctx Nicolai Stange
2021-12-01  7:32   ` Hannes Reinecke
2021-12-01  0:48 ` [PATCH 16/18] crypto: dh - calculate Q from P for the full public key verification Nicolai Stange
2021-12-01  7:33   ` Hannes Reinecke
2021-12-05  6:07   ` Stephan Müller
2021-12-08  6:41     ` Nicolai Stange
2021-12-01  0:48 ` [PATCH 17/18] crypto: dh - try to match domain parameters to a known safe-prime group Nicolai Stange
2021-12-01  7:34   ` Hannes Reinecke
2021-12-01  0:48 ` [PATCH 18/18] crypto: dh - accept only approved safe-prime groups in FIPS mode Nicolai Stange
2021-12-01  7:34   ` Hannes Reinecke
2021-12-09  9:26     ` Nicolai Stange
2021-12-07  7:06 [PATCH 17/18] crypto: dh - try to match domain parameters to a known safe-prime group kernel test robot

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.