/* SPDX-License-Identifier: GPL-2.0-only */
/*
* sha2-ce-core.S - core SHA-224/SHA-256 transform using v8 Crypto Extensions
*
* Copyright (C) 2014 Linaro Ltd <ard.biesheuvel@linaro.org>
*/
#include <linux/linkage.h>
#include <asm/assembler.h>
.text
.arch armv8-a+crypto
dga .req q20
dgav .req v20
dgb .req q21
dgbv .req v21
t0 .req v22
t1 .req v23
dg0q .req q24
dg0v .req v24
dg1q .req q25
dg1v .req v25
dg2q .req q26
dg2v .req v26
.macro add_only, ev, rc, s0
mov dg2v.16 b, dg0v.16 b
.ifeq \ev
add t1.4 s, v\s0\().4 s, \rc\().4 s
sha256h dg0q, dg1q, t0.4 s
sha256h2 dg1q, dg2q, t0.4 s
.else
.ifnb \s0
add t0.4 s, v\s0\().4 s, \rc\().4 s
.endif
sha256h dg0q, dg1q, t1.4 s
sha256h2 dg1q, dg2q, t1.4 s
.endif
.endm
.macro add_update, ev, rc, s0, s1, s2, s3
sha256su0 v\s0\().4 s, v\s1\().4 s
add_only \ev, \rc, \s1
sha256su1 v\s0\().4 s, v\s2\().4 s, v\s3\().4 s
.endm
/*
* The SHA-256 round constants
*/
.section ".rodata" , "a"
.align 4
.Lsha2_rcon:
.word 0 x428a2f98, 0 x71374491, 0 xb5c0fbcf, 0 xe9b5dba5
.word 0 x3956c25b, 0 x59f111f1, 0 x923f82a4, 0 xab1c5ed5
.word 0 xd807aa98, 0 x12835b01, 0 x243185be, 0 x550c7dc3
.word 0 x72be5d74, 0 x80deb1fe, 0 x9bdc06a7, 0 xc19bf174
.word 0 xe49b69c1, 0 xefbe4786, 0 x0fc19dc6, 0 x240ca1cc
.word 0 x2de92c6f, 0 x4a7484aa, 0 x5cb0a9dc, 0 x76f988da
.word 0 x983e5152, 0 xa831c66d, 0 xb00327c8, 0 xbf597fc7
.word 0 xc6e00bf3, 0 xd5a79147, 0 x06ca6351, 0 x14292967
.word 0 x27b70a85, 0 x2e1b2138, 0 x4d2c6dfc, 0 x53380d13
.word 0 x650a7354, 0 x766a0abb, 0 x81c2c92e, 0 x92722c85
.word 0 xa2bfe8a1, 0 xa81a664b, 0 xc24b8b70, 0 xc76c51a3
.word 0 xd192e819, 0 xd6990624, 0 xf40e3585, 0 x106aa070
.word 0 x19a4c116, 0 x1e376c08, 0 x2748774c, 0 x34b0bcb5
.word 0 x391c0cb3, 0 x4ed8aa4a, 0 x5b9cca4f, 0 x682e6ff3
.word 0 x748f82ee, 0 x78a5636f, 0 x84c87814, 0 x8cc70208
.word 0 x90befffa, 0 xa4506ceb, 0 xbef9a3f7, 0 xc67178f2
/*
* size_t __sha256_ce_transform(struct sha256_block_state *state,
* const u8 *data, size_t nblocks);
*/
.text
SYM_FUNC_START(__sha256_ce_transform)
/* load round constants */
adr_l x8, .Lsha2_rcon
ld1 { v0.4 s- v3.4 s}, [x8], #64
ld1 { v4.4 s- v7.4 s}, [x8], #64
ld1 { v8.4 s-v11.4 s}, [x8], #64
ld1 {v12.4 s-v15.4 s}, [x8]
/* load state */
ld1 {dgav.4 s, dgbv.4 s}, [x0]
/* load input */
0 : ld1 {v16.4 s-v19.4 s}, [x1], #64
sub x2, x2, #1
CPU_LE( rev32 v16.16 b, v16.16 b )
CPU_LE( rev32 v17.16 b, v17.16 b )
CPU_LE( rev32 v18.16 b, v18.16 b )
CPU_LE( rev32 v19.16 b, v19.16 b )
add t0.4 s, v16.4 s, v0.4 s
mov dg0v.16 b, dgav.16 b
mov dg1v.16 b, dgbv.16 b
add_update 0 , v1, 16 , 17 , 18 , 19
add_update 1 , v2, 17 , 18 , 19 , 16
add_update 0 , v3, 18 , 19 , 16 , 17
add_update 1 , v4, 19 , 16 , 17 , 18
add_update 0 , v5, 16 , 17 , 18 , 19
add_update 1 , v6, 17 , 18 , 19 , 16
add_update 0 , v7, 18 , 19 , 16 , 17
add_update 1 , v8, 19 , 16 , 17 , 18
add_update 0 , v9, 16 , 17 , 18 , 19
add_update 1 , v10, 17 , 18 , 19 , 16
add_update 0 , v11, 18 , 19 , 16 , 17
add_update 1 , v12, 19 , 16 , 17 , 18
add_only 0 , v13, 17
add_only 1 , v14, 18
add_only 0 , v15, 19
add_only 1
/* update state */
add dgav.4 s, dgav.4 s, dg0v.4 s
add dgbv.4 s, dgbv.4 s, dg1v.4 s
/* return early if voluntary preemption is needed */
cond_yield 1 f, x5, x6
/* handled all input blocks? */
cbnz x2, 0 b
/* store new state */
1 : st1 {dgav.4 s, dgbv.4 s}, [x0]
mov x0, x2
ret
SYM_FUNC_END(__sha256_ce_transform)
Messung V0.5 in Prozent C=94 H=92 G=92
¤ Dauer der Verarbeitung: 0.8 Sekunden
(vorverarbeitet am 2026-06-07)
¤
*© Formatika GbR, Deutschland