Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Wim Lewis
nettle
Commits
ef62d439
Commit
ef62d439
authored
May 21, 2013
by
Niels Möller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
x86: Adapted aes assembly to new interface.
parent
5c4ca294
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
43 deletions
+45
-43
ChangeLog
ChangeLog
+6
-2
x86/aes-decrypt-internal.asm
x86/aes-decrypt-internal.asm
+20
-21
x86/aes-encrypt-internal.asm
x86/aes-encrypt-internal.asm
+19
-20
No files found.
ChangeLog
View file @
ef62d439
2013-05-2
0
Niels Möller <nisse@lysator.liu.se>
2013-05-2
1
Niels Möller <nisse@lysator.liu.se>
* x86_64/aes-decrypt-internal.asm: Likewise.
* x86/aes-encrypt-internal.asm: Adapted to new interface.
* x86/aes-decrypt-internal.asm: Likewise.
2013-05-20 Niels Möller <nisse@lysator.liu.se>
* x86_64/aes-encrypt-internal.asm: Adapted to new interface.
* x86_64/aes-decrypt-internal.asm: Likewise.
2013-05-17 Niels Möller <nisse@lysator.liu.se>
...
...
x86/aes-decrypt-internal.asm
View file @
ef62d439
C
nettle
,
low
-
level
cryptographics
library
C
C
Copyright
(
C
)
2001
,
2002
,
2005
Rafael
R.
Sevilla
,
Niels
M
ö
ller
C
Copyright
(
C
)
2013
,
Niels
M
ö
ller
C
C
The
nettle
library
is
free
software
; you can redistribute it and/or modify
C
it
under
the
terms
of
the
GNU
Lesser
General
Public
License
as
published
by
...
...
@@ -32,11 +33,12 @@ define(<T>,<%ebp>)
define
(
<
TMP
>
,
<%
edi
>
)
define
(
<
KEY
>
,
<%
esi
>
)
define
(
<
FRAME_CTX
>
,
<
40
(
%
esp
)
>
)
define
(
<
FRAME_TABLE
>
,
<
44
(
%
esp
)
>
)
define
(
<
FRAME_LENGTH
>
,
<
48
(
%
esp
)
>
)
define
(
<
FRAME_DST
>
,
<
52
(
%
esp
)
>
)
define
(
<
FRAME_SRC
>
,
<
56
(
%
esp
)
>
)
define
(
<
PARAM_ROUNDS
>
,
<
40
(
%
esp
)
>
)
define
(
<
PARAM_KEYS
>
,
<
44
(
%
esp
)
>
)
define
(
<
PARAM_TABLE
>
,
<
48
(
%
esp
)
>
)
define
(
<
PARAM_LENGTH
>
,
<
52
(
%
esp
)
>
)
define
(
<
PARAM_DST
>
,
<
56
(
%
esp
)
>
)
define
(
<
PARAM_SRC
>
,
<
60
(
%
esp
)
>
)
define
(
<
FRAME_KEY
>
,
<
16
(
%
esp
)
>
)
define
(
<
FRAME_COUNT
>
,
<
12
(
%
esp
)
>
)
...
...
@@ -55,7 +57,7 @@ C %edi is a temporary, often used as an accumulator.
.file
"
aes
-
decrypt
-
internal.asm
"
C
_aes_decrypt
(
struct
aes_context
*
ctx
,
C
_aes_decrypt
(
unsigned
rounds
,
const
uint32_t
*
keys
,
C
const
struct
aes_table
*
T
,
C
si
ze_t
length
,
uint8_t
*
ds
t
,
C
uint8_t
*
src
)
...
...
@@ -70,24 +72,21 @@ PROLOGUE(_nettle_aes_decrypt)
subl
$
20
,
%
esp
C
loop
counter
and
save
area
for
the
key
pointer
movl
F
RAM
E
_LENGTH
,
%
ebp
movl
PA
RAM_LENGTH
,
%
ebp
testl
%
ebp
,
%
ebp
jz
.Lend
shrl
$
4
,
F
RAM
E
_LENGTH
shrl
$
4
,
PA
RAM_LENGTH
subl
$
1
,
PARAM_ROUNDS
.Lblock_loop:
movl
F
RAM
E_CTX
,
KEY
C
address
of
context
struct
ctx
movl
PA
RAM
_KEYS
,
KEY
C
address
of
subkeys
movl
F
RAM
E
_SRC
,
TMP
C
address
of
plaintext
movl
PA
RAM_SRC
,
TMP
C
address
of
plaintext
AES_LOAD
(
SA
,
SB
,
SC
,
SD
,
TMP
,
KEY
)
addl
$
16
,
FRAME_SRC
C
Increment
src
pointer
movl
FRAME_TABLE
,
T
C
get
number
of
rounds
to
do
from
ctx
struct
movl
AES_NROUNDS
(
KEY
),
TMP
subl
$
1
,
TMP
addl
$
16
,
PARAM_SRC
C
Increment
src
pointer
movl
PARAM_TABLE
,
T
movl
PARAM_ROUNDS
,
TMP
C
Loop
counter
on
stack
movl
TMP
,
FRAME_COUNT
...
...
@@ -140,18 +139,18 @@ PROLOGUE(_nettle_aes_decrypt)
C
Inverse
S
-
box
substitution
mov
$
3
,
TMP
.Lsubst:
AES_SUBST_BYTE
(
SA
,
SB
,
SC
,
SD
,
T
,
KEY
)
AES_SUBST_BYTE
(
SA
,
SB
,
SC
,
SD
,
T
,
KEY
)
decl
TMP
jnz
.Lsubst
C
Add
last
subkey
,
and
store
decrypted
data
movl
F
RAM
E
_DST
,
TMP
movl
PA
RAM_DST
,
TMP
movl
FRAME_KEY
,
KEY
AES_STORE
(
SA
,
SB
,
SC
,
SD
,
KEY
,
TMP
)
addl
$
16
,
F
RAM
E
_DST
C
Increment
destination
pointer
decl
F
RAM
E
_LENGTH
addl
$
16
,
PA
RAM_DST
C
Increment
destination
pointer
decl
PA
RAM_LENGTH
jnz
.Lblock_loop
...
...
x86/aes-encrypt-internal.asm
View file @
ef62d439
C
nettle
,
low
-
level
cryptographics
library
C
C
Copyright
(
C
)
2001
,
2002
,
2005
Rafael
R.
Sevilla
,
Niels
M
ö
ller
C
Copyright
(
C
)
2013
,
Niels
M
ö
ller
C
C
The
nettle
library
is
free
software
; you can redistribute it and/or modify
C
it
under
the
terms
of
the
GNU
Lesser
General
Public
License
as
published
by
...
...
@@ -32,11 +33,12 @@ define(<T>,<%ebp>)
define
(
<
TMP
>
,
<%
edi
>
)
define
(
<
KEY
>
,
<%
esi
>
)
define
(
<
FRAME_CTX
>
,
<
40
(
%
esp
)
>
)
define
(
<
FRAME_TABLE
>
,
<
44
(
%
esp
)
>
)
define
(
<
FRAME_LENGTH
>
,
<
48
(
%
esp
)
>
)
define
(
<
FRAME_DST
>
,
<
52
(
%
esp
)
>
)
define
(
<
FRAME_SRC
>
,
<
56
(
%
esp
)
>
)
define
(
<
PARAM_ROUNDS
>
,
<
40
(
%
esp
)
>
)
define
(
<
PARAM_KEYS
>
,
<
44
(
%
esp
)
>
)
define
(
<
PARAM_TABLE
>
,
<
48
(
%
esp
)
>
)
define
(
<
PARAM_LENGTH
>
,
<
52
(
%
esp
)
>
)
define
(
<
PARAM_DST
>
,
<
56
(
%
esp
)
>
)
define
(
<
PARAM_SRC
>
,
<
60
(
%
esp
)
>
)
define
(
<
FRAME_KEY
>
,
<
16
(
%
esp
)
>
)
define
(
<
FRAME_COUNT
>
,
<
12
(
%
esp
)
>
)
...
...
@@ -55,7 +57,7 @@ C %edi is a temporary, often used as an accumulator.
.file
"
aes
-
encrypt
-
internal.asm
"
C
_aes_encrypt
(
struct
aes_context
*
ctx
,
C
_aes_encrypt
(
unsigned
rounds
,
const
uint32_t
*
keys
,
C
const
struct
aes_table
*
T
,
C
si
ze_t
length
,
uint8_t
*
ds
t
,
C
uint8_t
*
src
)
...
...
@@ -70,24 +72,21 @@ PROLOGUE(_nettle_aes_encrypt)
subl
$
20
,
%
esp
C
loop
counter
and
save
area
for
the
key
pointer
movl
F
RAM
E
_LENGTH
,
%
ebp
movl
PA
RAM_LENGTH
,
%
ebp
testl
%
ebp
,
%
ebp
jz
.Lend
shrl
$
4
,
F
RAM
E
_LENGTH
shrl
$
4
,
PA
RAM_LENGTH
subl
$
1
,
PARAM_ROUNDS
.Lblock_loop:
movl
F
RAM
E_CTX
,
KEY
C
address
of
context
struct
ctx
movl
PA
RAM
_KEYS
,
KEY
C
address
of
subkeys
movl
F
RAM
E
_SRC
,
TMP
C
address
of
plaintext
movl
PA
RAM_SRC
,
TMP
C
address
of
plaintext
AES_LOAD
(
SA
,
SB
,
SC
,
SD
,
TMP
,
KEY
)
addl
$
16
,
FRAME_SRC
C
Increment
src
pointer
movl
FRAME_TABLE
,
T
C
get
number
of
rounds
to
do
from
ctx
struct
movl
AES_NROUNDS
(
KEY
),
TMP
subl
$
1
,
TMP
addl
$
16
,
PARAM_SRC
C
Increment
src
pointer
movl
PARAM_TABLE
,
T
movl
PARAM_ROUNDS
,
TMP
C
Loop
counter
on
stack
movl
TMP
,
FRAME_COUNT
...
...
@@ -146,12 +145,12 @@ PROLOGUE(_nettle_aes_encrypt)
jnz
.Lsubst
C
Add
last
subkey
,
and
store
encrypted
data
movl
F
RAM
E
_DST
,
TMP
movl
PA
RAM_DST
,
TMP
movl
FRAME_KEY
,
KEY
AES_STORE
(
SA
,
SB
,
SC
,
SD
,
KEY
,
TMP
)
addl
$
16
,
F
RAM
E
_DST
C
Increment
destination
pointer
decl
F
RAM
E
_LENGTH
addl
$
16
,
PA
RAM_DST
C
Increment
destination
pointer
decl
PA
RAM_LENGTH
jnz
.Lblock_loop
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment