lib/crypto/arm64/sha3-ce-core.S

Source file repositories/reference/linux-study-clean/lib/crypto/arm64/sha3-ce-core.S

File Facts

System
Linux kernel
Corpus path
lib/crypto/arm64/sha3-ce-core.S
Extension
.S
Size
6371 bytes
Lines
212
Domain
Kernel Services
Bucket
lib
Inferred role
Kernel Services: lib
Status
atlas-only

Why This File Exists

Shared kernel service surface used by multiple subsystems, including helpers, cryptography, virtualization support, and async I/O infrastructure.

Dependency Surface

Detected Declarations

Annotated Snippet

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

	.irp	b,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31
	.set	.Lv\b\().2d, \b
	.set	.Lv\b\().16b, \b
	.endr

	/*
	 * ARMv8.2 Crypto Extensions instructions
	 */
	.macro	eor3, rd, rn, rm, ra
	.inst	0xce000000 | .L\rd | (.L\rn << 5) | (.L\ra << 10) | (.L\rm << 16)
	.endm

	.macro	rax1, rd, rn, rm
	.inst	0xce608c00 | .L\rd | (.L\rn << 5) | (.L\rm << 16)
	.endm

	.macro	bcax, rd, rn, rm, ra
	.inst	0xce200000 | .L\rd | (.L\rn << 5) | (.L\ra << 10) | (.L\rm << 16)
	.endm

	.macro	xar, rd, rn, rm, imm6
	.inst	0xce800000 | .L\rd | (.L\rn << 5) | ((\imm6) << 10) | (.L\rm << 16)
	.endm

	/*
	 * void sha3_ce_transform(struct sha3_state *state, const u8 *data,
	 *			  size_t nblocks, size_t block_size)
	 *
	 * block_size is assumed to be one of 72 (SHA3-512), 104 (SHA3-384), 136
	 * (SHA3-256 and SHAKE256), 144 (SHA3-224), or 168 (SHAKE128).
	 */
	.text
SYM_FUNC_START(sha3_ce_transform)
	/* load state */
	add	x8, x0, #32
	ld1	{ v0.1d- v3.1d}, [x0]
	ld1	{ v4.1d- v7.1d}, [x8], #32
	ld1	{ v8.1d-v11.1d}, [x8], #32
	ld1	{v12.1d-v15.1d}, [x8], #32
	ld1	{v16.1d-v19.1d}, [x8], #32
	ld1	{v20.1d-v23.1d}, [x8], #32
	ld1	{v24.1d}, [x8]

0:	sub	x2, x2, #1
	mov	w8, #24
	adr_l	x9, .Lsha3_rcon

	/* load input */
	ld1	{v25.8b-v28.8b}, [x1], #32
	ld1	{v29.8b}, [x1], #8
	eor	v0.8b, v0.8b, v25.8b
	eor	v1.8b, v1.8b, v26.8b
	eor	v2.8b, v2.8b, v27.8b
	eor	v3.8b, v3.8b, v28.8b
	eor	v4.8b, v4.8b, v29.8b

	ld1	{v25.8b-v28.8b}, [x1], #32
	eor	v5.8b, v5.8b, v25.8b
	eor	v6.8b, v6.8b, v26.8b
	eor	v7.8b, v7.8b, v27.8b
	eor	v8.8b, v8.8b, v28.8b
	cmp	x3, #72
	b.eq	3f	/* SHA3-512 (block_size=72)? */

	ld1	{v25.8b-v28.8b}, [x1], #32
	eor	v9.8b, v9.8b, v25.8b
	eor	v10.8b, v10.8b, v26.8b

Annotation

Implementation Notes