Correct PPTP server firewall rules chain.
[tomato/davidwu.git] / release / src / router / nettle / arm / v6 / aes-decrypt-internal.asm
blob1cd92fb28634a0b521a650db16ba08eda9d94627
1 C nettle, low-level cryptographics library
2 C
3 C Copyright (C) 2013 Niels Möller
4 C
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.
9 C
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,
18 C MA 02111-1301, USA.
20 include_src(<arm/aes.m4>)
22 C Benchmarked at at 785, 914, 1051 cycles/block on cortex A9,
23 C for 128, 192 and 256 bit key sizes. Unclear why it is slower
24 C than _aes_encrypt.
26 define(<CTX>, <r0>)
27 define(<TABLE>, <r1>)
28 define(<LENGTH>, <r2>)
29 define(<DST>, <r3>)
30 define(<SRC>, <r12>)
32 define(<W0>, <r4>)
33 define(<W1>, <r5>)
34 define(<W2>, <r6>)
35 define(<W3>, <r7>)
36 define(<T0>, <r8>)
37 define(<KEY>, <r10>)
38 define(<ROUND>, <r11>)
40 define(<X0>, <r2>) C Overlaps LENGTH, SRC, DST
41 define(<X1>, <r3>)
42 define(<X2>, <r12>)
43 define(<X3>, <r14>) C lr
46 .file "aes-decrypt-internal.asm"
48 C _aes_decrypt(struct aes_context *ctx,
49 C const struct aes_table *T,
50 C unsigned length, uint8_t *dst,
51 C uint8_t *src)
52 .text
53 .align 2
54 PROLOGUE(_nettle_aes_decrypt)
55 teq LENGTH, #0
56 beq .Lend
57 ldr SRC, [sp]
59 push {r4,r5,r6,r7,r8,r10,r11,lr}
60 .Lblock_loop:
61 mov KEY, CTX
62 AES_LOAD(SRC,KEY,W0)
63 AES_LOAD(SRC,KEY,W1)
64 AES_LOAD(SRC,KEY,W2)
65 AES_LOAD(SRC,KEY,W3)
67 push {LENGTH, DST, SRC}
68 ldr ROUND, [CTX, #+AES_NROUNDS]
69 add TABLE, TABLE, #AES_TABLE0
71 b .Lentry
72 .align 2
73 .Lround_loop:
74 C Transform X -> W
75 AES_DECRYPT_ROUND(X0, X1, X2, X3, W0, W1, W2, W3, KEY)
77 .Lentry:
78 subs ROUND, ROUND,#2
79 C Transform W -> X
80 AES_DECRYPT_ROUND(W0, W1, W2, W3, X0, X1, X2, X3, KEY)
82 bne .Lround_loop
84 sub TABLE, TABLE, #AES_TABLE0
85 C Final round
86 AES_FINAL_ROUND(X0, X3, X2, X1, KEY, W0)
87 AES_FINAL_ROUND(X1, X0, X3, X2, KEY, W1)
88 AES_FINAL_ROUND(X2, X1, X0, X3, KEY, W2)
89 AES_FINAL_ROUND(X3, X2, X1, X0, KEY, W3)
91 pop {LENGTH, DST, SRC}
93 AES_STORE(DST,W0)
94 AES_STORE(DST,W1)
95 AES_STORE(DST,W2)
96 AES_STORE(DST,W3)
98 subs LENGTH, LENGTH, #16
99 bhi .Lblock_loop
101 pop {r4,r5,r6,r7,r8,r10,r11,pc}
103 .Lend:
104 bx lr
105 EPILOGUE(_nettle_aes_decrypt)