Skip to content

Commit

Permalink
Merge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git…
Browse files Browse the repository at this point in the history
…/herbert/crypto-2.6

Pull crypto updates from Herbert Xu:
 "API:
   - Add support for allocating transforms on a specific NUMA Node
   - Introduce the flag CRYPTO_ALG_ALLOCATES_MEMORY for storage users

  Algorithms:
   - Drop PMULL based ghash on arm64
   - Fixes for building with clang on x86
   - Add sha256 helper that does the digest in one go
   - Add SP800-56A rev 3 validation checks to dh

  Drivers:
   - Permit users to specify NUMA node in hisilicon/zip
   - Add support for i.MX6 in imx-rngc
   - Add sa2ul crypto driver
   - Add BA431 hwrng driver
   - Add Ingenic JZ4780 and X1000 hwrng driver
   - Spread IRQ affinity in inside-secure and marvell/cesa"

* 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6: (157 commits)
  crypto: sa2ul - Fix inconsistent IS_ERR and PTR_ERR
  hwrng: core - remove redundant initialization of variable ret
  crypto: x86/curve25519 - Remove unused carry variables
  crypto: ingenic - Add hardware RNG for Ingenic JZ4780 and X1000
  dt-bindings: RNG: Add Ingenic RNG bindings.
  crypto: caam/qi2 - add module alias
  crypto: caam - add more RNG hw error codes
  crypto: caam/jr - remove incorrect reference to caam_jr_register()
  crypto: caam - silence .setkey in case of bad key length
  crypto: caam/qi2 - create ahash shared descriptors only once
  crypto: caam/qi2 - fix error reporting for caam_hash_alloc
  crypto: caam - remove deadcode on 32-bit platforms
  crypto: ccp - use generic power management
  crypto: xts - Replace memcpy() invocation with simple assignment
  crypto: marvell/cesa - irq balance
  crypto: inside-secure - irq balance
  crypto: ecc - SP800-56A rev 3 local public key validation
  crypto: dh - SP800-56A rev 3 local public key validation
  crypto: dh - check validity of Z before export
  lib/mpi: Add mpi_sub_ui()
  ...
  • Loading branch information
torvalds committed Aug 3, 2020
2 parents 5577416 + 3cbfe80 commit ab5c60b
Show file tree
Hide file tree
Showing 257 changed files with 6,648 additions and 5,497 deletions.
18 changes: 3 additions & 15 deletions Documentation/core-api/padata.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,11 @@ padata_instance structure for overall control of how jobs are to be run::

#include <linux/padata.h>

struct padata_instance *padata_alloc_possible(const char *name);
struct padata_instance *padata_alloc(const char *name);

'name' simply identifies the instance.

There are functions for enabling and disabling the instance::

int padata_start(struct padata_instance *pinst);
void padata_stop(struct padata_instance *pinst);

These functions are setting or clearing the "PADATA_INIT" flag; if that flag is
not set, other functions will refuse to work. padata_start() returns zero on
success (flag set) or -EINVAL if the padata cpumask contains no active CPU
(flag not set). padata_stop() clears the flag and blocks until the padata
instance is unused.

Finally, complete padata initialization by allocating a padata_shell::
Then, complete padata initialization by allocating a padata_shell::

struct padata_shell *padata_alloc_shell(struct padata_instance *pinst);

Expand Down Expand Up @@ -155,11 +144,10 @@ submitted.
Destroying
----------

Cleaning up a padata instance predictably involves calling the three free
Cleaning up a padata instance predictably involves calling the two free
functions that correspond to the allocation in reverse::

void padata_free_shell(struct padata_shell *ps);
void padata_stop(struct padata_instance *pinst);
void padata_free(struct padata_instance *pinst);

It is the user's responsibility to ensure all outstanding jobs are complete
Expand Down
2 changes: 1 addition & 1 deletion Documentation/crypto/api-intro.txt
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ Portions of this API were derived from the following projects:

and;

Nettle (http://www.lysator.liu.se/~nisse/nettle/)
Nettle (https://www.lysator.liu.se/~nisse/nettle/)
Niels Möller

Original developers of the crypto algorithms:
Expand Down
4 changes: 2 additions & 2 deletions Documentation/crypto/userspace-if.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ user space, however. This includes the difference between synchronous
and asynchronous invocations. The user space API call is fully
synchronous.

[1] http://www.chronox.de/libkcapi.html
[1] https://www.chronox.de/libkcapi.html

User Space API General Remarks
------------------------------
Expand Down Expand Up @@ -384,4 +384,4 @@ Please see [1] for libkcapi which provides an easy-to-use wrapper around
the aforementioned Netlink kernel interface. [1] also contains a test
application that invokes all libkcapi API calls.

[1] http://www.chronox.de/libkcapi.html
[1] https://www.chronox.de/libkcapi.html
76 changes: 76 additions & 0 deletions Documentation/devicetree/bindings/crypto/ti,sa2ul.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# SPDX-License-Identifier: (GPL-2.0-only or BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/crypto/ti,sa2ul.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: K3 SoC SA2UL crypto module

maintainers:
- Tero Kristo <[email protected]>

properties:
compatible:
enum:
- ti,j721e-sa2ul
- ti,am654-sa2ul

reg:
maxItems: 1

power-domains:
maxItems: 1

dmas:
items:
- description: TX DMA Channel
- description: RX DMA Channel #1
- description: RX DMA Channel #2

dma-names:
items:
- const: tx
- const: rx1
- const: rx2

dma-coherent: true

"#address-cells":
const: 2

"#size-cells":
const: 2

ranges:
description:
Address translation for the possible RNG child node for SA2UL

patternProperties:
"^rng@[a-f0-9]+$":
type: object
description:
Child RNG node for SA2UL

required:
- compatible
- reg
- power-domains
- dmas
- dma-names
- dma-coherent

additionalProperties: false

examples:
- |
#include <dt-bindings/soc/ti,sci_pm_domain.h>
main_crypto: crypto@4e00000 {
compatible = "ti,j721-sa2ul";
reg = <0x0 0x4e00000 0x0 0x1200>;
power-domains = <&k3_pds 264 TI_SCI_PD_EXCLUSIVE>;
dmas = <&main_udmap 0xc000>, <&main_udmap 0x4000>,
<&main_udmap 0x4001>;
dma-names = "tx", "rx1", "rx2";
dma-coherent;
};
3 changes: 3 additions & 0 deletions Documentation/devicetree/bindings/rng/imx-rng.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ Required properties:
"fsl,imx21-rnga"
"fsl,imx31-rnga" (backward compatible with "fsl,imx21-rnga")
"fsl,imx25-rngb"
"fsl,imx6sl-rngb" (backward compatible with "fsl,imx25-rngb")
"fsl,imx6sll-rngb" (backward compatible with "fsl,imx25-rngb")
"fsl,imx6ull-rngb" (backward compatible with "fsl,imx25-rngb")
"fsl,imx35-rngc"
- reg : offset and length of the register set of this block
- interrupts : the interrupt number for the RNG block
Expand Down
36 changes: 36 additions & 0 deletions Documentation/devicetree/bindings/rng/ingenic,rng.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/rng/ingenic,rng.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: Bindings for RNG in Ingenic SoCs

maintainers:
- 周琰杰 (Zhou Yanjie) <[email protected]>

description:
The Random Number Generator in Ingenic SoCs.

properties:
compatible:
enum:
- ingenic,jz4780-rng
- ingenic,x1000-rng

reg:
maxItems: 1

required:
- compatible
- reg

additionalProperties: false

examples:
- |
rng: rng@d8 {
compatible = "ingenic,jz4780-rng";
reg = <0xd8 0x8>;
};
...
36 changes: 36 additions & 0 deletions Documentation/devicetree/bindings/rng/silex-insight,ba431-rng.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/rng/silex-insight,ba431-rng.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: Silex Insight BA431 RNG bindings

description: |
The BA431 hardware random number generator is an IP that is FIPS-140-2/3
certified.
maintainers:
- Olivier Sobrie <[email protected]>

properties:
compatible:
const: silex-insight,ba431-rng

reg:
maxItems: 1

required:
- compatible
- reg

additionalProperties: false

examples:
- |
rng@42800000 {
compatible = "silex-insight,ba431-rng";
reg = <0x42800000 0x1000>;
};
...
9 changes: 9 additions & 0 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -830,11 +830,20 @@ F: include/uapi/rdma/efa-abi.h

AMD CRYPTOGRAPHIC COPROCESSOR (CCP) DRIVER
M: Tom Lendacky <[email protected]>
M: John Allen <[email protected]>
L: [email protected]
S: Supported
F: drivers/crypto/ccp/
F: include/linux/ccp.h

AMD CRYPTOGRAPHIC COPROCESSOR (CCP) DRIVER - SEV SUPPORT
M: Brijesh Singh <[email protected]>
M: Tom Lendacky <[email protected]>
L: [email protected]
S: Supported
F: drivers/crypto/ccp/sev*
F: include/uapi/linux/psp-sev.h

AMD DISPLAY CORE
M: Harry Wentland <[email protected]>
M: Leo Li <[email protected]>
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/crypto/crc32-ce-core.S
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
* CRC32 polynomial:0x04c11db7(BE)/0xEDB88320(LE)
* PCLMULQDQ is a new instruction in Intel SSE4.2, the reference can be found
* at:
* http://www.intel.com/products/processor/manuals/
* https://www.intel.com/products/processor/manuals/
* Intel(R) 64 and IA-32 Architectures Software Developer's Manual
* Volume 2B: Instruction Set Reference, N-Z
*
Expand Down
51 changes: 24 additions & 27 deletions arch/arm/crypto/ghash-ce-glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <crypto/gf128mul.h>
#include <linux/cpufeature.h>
#include <linux/crypto.h>
#include <linux/jump_label.h>
#include <linux/module.h>

MODULE_DESCRIPTION("GHASH hash function using ARMv8 Crypto Extensions");
Expand All @@ -27,12 +28,8 @@ MODULE_ALIAS_CRYPTO("ghash");
#define GHASH_DIGEST_SIZE 16

struct ghash_key {
u64 h[2];
u64 h2[2];
u64 h3[2];
u64 h4[2];

be128 k;
u64 h[][2];
};

struct ghash_desc_ctx {
Expand All @@ -46,16 +43,12 @@ struct ghash_async_ctx {
};

asmlinkage void pmull_ghash_update_p64(int blocks, u64 dg[], const char *src,
struct ghash_key const *k,
const char *head);
u64 const h[][2], const char *head);

asmlinkage void pmull_ghash_update_p8(int blocks, u64 dg[], const char *src,
struct ghash_key const *k,
const char *head);
u64 const h[][2], const char *head);

static void (*pmull_ghash_update)(int blocks, u64 dg[], const char *src,
struct ghash_key const *k,
const char *head);
static __ro_after_init DEFINE_STATIC_KEY_FALSE(use_p64);

static int ghash_init(struct shash_desc *desc)
{
Expand All @@ -70,7 +63,10 @@ static void ghash_do_update(int blocks, u64 dg[], const char *src,
{
if (likely(crypto_simd_usable())) {
kernel_neon_begin();
pmull_ghash_update(blocks, dg, src, key, head);
if (static_branch_likely(&use_p64))
pmull_ghash_update_p64(blocks, dg, src, key->h, head);
else
pmull_ghash_update_p8(blocks, dg, src, key->h, head);
kernel_neon_end();
} else {
be128 dst = { cpu_to_be64(dg[1]), cpu_to_be64(dg[0]) };
Expand Down Expand Up @@ -161,25 +157,26 @@ static int ghash_setkey(struct crypto_shash *tfm,
const u8 *inkey, unsigned int keylen)
{
struct ghash_key *key = crypto_shash_ctx(tfm);
be128 h;

if (keylen != GHASH_BLOCK_SIZE)
return -EINVAL;

/* needed for the fallback */
memcpy(&key->k, inkey, GHASH_BLOCK_SIZE);
ghash_reflect(key->h, &key->k);
ghash_reflect(key->h[0], &key->k);

h = key->k;
gf128mul_lle(&h, &key->k);
ghash_reflect(key->h2, &h);
if (static_branch_likely(&use_p64)) {
be128 h = key->k;

gf128mul_lle(&h, &key->k);
ghash_reflect(key->h3, &h);
gf128mul_lle(&h, &key->k);
ghash_reflect(key->h[1], &h);

gf128mul_lle(&h, &key->k);
ghash_reflect(key->h4, &h);
gf128mul_lle(&h, &key->k);
ghash_reflect(key->h[2], &h);

gf128mul_lle(&h, &key->k);
ghash_reflect(key->h[3], &h);
}
return 0;
}

Expand All @@ -195,7 +192,7 @@ static struct shash_alg ghash_alg = {
.base.cra_driver_name = "ghash-ce-sync",
.base.cra_priority = 300 - 1,
.base.cra_blocksize = GHASH_BLOCK_SIZE,
.base.cra_ctxsize = sizeof(struct ghash_key),
.base.cra_ctxsize = sizeof(struct ghash_key) + sizeof(u64[2]),
.base.cra_module = THIS_MODULE,
};

Expand Down Expand Up @@ -354,10 +351,10 @@ static int __init ghash_ce_mod_init(void)
if (!(elf_hwcap & HWCAP_NEON))
return -ENODEV;

if (elf_hwcap2 & HWCAP2_PMULL)
pmull_ghash_update = pmull_ghash_update_p64;
else
pmull_ghash_update = pmull_ghash_update_p8;
if (elf_hwcap2 & HWCAP2_PMULL) {
ghash_alg.base.cra_ctxsize += 3 * sizeof(u64[2]);
static_branch_enable(&use_p64);
}

err = crypto_register_shash(&ghash_alg);
if (err)
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/crypto/sha1-armv4-large.S
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
@ Written by Andy Polyakov <[email protected]> for the OpenSSL
@ project. The module is, however, dual licensed under OpenSSL and
@ CRYPTOGAMS licenses depending on where you obtain it. For further
@ details see http://www.openssl.org/~appro/cryptogams/.
@ details see https://www.openssl.org/~appro/cryptogams/.
@ ====================================================================

@ sha1_block procedure for ARMv4.
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/crypto/sha256-armv4.pl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# Written by Andy Polyakov <[email protected]> for the OpenSSL
# project. The module is, however, dual licensed under OpenSSL and
# CRYPTOGAMS licenses depending on where you obtain it. For further
# details see http://www.openssl.org/~appro/cryptogams/.
# details see https://www.openssl.org/~appro/cryptogams/.
# ====================================================================

# SHA256 block procedure for ARMv4. May 2007.
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/crypto/sha256-core.S_shipped
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
@ Written by Andy Polyakov <[email protected]> for the OpenSSL
@ project. The module is, however, dual licensed under OpenSSL and
@ CRYPTOGAMS licenses depending on where you obtain it. For further
@ details see http://www.openssl.org/~appro/cryptogams/.
@ details see https://www.openssl.org/~appro/cryptogams/.
@ ====================================================================

@ SHA256 block procedure for ARMv4. May 2007.
Expand Down
Loading

0 comments on commit ab5c60b

Please sign in to comment.