[PATCH v5] mm/zswap: move to use crypto_acomp API for hardware acceleration

2020-07-12 Thread Barry Song
Right now, all new ZIP drivers are adapted to crypto_acomp APIs rather than legacy crypto_comp APIs. Tradiontal ZIP drivers like lz4,lzo etc have been also wrapped into acomp via scomp backend. But zswap.c is still using the old APIs. That means zswap won't be able to work on any new ZIP drivers in

[PATCH v2 0/5] DH: SP800-56A rev 3 compliant validation checks

2020-07-12 Thread Stephan Müller
Hi, This patch set adds the required checks to make all aspects of (EC)DH compliant with SP800-56A rev 3 assuming that all keys are ephemeral. The use of static keys adds yet additional validations which are hard to achieve in the kernel. SP800-56A rev 3 mandates various checks: - validation of

[PATCH v2 1/5] crypto: ECDH - check validity of Z before export

2020-07-12 Thread Stephan Müller
SP800-56A rev3 section 5.7.1.2 step 2 mandates that the validity of the calculated shared secret is verified before the data is returned to the caller. Thus, the export function and the validity check functions are reversed. In addition, the sensitive variables of priv and rand_z are zeroized. Sig

[PATCH v2 4/5] crypto: DH SP800-56A rev 3 local public key validation

2020-07-12 Thread Stephan Müller
After the generation of a local public key, SP800-56A rev 3 section 5.6.2.1.3 mandates a validation of that key with a full validation compliant to section 5.6.2.3.1. Only if the full validation passes, the key is allowed to be used. Signed-off-by: Stephan Mueller --- crypto/dh.c | 59 +

[PATCH v2 3/5] crypto: DH - check validity of Z before export

2020-07-12 Thread Stephan Müller
SP800-56A rev3 section 5.7.1.1 step 2 mandates that the validity of the calculated shared secret is verified before the data is returned to the caller. This patch adds the validation check. Signed-off-by: Stephan Mueller --- crypto/dh.c | 29 + 1 file changed, 29 inse

[PATCH v2 2/5] lib/mpi: Add mpi_sub_ui()

2020-07-12 Thread Stephan Müller
Add mpi_sub_ui() based on Gnu MP mpz_sub_ui() from mpz/aors_ui.h adapting the code to the kernel's structures and coding style and also removing the defines used to produce mpz_sub_ui() and mpz_add_ui() from the same code. Signed-off-by: Marcelo Henrique Cerri Signed-off-by: Stephan Mueller ---

[PATCH v2 5/5] crypto: ECDH SP800-56A rev 3 local public key validation

2020-07-12 Thread Stephan Müller
After the generation of a local public key, SP800-56A rev 3 section 5.6.2.1.3 mandates a validation of that key with a full validation compliant to section 5.6.2.3.3. Only if the full validation passes, the key is allowed to be used. The patch adds the full key validation compliant to 5.6.2.3.3 a

Re: [PATCH v2 1/5] crypto: ECDH - check validity of Z before export

2020-07-12 Thread Vitaly Chikunov
On Sun, Jul 12, 2020 at 06:39:26PM +0200, Stephan Müller wrote: > SP800-56A rev3 section 5.7.1.2 step 2 mandates that the validity of the > calculated shared secret is verified before the data is returned to the > caller. Thus, the export function and the validity check functions are > reversed. In

Re: [PATCH v2 5/5] crypto: ECDH SP800-56A rev 3 local public key validation

2020-07-12 Thread Vitaly Chikunov
Stephan, On Sun, Jul 12, 2020 at 06:42:14PM +0200, Stephan Müller wrote: > After the generation of a local public key, SP800-56A rev 3 section > 5.6.2.1.3 mandates a validation of that key with a full validation > compliant to section 5.6.2.3.3. > > Only if the full validation passes, the key is

[PATCH 2/2] Crypto/chcr: Fix some pr_xxx messages

2020-07-12 Thread Christophe JAILLET
At the top this file, we have: #define pr_fmt(fmt) "chcr:" fmt So there is no need to repeat "chcr : " in some error message when the pr_xxx macro is used. This would lead to log "chcr:chcr : blabla" Signed-off-by: Christophe JAILLET --- drivers/crypto/chelsio/chcr_algo.c | 19 +-

[PATCH 1/2] Crypto/chcr: Avoid some code duplication

2020-07-12 Thread Christophe JAILLET
The error handling path of 'chcr_authenc_setkey()' is the same as this error handling code. So just 'goto out' as done everywhere in the function to simplify the code. Signed-off-by: Christophe JAILLET --- drivers/crypto/chelsio/chcr_algo.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(

[PATCH 1/2] crypto: caam - add tag object functionality

2020-07-12 Thread Iuliana Prodan
A tag object represents the metadata (or simply a header/configuration) and the actual data (e.g. black key) obtained from hardware. Add functionality to tag an object with metadata: - validate metadata: check tag object header; - retrieve metadata: get tag object header configuration, black key co

[PATCH 2/2] crypto: caam - support tagged keys for skcipher algorithms

2020-07-12 Thread Iuliana Prodan
Tagged keys are keys that contain metadata indicating what they are and how to handle them using tag_object API. Add support, for tagged keys, to skcipher algorithms by adding new transformations, with _tk_ prefix to distinguish between plaintext and tagged keys. For job descriptors a new option

[PATCH 0/2] crypto: caam - add tagged keys functionality and tk transformations for skcipher

2020-07-12 Thread Iuliana Prodan
Tagged keys are keys that contain metadata indicating what they are and how to handle them using the new added tag_object API. A tag object represents the metadata (or simply a header/configuration) and the actual data (e.g. black key) obtained from hardware. Patch #2 adds support, for tagged keys,

Re: [PATCH v5 2/8] lib/mpi: Extend the MPI library

2020-07-12 Thread Tianjia Zhang
On 2020/7/10 21:12, Marcelo Henrique Cerri wrote: Hi, Tianjia. On Thu, Jul 09, 2020 at 04:40:09PM +0800, Tianjia Zhang wrote: Expand the mpi library based on libgcrypt, and the ECC algorithm of mpi based on libgcrypt requires these functions. Some other algorithms will be developed based on

Re: [PATCH v2 5/5] crypto: ECDH SP800-56A rev 3 local public key validation

2020-07-12 Thread Stephan Mueller
Am Sonntag, 12. Juli 2020, 20:06:13 CEST schrieb Vitaly Chikunov: Hi Vitaly, > Stephan, > > On Sun, Jul 12, 2020 at 06:42:14PM +0200, Stephan Müller wrote: > > After the generation of a local public key, SP800-56A rev 3 section > > 5.6.2.1.3 mandates a validation of that key with a full validati

Re: [PATCH v2 5/5] crypto: ECDH SP800-56A rev 3 local public key validation

2020-07-12 Thread Vitaly Chikunov
On Mon, Jul 13, 2020 at 07:04:39AM +0200, Stephan Mueller wrote: > Am Sonntag, 12. Juli 2020, 20:06:13 CEST schrieb Vitaly Chikunov: > > Hi Vitaly, > > > Stephan, > > > > On Sun, Jul 12, 2020 at 06:42:14PM +0200, Stephan Müller wrote: > > > After the generation of a local public key, SP800-56A r

Re: [PATCH v2 5/5] crypto: ECDH SP800-56A rev 3 local public key validation

2020-07-12 Thread Stephan Müller
Am Montag, 13. Juli 2020, 07:59:50 CEST schrieb Vitaly Chikunov: Hi Vitaly, > > > > +/* SP800-56A section 5.6.2.3.3 full verification */ > > > > > > Btw, 5.6.2.3.3 is partial validation, 5.6.2.3.2 is full validation > > > routine. > > > > Looking at SP800-56A revision 3 from April 2018 I see: >

[PATCH v31 01/12] Linux Random Number Generator

2020-07-12 Thread Stephan Müller
In an effort to provide a flexible implementation for a random number generator that also delivers entropy during early boot time, allows replacement of the deterministic random number generation mechanism, implement the various components in separate code for easier maintenance, and provide compli

[PATCH v31 07/12] LRNG - add kernel crypto API PRNG extension

2020-07-12 Thread Stephan Müller
Add runtime-pluggable support for all PRNGs that are accessible via the kernel crypto API, including hardware PRNGs. The PRNG is selected with the module parameter drng_name where the name must be one that the kernel crypto API can resolve into an RNG. This allows using of the kernel crypto API PR

[PATCH v31 10/12] LRNG - add SP800-90B compliant health tests

2020-07-12 Thread Stephan Müller
Implement health tests for LRNG's slow noise sources as mandated by SP-800-90B The file contains the following health tests: - stuck test: The stuck test calculates the first, second and third discrete derivative of the time stamp to be processed by the LFSR. Only if all three values are non-z

[PATCH v31 08/12] crypto: provide access to a static Jitter RNG state

2020-07-12 Thread Stephan Müller
To support the LRNG operation which uses the Jitter RNG separately from the kernel crypto API, at a time where potentially the regular memory management is not yet initialized, the Jitter RNG needs to provide a state whose memory is defined at compile time. As only once instance will ever be needed

[PATCH v31 05/12] crypto: DRBG - externalize DRBG functions for LRNG

2020-07-12 Thread Stephan Müller
This patch allows several DRBG functions to be called by the LRNG kernel code paths outside the drbg.c file. 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 Ka

[PATCH v31 12/12] LRNG - add power-on and runtime self-tests

2020-07-12 Thread Stephan Müller
Parts of the LRNG are already covered by self-tests, including: * Self-test of SP800-90A DRBG provided by the Linux kernel crypto API. * Self-test of the PRNG provided by the Linux kernel crypto API. * Raw noise source data testing including SP800-90B compliant tests when enabling CONFIG_LRNG_

[PATCH v31 09/12] LRNG - add Jitter RNG fast noise source

2020-07-12 Thread Stephan Müller
The Jitter RNG fast noise source implemented as part of the kernel crypto API is queried for 256 bits of entropy at the time the seed buffer managed by the LRNG is about to be filled. CC: "Eric W. Biederman" CC: "Alexander E. Patrakov" CC: "Ahmed S. Darwish" CC: "Theodore Y. Ts'o" CC: Willy Ta

[PATCH v31 04/12] LRNG - add switchable DRNG support

2020-07-12 Thread Stephan Müller
The DRNG switch support allows replacing the DRNG mechanism of the LRNG. The switching support rests on the interface definition of include/linux/lrng.h. A new DRNG is implemented by filling in the interface defined in this header file. In addition to the DRNG, the extension also has to provide a

[PATCH v31 06/12] LRNG - add SP800-90A DRBG extension

2020-07-12 Thread Stephan Müller
Using the LRNG switchable DRNG support, the SP800-90A DRBG extension is implemented. The DRBG uses the kernel crypto API DRBG implementation. In addition, it uses the kernel crypto API SHASH support to provide the hashing operation. The DRBG supports the choice of either a CTR DRBG using AES-256,

[PATCH v31 11/12] LRNG - add interface for gathering of raw entropy

2020-07-12 Thread Stephan Müller
The test interface allows a privileged process to capture the raw unconditioned noise that is collected by the LRNG for statistical analysis. Such testing allows the analysis how much entropy the interrupt noise source provides on a given platform. Extracted noise data is not used to seed the LRNG.

[PATCH v31 00/12] /dev/random - a new approach with full SP800-90B

2020-07-12 Thread Stephan Müller
Hi, The following patch set provides a different approach to /dev/random which is called Linux Random Number Generator (LRNG) to collect entropy within the Linux kernel. The main improvements compared to the existing /dev/random is to provide sufficient entropy during boot time as well as in virtu

[PATCH v31 02/12] LRNG - allocate one DRNG instance per NUMA node

2020-07-12 Thread Stephan Müller
In order to improve NUMA-locality when serving getrandom(2) requests, allocate one DRNG instance per node. The DRNG instance that is present right from the start of the kernel is reused as the first per-NUMA-node DRNG. For all remaining online NUMA nodes a new DRNG instance is allocated. During b

[PATCH v31 03/12] LRNG - sysctls and /proc interface

2020-07-12 Thread Stephan Müller
The LRNG sysctl interface provides the same controls as the existing /dev/random implementation. These sysctls behave identically and are implemented identically. The goal is to allow a possible merge of the existing /dev/random implementation with this implementation which implies that this patch