From ff3ef3d5288b8ac0ba5bce0910181b2f7664a9a9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Niels=20M=C3=B6ller?= <nisse@lysator.liu.se>
Date: Tue, 14 May 2002 20:16:38 +0200
Subject: [PATCH] * x86/machine.m4 (AES_ROUND): New macro.

Rev: src/nettle/x86/machine.m4:1.5
---
 x86/machine.m4 | 53 +++++++++++++++++++++++++++++++++++---------------
 1 file changed, 37 insertions(+), 16 deletions(-)

diff --git a/x86/machine.m4 b/x86/machine.m4
index dac44cdd..d7bccade 100644
--- a/x86/machine.m4
+++ b/x86/machine.m4
@@ -1,19 +1,3 @@
-dnl AES_LAST_ROUND(a, b, c, d)
-dnl Leaves result in %edi
-dnl Note that we have to quote $ in constants.
-define(<AES_LAST_ROUND>, <
-	movl	%e<>$1<>x,%edi
-	andl	<$>0x000000ff,%edi
-	movl	%e<>$2<>x,%ebp
-	andl	<$>0x0000ff00,%ebp
-	orl	%ebp,%edi
-	movl	%e<>$3<>x,%ebp
-	andl	<$>0x00ff0000,%ebp
-	orl	%ebp,%edi
-	movl	%e<>$4<>x,%ebp
-	andl	<$>0xff000000,%ebp
-	orl	%ebp,%edi>)dnl
-
 dnl AES_LOAD(key, src)
 dnl Loads the next block of data from src, and add the subkey pointed
 dnl to by key.
@@ -45,3 +29,40 @@ define(<AES_STORE>, <
 	movl	%ebx,4($2)
 	movl	%ecx,8($2)
 	movl	%edx,12($2)>)dnl
+
+dnl AES_ROUND(table,a,b,c,d)
+dnl Computes one word of the AES round. Leaves result in %edi.
+define(<AES_ROUND>, <
+	movl	%e<>$2<>x, %esi
+	andl	<$>0xff, %esi
+	shll	<$>2,%esi		C  index in table
+	movl	AES_TABLE0 + $1 (%esi),%edi
+	movl	%e<>$3<>x, %esi
+	shrl	<$>6,%esi
+	andl	<$>0x000003fc,%esi C  clear all but offset bytes
+	xorl	AES_TABLE1 + $1 (%esi),%edi
+	movl	%e<>$4<>x,%esi	C  third one
+	shrl	<$>14,%esi
+	andl	<$>0x000003fc,%esi
+	xorl	AES_TABLE2 + $1 (%esi),%edi
+	movl	%e<>$5<>x,%esi	C  fourth one
+	shrl	<$>22,%esi
+	andl	<$>0x000003fc,%esi
+	xorl	AES_TABLE3 + $1 (%esi),%edi>)dnl
+
+dnl AES_LAST_ROUND(a, b, c, d)
+dnl Computes one word of the final round. Leaves result in %edi.
+dnl Note that we have to quote $ in constants.
+define(<AES_LAST_ROUND>, <
+	movl	%e<>$1<>x,%edi
+	andl	<$>0x000000ff,%edi
+	movl	%e<>$2<>x,%ebp
+	andl	<$>0x0000ff00,%ebp
+	orl	%ebp,%edi
+	movl	%e<>$3<>x,%ebp
+	andl	<$>0x00ff0000,%ebp
+	orl	%ebp,%edi
+	movl	%e<>$4<>x,%ebp
+	andl	<$>0xff000000,%ebp
+	orl	%ebp,%edi>)dnl
+
-- 
GitLab