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:
 "Algorithms:
   - add private key generation to ecdh

  Drivers:
   - add generic gcm(aes) to aesni-intel
   - add SafeXcel EIP197 crypto engine driver
   - add ecb(aes), cfb(aes) and ecb(des3_ede) to cavium
   - add support for CNN55XX adapters in cavium
   - add ctr mode to chcr
   - add support for gcm(aes) to omap"

* 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6: (140 commits)
  crypto: testmgr - Reenable sha1/aes in FIPS mode
  crypto: ccp - Release locks before returning
  crypto: cavium/nitrox - dma_mapping_error() returns bool
  crypto: doc - fix typo in docs
  Documentation/bindings: Document the SafeXel cryptographic engine driver
  crypto: caam - fix gfp allocation flags (part II)
  crypto: caam - fix gfp allocation flags (part I)
  crypto: drbg - Fixes panic in wait_for_completion call
  crypto: caam - make of_device_ids const.
  crypto: vmx - remove unnecessary check
  crypto: n2 - make of_device_ids const
  crypto: inside-secure - use the base_end pointer in ring rollback
  crypto: inside-secure - increase the batch size
  crypto: inside-secure - only dequeue when needed
  crypto: inside-secure - get the backlog before dequeueing the request
  crypto: inside-secure - stop requeueing failed requests
  crypto: inside-secure - use one queue per hw ring
  crypto: inside-secure - update the context and request later
  crypto: inside-secure - align the cipher and hash send functions
  crypto: inside-secure - optimize DSE bufferability control
  ...
  • Loading branch information
torvalds committed Jul 5, 2017
2 parents 59005b0 + 035f901 commit 8ad06e5
Show file tree
Hide file tree
Showing 127 changed files with 12,841 additions and 1,535 deletions.
38 changes: 28 additions & 10 deletions Documentation/crypto/api-samples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,9 @@ Code Example For Use of Operational State Memory With SHASH
char ctx[];
};

static struct sdesc init_sdesc(struct crypto_shash *alg)
static struct sdesc *init_sdesc(struct crypto_shash *alg)
{
struct sdesc sdesc;
struct sdesc *sdesc;
int size;

size = sizeof(struct shash_desc) + crypto_shash_descsize(alg);
Expand All @@ -169,15 +169,16 @@ Code Example For Use of Operational State Memory With SHASH
return sdesc;
}

static int calc_hash(struct crypto_shashalg,
const unsigned chardata, unsigned int datalen,
unsigned chardigest) {
struct sdesc sdesc;
static int calc_hash(struct crypto_shash *alg,
const unsigned char *data, unsigned int datalen,
unsigned char *digest)
{
struct sdesc *sdesc;
int ret;

sdesc = init_sdesc(alg);
if (IS_ERR(sdesc)) {
pr_info("trusted_key: can't alloc %s\n", hash_alg);
pr_info("can't alloc sdesc\n");
return PTR_ERR(sdesc);
}

Expand All @@ -186,6 +187,23 @@ Code Example For Use of Operational State Memory With SHASH
return ret;
}

static int test_hash(const unsigned char *data, unsigned int datalen,
unsigned char *digest)
{
struct crypto_shash *alg;
char *hash_alg_name = "sha1-padlock-nano";
int ret;

alg = crypto_alloc_shash(hash_alg_name, CRYPTO_ALG_TYPE_SHASH, 0);
if (IS_ERR(alg)) {
pr_info("can't alloc alg %s\n", hash_alg_name);
return PTR_ERR(alg);
}
ret = calc_hash(alg, data, datalen, digest);
crypto_free_shash(alg);
return ret;
}


Code Example For Random Number Generator Usage
----------------------------------------------
Expand All @@ -195,8 +213,8 @@ Code Example For Random Number Generator Usage

static int get_random_numbers(u8 *buf, unsigned int len)
{
struct crypto_rngrng = NULL;
chardrbg = "drbg_nopr_sha256"; /* Hash DRBG with SHA-256, no PR */
struct crypto_rng *rng = NULL;
char *drbg = "drbg_nopr_sha256"; /* Hash DRBG with SHA-256, no PR */
int ret;

if (!buf || !len) {
Expand All @@ -207,7 +225,7 @@ Code Example For Random Number Generator Usage
rng = crypto_alloc_rng(drbg, 0, 0);
if (IS_ERR(rng)) {
pr_debug("could not allocate RNG handle for %s\n", drbg);
return -PTR_ERR(rng);
return PTR_ERR(rng);
}

ret = crypto_rng_get_bytes(rng, buf, len);
Expand Down
2 changes: 1 addition & 1 deletion Documentation/crypto/userspace-if.rst
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ boundary. Non-aligned data can be used as well, but may require more
operations of the kernel which would defeat the speed gains obtained
from the zero-copy interface.

The system-interent limit for the size of one zero-copy operation is 16
The system-inherent limit for the size of one zero-copy operation is 16
pages. If more data is to be sent to AF_ALG, user space must slice the
input into segments with a maximum size of 16 pages.

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
Inside Secure SafeXcel cryptographic engine

Required properties:
- compatible: Should be "inside-secure,safexcel-eip197".
- reg: Base physical address of the engine and length of memory mapped region.
- interrupts: Interrupt numbers for the rings and engine.
- interrupt-names: Should be "ring0", "ring1", "ring2", "ring3", "eip", "mem".

Optional properties:
- clocks: Reference to the crypto engine clock.
- dma-mask: The address mask limitation. Defaults to 64.

Example:

crypto: crypto@800000 {
compatible = "inside-secure,safexcel-eip197";
reg = <0x800000 0x200000>;
interrupts = <GIC_SPI 34 IRQ_TYPE_LEVEL_HIGH>,
<GIC_SPI 54 IRQ_TYPE_LEVEL_HIGH>,
<GIC_SPI 55 IRQ_TYPE_LEVEL_HIGH>,
<GIC_SPI 56 IRQ_TYPE_LEVEL_HIGH>,
<GIC_SPI 57 IRQ_TYPE_LEVEL_HIGH>,
<GIC_SPI 58 IRQ_TYPE_LEVEL_HIGH>;
interrupt-names = "mem", "ring0", "ring1", "ring2", "ring3",
"eip";
clocks = <&cpm_syscon0 1 26>;
dma-mask = <0xff 0xffffffff>;
status = "disabled";
};
8 changes: 3 additions & 5 deletions Documentation/devicetree/bindings/crypto/mediatek-crypto.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ Required properties:
- interrupts: Should contain the five crypto engines interrupts in numeric
order. These are global system and four descriptor rings.
- clocks: the clock used by the core
- clock-names: the names of the clock listed in the clocks property. These are
"ethif", "cryp"
- clock-names: Must contain "cryp".
- power-domains: Must contain a reference to the PM domain.


Expand All @@ -20,8 +19,7 @@ Example:
<GIC_SPI 84 IRQ_TYPE_LEVEL_LOW>,
<GIC_SPI 91 IRQ_TYPE_LEVEL_LOW>,
<GIC_SPI 97 IRQ_TYPE_LEVEL_LOW>;
clocks = <&topckgen CLK_TOP_ETHIF_SEL>,
<&ethsys CLK_ETHSYS_CRYPTO>;
clock-names = "ethif","cryp";
clocks = <&ethsys CLK_ETHSYS_CRYPTO>;
clock-names = "cryp";
power-domains = <&scpsys MT2701_POWER_DOMAIN_ETH>;
};
4 changes: 3 additions & 1 deletion Documentation/devicetree/bindings/rng/mtk-rng.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ Device-Tree bindings for Mediatek random number generator
found in Mediatek SoC family

Required properties:
- compatible : Should be "mediatek,mt7623-rng"
- compatible : Should be
"mediatek,mt7622-rng", "mediatek,mt7623-rng" : for MT7622
"mediatek,mt7623-rng" : for MT7623
- clocks : list of clock specifiers, corresponding to
entries in clock-names property;
- clock-names : Should contain "rng" entries;
Expand Down
7 changes: 7 additions & 0 deletions Documentation/devicetree/bindings/rng/timeriomem_rng.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ Required properties:
- reg : base address to sample from
- period : wait time in microseconds to use between samples

Optional properties:
- quality : estimated number of bits of true entropy per 1024 bits read from the
rng. Defaults to zero which causes the kernel's default quality to
be used instead. Note that the default quality is usually zero
which disables using this rng to automatically fill the kernel's
entropy pool.

N.B. currently 'reg' must be four bytes wide and aligned

Example:
Expand Down
18 changes: 18 additions & 0 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -3746,6 +3746,13 @@ S: Supported
F: drivers/infiniband/hw/cxgb4/
F: include/uapi/rdma/cxgb4-abi.h

CXGB4 CRYPTO DRIVER (chcr)
M: Harsh Jain <[email protected]>
L: [email protected]
W: http://www.chelsio.com
S: Supported
F: drivers/crypto/chelsio

CXGB4VF ETHERNET DRIVER (CXGB4VF)
M: Casey Leedom <[email protected]>
L: [email protected]
Expand Down Expand Up @@ -6647,6 +6654,12 @@ F: Documentation/input/multi-touch-protocol.rst
F: drivers/input/input-mt.c
K: \b(ABS|SYN)_MT_

INSIDE SECURE CRYPTO DRIVER
M: Antoine Tenart <[email protected]>
F: drivers/crypto/inside-secure/
S: Maintained
L: [email protected]

INTEL ASoC BDW/HSW DRIVERS
M: Jie Yang <[email protected]>
L: [email protected] (moderated for non-subscribers)
Expand Down Expand Up @@ -8306,6 +8319,11 @@ L: [email protected]
S: Maintained
F: drivers/net/wireless/mediatek/mt7601u/

MEDIATEK RANDOM NUMBER GENERATOR SUPPORT
M: Sean Wang <[email protected]>
S: Maintained
F: drivers/char/hw_random/mtk-rng.c

MEGACHIPS STDPXXXX-GE-B850V3-FW LVDS/DP++ BRIDGES
M: Peter Senna Tschudin <[email protected]>
M: Martin Donnelly <[email protected]>
Expand Down
6 changes: 2 additions & 4 deletions arch/arm/crypto/aes-ce-glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <crypto/aes.h>
#include <crypto/internal/simd.h>
#include <crypto/internal/skcipher.h>
#include <linux/cpufeature.h>
#include <linux/module.h>
#include <crypto/xts.h>

Expand Down Expand Up @@ -425,9 +426,6 @@ static int __init aes_init(void)
int err;
int i;

if (!(elf_hwcap2 & HWCAP2_AES))
return -ENODEV;

err = crypto_register_skciphers(aes_algs, ARRAY_SIZE(aes_algs));
if (err)
return err;
Expand All @@ -451,5 +449,5 @@ static int __init aes_init(void)
return err;
}

module_init(aes_init);
module_cpu_feature_match(AES, aes_init);
module_exit(aes_exit);
6 changes: 6 additions & 0 deletions arch/arm/crypto/crc32-ce-glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* published by the Free Software Foundation.
*/

#include <linux/cpufeature.h>
#include <linux/crc32.h>
#include <linux/init.h>
#include <linux/kernel.h>
Expand Down Expand Up @@ -233,6 +234,11 @@ static void __exit crc32_pmull_mod_exit(void)
ARRAY_SIZE(crc32_pmull_algs));
}

static const struct cpu_feature crc32_cpu_feature[] = {
{ cpu_feature(CRC32) }, { cpu_feature(PMULL) }, { }
};
MODULE_DEVICE_TABLE(cpu, crc32_cpu_feature);

module_init(crc32_pmull_mod_init);
module_exit(crc32_pmull_mod_exit);

Expand Down
6 changes: 2 additions & 4 deletions arch/arm/crypto/ghash-ce-glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <crypto/cryptd.h>
#include <crypto/internal/hash.h>
#include <crypto/gf128mul.h>
#include <linux/cpufeature.h>
#include <linux/crypto.h>
#include <linux/module.h>

Expand Down Expand Up @@ -311,9 +312,6 @@ static int __init ghash_ce_mod_init(void)
{
int err;

if (!(elf_hwcap2 & HWCAP2_PMULL))
return -ENODEV;

err = crypto_register_shash(&ghash_alg);
if (err)
return err;
Expand All @@ -334,5 +332,5 @@ static void __exit ghash_ce_mod_exit(void)
crypto_unregister_shash(&ghash_alg);
}

module_init(ghash_ce_mod_init);
module_cpu_feature_match(PMULL, ghash_ce_mod_init);
module_exit(ghash_ce_mod_exit);
5 changes: 2 additions & 3 deletions arch/arm/crypto/sha1-ce-glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <crypto/internal/hash.h>
#include <crypto/sha.h>
#include <crypto/sha1_base.h>
#include <linux/cpufeature.h>
#include <linux/crypto.h>
#include <linux/module.h>

Expand Down Expand Up @@ -82,8 +83,6 @@ static struct shash_alg alg = {

static int __init sha1_ce_mod_init(void)
{
if (!(elf_hwcap2 & HWCAP2_SHA1))
return -ENODEV;
return crypto_register_shash(&alg);
}

Expand All @@ -92,5 +91,5 @@ static void __exit sha1_ce_mod_fini(void)
crypto_unregister_shash(&alg);
}

module_init(sha1_ce_mod_init);
module_cpu_feature_match(SHA1, sha1_ce_mod_init);
module_exit(sha1_ce_mod_fini);
5 changes: 2 additions & 3 deletions arch/arm/crypto/sha2-ce-glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <crypto/internal/hash.h>
#include <crypto/sha.h>
#include <crypto/sha256_base.h>
#include <linux/cpufeature.h>
#include <linux/crypto.h>
#include <linux/module.h>

Expand Down Expand Up @@ -100,8 +101,6 @@ static struct shash_alg algs[] = { {

static int __init sha2_ce_mod_init(void)
{
if (!(elf_hwcap2 & HWCAP2_SHA2))
return -ENODEV;
return crypto_register_shashes(algs, ARRAY_SIZE(algs));
}

Expand All @@ -110,5 +109,5 @@ static void __exit sha2_ce_mod_fini(void)
crypto_unregister_shashes(algs, ARRAY_SIZE(algs));
}

module_init(sha2_ce_mod_init);
module_cpu_feature_match(SHA2, sha2_ce_mod_init);
module_exit(sha2_ce_mod_fini);
6 changes: 4 additions & 2 deletions arch/arm64/crypto/sha1-ce-core.S
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ ENTRY(sha1_ce_transform)
ldr dgb, [x0, #16]

/* load sha1_ce_state::finalize */
ldr w4, [x0, #:lo12:sha1_ce_offsetof_finalize]
ldr_l w4, sha1_ce_offsetof_finalize, x4
ldr w4, [x0, x4]

/* load input */
0: ld1 {v8.4s-v11.4s}, [x1], #64
Expand Down Expand Up @@ -132,7 +133,8 @@ CPU_LE( rev32 v11.16b, v11.16b )
* the padding is handled by the C code in that case.
*/
cbz x4, 3f
ldr x4, [x0, #:lo12:sha1_ce_offsetof_count]
ldr_l w4, sha1_ce_offsetof_count, x4
ldr x4, [x0, x4]
movi v9.2d, #0
mov x8, #0x80000000
movi v10.2d, #0
Expand Down
11 changes: 3 additions & 8 deletions arch/arm64/crypto/sha1-ce-glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@
#include <linux/crypto.h>
#include <linux/module.h>

#define ASM_EXPORT(sym, val) \
asm(".globl " #sym "; .set " #sym ", %0" :: "I"(val));

MODULE_DESCRIPTION("SHA1 secure hash using ARMv8 Crypto Extensions");
MODULE_AUTHOR("Ard Biesheuvel <[email protected]>");
MODULE_LICENSE("GPL v2");
Expand All @@ -32,6 +29,9 @@ struct sha1_ce_state {
asmlinkage void sha1_ce_transform(struct sha1_ce_state *sst, u8 const *src,
int blocks);

const u32 sha1_ce_offsetof_count = offsetof(struct sha1_ce_state, sst.count);
const u32 sha1_ce_offsetof_finalize = offsetof(struct sha1_ce_state, finalize);

static int sha1_ce_update(struct shash_desc *desc, const u8 *data,
unsigned int len)
{
Expand All @@ -52,11 +52,6 @@ static int sha1_ce_finup(struct shash_desc *desc, const u8 *data,
struct sha1_ce_state *sctx = shash_desc_ctx(desc);
bool finalize = !sctx->sst.count && !(len % SHA1_BLOCK_SIZE);

ASM_EXPORT(sha1_ce_offsetof_count,
offsetof(struct sha1_ce_state, sst.count));
ASM_EXPORT(sha1_ce_offsetof_finalize,
offsetof(struct sha1_ce_state, finalize));

/*
* Allow the asm code to perform the finalization if there is no
* partial data and the input is a round multiple of the block size.
Expand Down
6 changes: 4 additions & 2 deletions arch/arm64/crypto/sha2-ce-core.S
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ ENTRY(sha2_ce_transform)
ld1 {dgav.4s, dgbv.4s}, [x0]

/* load sha256_ce_state::finalize */
ldr w4, [x0, #:lo12:sha256_ce_offsetof_finalize]
ldr_l w4, sha256_ce_offsetof_finalize, x4
ldr w4, [x0, x4]

/* load input */
0: ld1 {v16.4s-v19.4s}, [x1], #64
Expand Down Expand Up @@ -136,7 +137,8 @@ CPU_LE( rev32 v19.16b, v19.16b )
* the padding is handled by the C code in that case.
*/
cbz x4, 3f
ldr x4, [x0, #:lo12:sha256_ce_offsetof_count]
ldr_l w4, sha256_ce_offsetof_count, x4
ldr x4, [x0, x4]
movi v17.2d, #0
mov x8, #0x80000000
movi v18.2d, #0
Expand Down
Loading

0 comments on commit 8ad06e5

Please sign in to comment.