1 C nettle
, low-level cryptographics library
3 C Copyright
(C
) 2013 Niels Möller
5 C The nettle library is free software
; you can redistribute it and/or modify
6 C it under the terms of the GNU Lesser General
Public License as published by
7 C the Free Software Foundation
; either version 2.1 of the License, or (at your
8 C option
) any later version.
10 C The nettle library is distributed
in the hope that it will be useful
, but
11 C WITHOUT ANY WARRANTY
; without even the implied warranty of MERCHANTABILITY
12 C
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public
13 C License for more details.
15 C You should have received a copy of the GNU Lesser General
Public License
16 C along with the nettle library
; see the file COPYING.LIB. If not, write to
17 C the Free Software Foundation
, Inc.
, 51 Franklin Street
, Fifth Floor
, Boston
,
20 include_src
(<arm
/aes.m4
>)
22 C Benchmarked at at
693, 824, 950 cycles
/block on cortex A9
,
23 C for
128, 192 and 256 bit key sizes.
25 C Possible
improvements: More efficient load
and store with
26 C aligned accesses. Better scheduling.
30 define
(<LENGTH>, <r2
>)
40 define
(<ROUND
>, <r11
>)
42 define
(<X0
>, <r2
>) C Overlaps
LENGTH, SRC
, DST
45 define
(<X3
>, <r14
>) C lr
48 .file
"aes-encrypt-internal.asm"
50 C _aes_encrypt
(struct aes_context
*ctx
,
51 C const
struct aes_table
*T
,
52 C unsigned
length, uint8_t
*dst
,
56 PROLOGUE
(_nettle_aes_encrypt
)
61 push {r4,r5,r6,r7,r8,r10,r11,lr}
69 push {LENGTH, DST, SRC}
70 ldr ROUND
, [CTX
, #
+AES_NROUNDS
]
71 add TABLE
, TABLE
, #AES_TABLE0
77 AES_ENCRYPT_ROUND
(X0
, X1
, X2
, X3
, W0
, W1
, W2
, W3
, KEY
)
82 AES_ENCRYPT_ROUND
(W0
, W1
, W2
, W3
, X0
, X1
, X2
, X3
, KEY
)
86 sub TABLE
, TABLE
, #AES_TABLE0
88 AES_FINAL_ROUND
(X0
, X1
, X2
, X3
, KEY
, W0
)
89 AES_FINAL_ROUND
(X1
, X2
, X3
, X0
, KEY
, W1
)
90 AES_FINAL_ROUND
(X2
, X3
, X0
, X1
, KEY
, W2
)
91 AES_FINAL_ROUND
(X3
, X0
, X1
, X2
, KEY
, W3
)
93 pop {LENGTH, DST, SRC}
100 subs
LENGTH, LENGTH, #
16
103 pop {r4,r5,r6,r7,r8,r10,r11,pc}
107 EPILOGUE
(_nettle_aes_encrypt
)