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:

   - crypto_destroy_tfm now ignores errors as well as NULL pointers

  Algorithms:

   - Add explicit curve IDs in ECDH algorithm names

   - Add NIST P384 curve parameters

   - Add ECDSA

  Drivers:

   - Add support for Green Sardine in ccp

   - Add ecdh/curve25519 to hisilicon/hpre

   - Add support for AM64 in sa2ul"

* 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6: (184 commits)
  fsverity: relax build time dependency on CRYPTO_SHA256
  fscrypt: relax Kconfig dependencies for crypto API algorithms
  crypto: camellia - drop duplicate "depends on CRYPTO"
  crypto: s5p-sss - consistently use local 'dev' variable in probe()
  crypto: s5p-sss - remove unneeded local variable initialization
  crypto: s5p-sss - simplify getting of_device_id match data
  ccp: ccp - add support for Green Sardine
  crypto: ccp - Make ccp_dev_suspend and ccp_dev_resume void functions
  crypto: octeontx2 - add support for OcteonTX2 98xx CPT block.
  crypto: chelsio/chcr - Remove useless MODULE_VERSION
  crypto: ux500/cryp - Remove duplicate argument
  crypto: chelsio - remove unused function
  crypto: sa2ul - Add support for AM64
  crypto: sa2ul - Support for per channel coherency
  dt-bindings: crypto: ti,sa2ul: Add new compatible for AM64
  crypto: hisilicon - enable new error types for QM
  crypto: hisilicon - add new error type for SEC
  crypto: hisilicon - support new error types for ZIP
  crypto: hisilicon - dynamic configuration 'err_info'
  crypto: doc - fix kernel-doc notation in chacha.c and af_alg.c
  ...
  • Loading branch information
torvalds committed Apr 26, 2021
2 parents ffc766b + e3a606f commit a4a78bc
Show file tree
Hide file tree
Showing 209 changed files with 4,558 additions and 1,986 deletions.
24 changes: 23 additions & 1 deletion Documentation/devicetree/bindings/crypto/ti,sa2ul.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ properties:
enum:
- ti,j721e-sa2ul
- ti,am654-sa2ul
- ti,am64-sa2ul

reg:
maxItems: 1
Expand Down Expand Up @@ -45,6 +46,18 @@ properties:
description:
Address translation for the possible RNG child node for SA2UL

clocks:
items:
- description: Clock used by PKA
- description: Main Input Clock
- description: Clock used by rng

clock-names:
items:
- const: pka_in_clk
- const: x1_clk
- const: x2_clk

patternProperties:
"^rng@[a-f0-9]+$":
type: object
Expand All @@ -57,7 +70,16 @@ required:
- power-domains
- dmas
- dma-names
- dma-coherent

if:
properties:
compatible:
enum:
- ti,j721e-sa2ul
- ti,am654-sa2ul
then:
required:
- dma-coherent

additionalProperties: false

Expand Down
21 changes: 21 additions & 0 deletions Documentation/devicetree/bindings/rng/brcm,bcm2835.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,31 @@ properties:
clock-names:
const: ipsec

resets:
maxItems: 1

reset-names:
const: ipsec

interrupts:
maxItems: 1

required:
- compatible
- reg

if:
properties:
compatible:
enum:
- brcm,bcm6368-rng
then:
required:
- clocks
- clock-names
- resets
- reset-names

additionalProperties: false

examples:
Expand All @@ -58,4 +76,7 @@ examples:
clocks = <&periph_clk 18>;
clock-names = "ipsec";
resets = <&periph_rst 4>;
reset-names = "ipsec";
};
42 changes: 10 additions & 32 deletions arch/arm/crypto/aes-cipher-core.S
Original file line number Diff line number Diff line change
Expand Up @@ -99,28 +99,6 @@
__hround \out2, \out3, \in2, \in1, \in0, \in3, \in1, \in0, 0, \sz, \op, \oldcpsr
.endm

.macro __rev, out, in
.if __LINUX_ARM_ARCH__ < 6
lsl t0, \in, #24
and t1, \in, #0xff00
and t2, \in, #0xff0000
orr \out, t0, \in, lsr #24
orr \out, \out, t1, lsl #8
orr \out, \out, t2, lsr #8
.else
rev \out, \in
.endif
.endm

.macro __adrl, out, sym, c
.if __LINUX_ARM_ARCH__ < 7
ldr\c \out, =\sym
.else
movw\c \out, #:lower16:\sym
movt\c \out, #:upper16:\sym
.endif
.endm

.macro do_crypt, round, ttab, ltab, bsz
push {r3-r11, lr}

Expand All @@ -133,18 +111,18 @@
ldr r7, [in, #12]

#ifdef CONFIG_CPU_BIG_ENDIAN
__rev r4, r4
__rev r5, r5
__rev r6, r6
__rev r7, r7
rev_l r4, t0
rev_l r5, t0
rev_l r6, t0
rev_l r7, t0
#endif

eor r4, r4, r8
eor r5, r5, r9
eor r6, r6, r10
eor r7, r7, r11

__adrl ttab, \ttab
mov_l ttab, \ttab
/*
* Disable interrupts and prefetch the 1024-byte 'ft' or 'it' table into
* L1 cache, assuming cacheline size >= 32. This is a hardening measure
Expand Down Expand Up @@ -180,7 +158,7 @@
2: .ifb \ltab
add ttab, ttab, #1
.else
__adrl ttab, \ltab
mov_l ttab, \ltab
// Prefetch inverse S-box for final round; see explanation above
.set i, 0
.rept 256 / 64
Expand All @@ -194,10 +172,10 @@
\round r4, r5, r6, r7, r8, r9, r10, r11, \bsz, b, rounds

#ifdef CONFIG_CPU_BIG_ENDIAN
__rev r4, r4
__rev r5, r5
__rev r6, r6
__rev r7, r7
rev_l r4, t0
rev_l r5, t0
rev_l r6, t0
rev_l r7, t0
#endif

ldr out, [sp]
Expand Down
4 changes: 2 additions & 2 deletions arch/arm/crypto/blake2b-neon-glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ static int __init blake2b_neon_mod_init(void)

static void __exit blake2b_neon_mod_exit(void)
{
return crypto_unregister_shashes(blake2b_neon_algs,
ARRAY_SIZE(blake2b_neon_algs));
crypto_unregister_shashes(blake2b_neon_algs,
ARRAY_SIZE(blake2b_neon_algs));
}

module_init(blake2b_neon_mod_init);
Expand Down
21 changes: 21 additions & 0 deletions arch/arm/crypto/blake2s-core.S
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*/

#include <linux/linkage.h>
#include <asm/assembler.h>

// Registers used to hold message words temporarily. There aren't
// enough ARM registers to hold the whole message block, so we have to
Expand Down Expand Up @@ -38,6 +39,23 @@
#endif
.endm

.macro _le32_bswap a, tmp
#ifdef __ARMEB__
rev_l \a, \tmp
#endif
.endm

.macro _le32_bswap_8x a, b, c, d, e, f, g, h, tmp
_le32_bswap \a, \tmp
_le32_bswap \b, \tmp
_le32_bswap \c, \tmp
_le32_bswap \d, \tmp
_le32_bswap \e, \tmp
_le32_bswap \f, \tmp
_le32_bswap \g, \tmp
_le32_bswap \h, \tmp
.endm

// Execute a quarter-round of BLAKE2s by mixing two columns or two diagonals.
// (a0, b0, c0, d0) and (a1, b1, c1, d1) give the registers containing the two
// columns/diagonals. s0-s1 are the word offsets to the message words the first
Expand Down Expand Up @@ -180,8 +198,10 @@ ENTRY(blake2s_compress_arch)
tst r1, #3
bne .Lcopy_block_misaligned
ldmia r1!, {r2-r9}
_le32_bswap_8x r2, r3, r4, r5, r6, r7, r8, r9, r14
stmia r12!, {r2-r9}
ldmia r1!, {r2-r9}
_le32_bswap_8x r2, r3, r4, r5, r6, r7, r8, r9, r14
stmia r12, {r2-r9}
.Lcopy_block_done:
str r1, [sp, #68] // Update message pointer
Expand Down Expand Up @@ -268,6 +288,7 @@ ENTRY(blake2s_compress_arch)
1:
#ifdef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
ldr r3, [r1], #4
_le32_bswap r3, r4
#else
ldrb r3, [r1, #0]
ldrb r4, [r1, #1]
Expand Down
43 changes: 13 additions & 30 deletions arch/arm/crypto/chacha-scalar-core.S
Original file line number Diff line number Diff line change
Expand Up @@ -41,32 +41,15 @@
X14 .req r12
X15 .req r14

.macro __rev out, in, t0, t1, t2
.if __LINUX_ARM_ARCH__ >= 6
rev \out, \in
.else
lsl \t0, \in, #24
and \t1, \in, #0xff00
and \t2, \in, #0xff0000
orr \out, \t0, \in, lsr #24
orr \out, \out, \t1, lsl #8
orr \out, \out, \t2, lsr #8
.endif
.endm

.macro _le32_bswap x, t0, t1, t2
.macro _le32_bswap_4x a, b, c, d, tmp
#ifdef __ARMEB__
__rev \x, \x, \t0, \t1, \t2
rev_l \a, \tmp
rev_l \b, \tmp
rev_l \c, \tmp
rev_l \d, \tmp
#endif
.endm

.macro _le32_bswap_4x a, b, c, d, t0, t1, t2
_le32_bswap \a, \t0, \t1, \t2
_le32_bswap \b, \t0, \t1, \t2
_le32_bswap \c, \t0, \t1, \t2
_le32_bswap \d, \t0, \t1, \t2
.endm

.macro __ldrd a, b, src, offset
#if __LINUX_ARM_ARCH__ >= 6
ldrd \a, \b, [\src, #\offset]
Expand Down Expand Up @@ -200,7 +183,7 @@
add X1, X1, r9
add X2, X2, r10
add X3, X3, r11
_le32_bswap_4x X0, X1, X2, X3, r8, r9, r10
_le32_bswap_4x X0, X1, X2, X3, r8
ldmia r12!, {r8-r11}
eor X0, X0, r8
eor X1, X1, r9
Expand All @@ -216,7 +199,7 @@
ldmia r12!, {X0-X3}
add X6, r10, X6, ror #brot
add X7, r11, X7, ror #brot
_le32_bswap_4x X4, X5, X6, X7, r8, r9, r10
_le32_bswap_4x X4, X5, X6, X7, r8
eor X4, X4, X0
eor X5, X5, X1
eor X6, X6, X2
Expand All @@ -231,7 +214,7 @@
add r1, r1, r9 // x9
add r6, r6, r10 // x10
add r7, r7, r11 // x11
_le32_bswap_4x r0, r1, r6, r7, r8, r9, r10
_le32_bswap_4x r0, r1, r6, r7, r8
ldmia r12!, {r8-r11}
eor r0, r0, r8 // x8
eor r1, r1, r9 // x9
Expand All @@ -245,7 +228,7 @@
add r3, r9, r3, ror #drot // x13
add r4, r10, r4, ror #drot // x14
add r5, r11, r5, ror #drot // x15
_le32_bswap_4x r2, r3, r4, r5, r9, r10, r11
_le32_bswap_4x r2, r3, r4, r5, r9
ldr r9, [sp, #72] // load LEN
eor r2, r2, r0 // x12
eor r3, r3, r1 // x13
Expand Down Expand Up @@ -301,7 +284,7 @@
add X1, X1, r9
add X2, X2, r10
add X3, X3, r11
_le32_bswap_4x X0, X1, X2, X3, r8, r9, r10
_le32_bswap_4x X0, X1, X2, X3, r8
stmia r14!, {X0-X3}

// Save keystream for x4-x7
Expand All @@ -311,7 +294,7 @@
add X5, r9, X5, ror #brot
add X6, r10, X6, ror #brot
add X7, r11, X7, ror #brot
_le32_bswap_4x X4, X5, X6, X7, r8, r9, r10
_le32_bswap_4x X4, X5, X6, X7, r8
add r8, sp, #64
stmia r14!, {X4-X7}

Expand All @@ -323,15 +306,15 @@
add r1, r1, r9 // x9
add r6, r6, r10 // x10
add r7, r7, r11 // x11
_le32_bswap_4x r0, r1, r6, r7, r8, r9, r10
_le32_bswap_4x r0, r1, r6, r7, r8
stmia r14!, {r0,r1,r6,r7}
__ldrd r8, r9, sp, 144
__ldrd r10, r11, sp, 152
add r2, r8, r2, ror #drot // x12
add r3, r9, r3, ror #drot // x13
add r4, r10, r4, ror #drot // x14
add r5, r11, r5, ror #drot // x15
_le32_bswap_4x r2, r3, r4, r5, r9, r10, r11
_le32_bswap_4x r2, r3, r4, r5, r9
stmia r14, {r2-r5}

// Stack: ks0-ks15 unused0-unused7 x0-x15 OUT IN LEN
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/crypto/curve25519-core.S
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
#include <linux/linkage.h>

.text
.fpu neon
.arch armv7-a
.fpu neon
.align 4

ENTRY(curve25519_neon)
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/crypto/poly1305-glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ void __weak poly1305_blocks_neon(void *state, const u8 *src, u32 len, u32 hibit)

static __ro_after_init DEFINE_STATIC_KEY_FALSE(have_neon);

void poly1305_init_arch(struct poly1305_desc_ctx *dctx, const u8 *key)
void poly1305_init_arch(struct poly1305_desc_ctx *dctx, const u8 key[POLY1305_KEY_SIZE])
{
poly1305_init_arm(&dctx->h, key);
dctx->s[0] = get_unaligned_le32(key + 16);
Expand Down
1 change: 1 addition & 0 deletions arch/arm64/crypto/aes-modes.S
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ ST5( mov v4.16b, vctr.16b )
ins vctr.d[0], x8

/* apply carry to N counter blocks for N := x12 */
cbz x12, 2f
adr x16, 1f
sub x16, x16, x12, lsl #3
br x16
Expand Down
2 changes: 1 addition & 1 deletion arch/arm64/crypto/poly1305-glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ asmlinkage void poly1305_emit(void *state, u8 *digest, const u32 *nonce);

static __ro_after_init DEFINE_STATIC_KEY_FALSE(have_neon);

void poly1305_init_arch(struct poly1305_desc_ctx *dctx, const u8 *key)
void poly1305_init_arch(struct poly1305_desc_ctx *dctx, const u8 key[POLY1305_KEY_SIZE])
{
poly1305_init_arm64(&dctx->h, key);
dctx->s[0] = get_unaligned_le32(key + 16);
Expand Down
2 changes: 1 addition & 1 deletion arch/mips/crypto/poly1305-glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ asmlinkage void poly1305_init_mips(void *state, const u8 *key);
asmlinkage void poly1305_blocks_mips(void *state, const u8 *src, u32 len, u32 hibit);
asmlinkage void poly1305_emit_mips(void *state, u8 *digest, const u32 *nonce);

void poly1305_init_arch(struct poly1305_desc_ctx *dctx, const u8 *key)
void poly1305_init_arch(struct poly1305_desc_ctx *dctx, const u8 key[POLY1305_KEY_SIZE])
{
poly1305_init_mips(&dctx->h, key);
dctx->s[0] = get_unaligned_le32(key + 16);
Expand Down
2 changes: 1 addition & 1 deletion arch/powerpc/crypto/sha1-spe-glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ static int ppc_spe_sha1_update(struct shash_desc *desc, const u8 *data,

src += bytes;
len -= bytes;
};
}

memcpy((char *)sctx->buffer, src, len);
return 0;
Expand Down
Loading

0 comments on commit a4a78bc

Please sign in to comment.