Skip to content
Snippets Groups Projects
Forked from Nettle / nettle
2425 commits behind the upstream repository.
aes.m4 2.83 KiB
dnl LREG(reg) gives the 8-bit register corresponding to the given 32-bit register.
define(<LREG>,<ifelse(
	$1, %eax, %al,
	$1, %ebx, %bl,
	$1, %ecx, %cl,
	$1, %edx, %dl,
	$1, %esi, %sil,
	$1, %edi, %dil,
	$1, %ebp, %bpl,
	$1, %esp, %spl,
	$1, %r8d, %r8b,
	$1, %r9d, %r9b,
	$1, %r10d, %r10b,
	$1, %r11d, %r11b,
	$1, %r12d, %r12b,
	$1, %r13d, %r13b,
	$1, %r14d, %r14b,
	$1, %r15d, %r15b)>)dnl

define(<HREG>,<ifelse(
	$1, %eax, %ah,
	$1, %ebx, %bh,
	$1, %ecx, %ch,
	$1, %edx, %dh,
	error)>)

define(<XREG>,<ifelse(
	$1, %rax, %eax,
	$1, %rbx, %ebx,
	$1, %rcx, %ecx,
	$1, %rdx, %edx,
	$1, %rsi, %esi,
	$1, %rdi, %edi,
	$1, %rbp, %ebp,
	$1, %rsp, %esp,
	$1, %r8, %r8d,
	$1, %r9, %r9d,
	$1, %r10,%r10d,
	$1, %r11,%r11d,
	$1, %r12,%r12d,
	$1, %r13,%r13d,
	$1, %r14,%r14d,
	$1, %r15,%r15d)>)dnl

dnl AES_LOAD(a, b, c, d, src, key)
dnl Loads the next block of data from src, and add the subkey pointed
dnl to by key.
dnl Note that x86 allows unaligned accesses.
dnl Would it be preferable to interleave the loads and stores?
define(<AES_LOAD>, <
	movl	($5),$1
	movl	4($5),$2
	movl	8($5),$3
	movl	12($5),$4
	
	xorl	($6),$1
	xorl	4($6),$2
	xorl	8($6),$3
	xorl	12($6),$4>)dnl

dnl AES_STORE(a, b, c, d, key, dst)
dnl Adds the subkey to a, b, c, d,
dnl and stores the result in the area pointed to by dst.
dnl Note that x86 allows unaligned accesses.
dnl Would it be preferable to interleave the loads and stores?
define(<AES_STORE>, <
	xorl	($5),$1
	xorl	4($5),$2
	xorl	8($5),$3
	xorl	12($5),$4