Commit 06cfa5e8 authored by Niels Möller's avatar Niels Möller
Browse files

* sparc/aes.asm (AES_ROUND): New macro.

* (_aes_crypt): Use AES_ROUND for first word of the
round function.

Rev: src/nettle/sparc/aes.asm:1.95
parent 26756e84
...@@ -28,12 +28,6 @@ ...@@ -28,12 +28,6 @@
.file "aes.asm" .file "aes.asm"
.section ".text"
.align 16
.global _aes_crypt
.type _aes_crypt,#function
.proc 020
! Arguments ! Arguments
define(ctx, %i0) define(ctx, %i0)
define(T, %i1) define(T, %i1)
...@@ -69,6 +63,42 @@ define(t1, %o1) ...@@ -69,6 +63,42 @@ define(t1, %o1)
define(t2, %o2) define(t2, %o2)
define(t3, %o3) define(t3, %o3)
dnl AES_ROUND(i)
dnl Compute one word in the round function.
dnl Input in wtxt, output stored in tmp + i.
define(<AES_ROUND>, <
ld [IDX1+$1], t1 ! 1
ldub [wtxt+t1], t1 ! 1
ld [IDX3+$1], t3 ! 3
sll t1, 2, t1 ! 1
ld [wtxt+$1], t0 ! 0
! IDX2(j) = j XOR 2
lduh [wtxt+eval($1 ^ 8)], t2 ! 2
and t0, 255, t0 ! 0
ldub [wtxt+t3], t3 ! 3
sll t0, 2, t0 ! 0
ld [T0+t0], t0 ! 0
and t2, 255, t2 ! 2
ld [T1+t1], t1 ! 1
sll t2, 2, t2 ! 2
ld [T2+t2], t2 ! 2
sll t3, 2, t3 ! 3
ld [T3+t3], t3 ! 3
xor t0, t1, t0 ! 0, 1
xor t0, t2, t0 ! 0, 1, 2
! Fetch roundkey
ld [key + $1], t1
xor t0, t3, t0 ! 0, 1, 2, 3
xor t0, t1, t0
st t0, [tmp + $1]>)
C The stack frame looks like C The stack frame looks like
C C
C %fp - 4: OS-dependent link field C %fp - 4: OS-dependent link field
...@@ -78,6 +108,12 @@ C %fp - 40: wtxt, uint32_t[4] ...@@ -78,6 +108,12 @@ C %fp - 40: wtxt, uint32_t[4]
C %fp - 136: OS register save area. C %fp - 136: OS register save area.
define(<FRAME_SIZE>, 136) define(<FRAME_SIZE>, 136)
.section ".text"
.align 16
.global _aes_crypt
.type _aes_crypt,#function
.proc 020
_aes_crypt: _aes_crypt:
save %sp, -FRAME_SIZE, %sp save %sp, -FRAME_SIZE, %sp
cmp length, 0 cmp length, 0
...@@ -145,42 +181,41 @@ _aes_crypt: ...@@ -145,42 +181,41 @@ _aes_crypt:
C Unrolled inner loop begins C Unrolled inner loop begins
C i = 0 C i = 0
ld [IDX1+0], t1 ! 1 AES_ROUND(0)
C ld [IDX1+0], t1 ! 1
C add wtxt, t1, t1 ! 1 C
ldub [wtxt+t1], t1 ! 1 C ldub [wtxt+t1], t1 ! 1
ld [IDX3+0], t3 ! 3 C ld [IDX3+0], t3 ! 3
C
sll t1, 2, t1 ! 1 C sll t1, 2, t1 ! 1
ld [wtxt], t0 ! 0 C ld [wtxt], t0 ! 0
! IDX2(j) = j XOR 2 C ! IDX2(j) = j XOR 2
lduh [wtxt+8], t2 ! 2 C lduh [wtxt+8], t2 ! 2
and t0, 255, t0 ! 0 C and t0, 255, t0 ! 0
C
ldub [wtxt+t3], t3 ! 3 C ldub [wtxt+t3], t3 ! 3
sll t0, 2, t0 ! 0 C sll t0, 2, t0 ! 0
ld [T0+t0], t0 ! 0 C ld [T0+t0], t0 ! 0
and t2, 255, t2 ! 2 C and t2, 255, t2 ! 2
C
ld [T1+t1], t1 ! 1 C ld [T1+t1], t1 ! 1
sll t2, 2, t2 ! 2 C sll t2, 2, t2 ! 2
ld [T2+t2], t2 ! 2 C ld [T2+t2], t2 ! 2
sll t3, 2, t3 ! 3 C sll t3, 2, t3 ! 3
C
ld [T3+t3], t3 ! 3 C ld [T3+t3], t3 ! 3
xor t0, t1, t0 ! 0, 1 C xor t0, t1, t0 ! 0, 1
xor t0, t2, t0 ! 0, 1, 2 C xor t0, t2, t0 ! 0, 1, 2
! Fetch roundkey C ! Fetch roundkey
ld [key], t1 C ld [key], t1
C
xor t0, t3, t0 ! 0, 1, 2, 3 C xor t0, t3, t0 ! 0, 1, 2, 3
xor t0, t1, t0 C xor t0, t1, t0
st t0, [tmp] C st t0, [tmp]
C i = 1 C i = 1
ld [IDX1+4], t1 ! 1 ld [IDX1+4], t1 ! 1
C add wtxt, t1, t1 ! 1
ldub [wtxt+t1], t1 ! 1 ldub [wtxt+t1], t1 ! 1
ld [IDX3+4], t3 ! 3 ld [IDX3+4], t3 ! 3
...@@ -213,7 +248,6 @@ _aes_crypt: ...@@ -213,7 +248,6 @@ _aes_crypt:
C = 2 C = 2
ld [IDX1+8], t1 ! 1 ld [IDX1+8], t1 ! 1
C add wtxt, t1, t1 ! 1
ldub [wtxt+t1], t1 ! 1 ldub [wtxt+t1], t1 ! 1
ld [IDX3+8], t3 ! 3 ld [IDX3+8], t3 ! 3
...@@ -246,7 +280,6 @@ _aes_crypt: ...@@ -246,7 +280,6 @@ _aes_crypt:
C = 3 C = 3
ld [IDX1+12], t1 ! 1 ld [IDX1+12], t1 ! 1
C add wtxt, t1, t1 ! 1
ldub [wtxt+t1], t1 ! 1 ldub [wtxt+t1], t1 ! 1
ld [IDX3+12], t3 ! 3 ld [IDX3+12], t3 ! 3
...@@ -295,7 +328,6 @@ _aes_crypt: ...@@ -295,7 +328,6 @@ _aes_crypt:
C i = 0 C i = 0
ld [IDX1+0], t1 ! 1 ld [IDX1+0], t1 ! 1
C add wtxt, t1, t1 ! 1
ldub [wtxt+t1], t1 ! 1 ldub [wtxt+t1], t1 ! 1
ld [wtxt+0], t0 ! 0 ld [wtxt+0], t0 ! 0
...@@ -335,7 +367,6 @@ _aes_crypt: ...@@ -335,7 +367,6 @@ _aes_crypt:
C i = 1 C i = 1
ld [IDX1+4], t1 ! 1 ld [IDX1+4], t1 ! 1
C add wtxt, t1, t1 ! 1
ldub [wtxt+t1], t1 ! 1 ldub [wtxt+t1], t1 ! 1
ld [wtxt+4], t0 ! 0 ld [wtxt+4], t0 ! 0
...@@ -375,7 +406,6 @@ _aes_crypt: ...@@ -375,7 +406,6 @@ _aes_crypt:
C i = 2 C i = 2
ld [IDX1+8], t1 ! 1 ld [IDX1+8], t1 ! 1
C add wtxt, t1, t1 ! 1
ldub [wtxt+t1], t1 ! 1 ldub [wtxt+t1], t1 ! 1
ld [wtxt+8], t0 ! 0 ld [wtxt+8], t0 ! 0
...@@ -415,7 +445,6 @@ _aes_crypt: ...@@ -415,7 +445,6 @@ _aes_crypt:
C i = 3 C i = 3
ld [IDX1+12], t1 ! 1 ld [IDX1+12], t1 ! 1
C add wtxt, t1, t1 ! 1
ldub [wtxt+t1], t1 ! 1 ldub [wtxt+t1], t1 ! 1
ld [wtxt+12], t0 ! 0 ld [wtxt+12], t0 ! 0
...@@ -461,7 +490,6 @@ _aes_crypt: ...@@ -461,7 +490,6 @@ _aes_crypt:
sub wtxt, src, %g3 sub wtxt, src, %g3
.Lend: .Lend:
C add %sp, FRAME_SIZE, %fp
ret ret
restore restore
.LLFE1: .LLFE1:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment