Correct PPTP server firewall rules chain.
[tomato/davidwu.git] / release / src / router / nettle / arm / v6 / aes-encrypt-internal.asm
blobb3309351b5b624105ff37fdb6eb6071d48302b8c
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 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.
28 define(<CTX>, <r0>)
29 define(<TABLE>, <r1>)
30 define(<LENGTH>, <r2>)
31 define(<DST>, <r3>)
32 define(<SRC>, <r12>)
34 define(<W0>, <r4>)
35 define(<W1>, <r5>)
36 define(<W2>, <r6>)
37 define(<W3>, <r7>)
38 define(<T0>, <r8>)
39 define(<KEY>, <r10>)
40 define(<ROUND>, <r11>)
42 define(<X0>, <r2>) C Overlaps LENGTH, SRC, DST
43 define(<X1>, <r3>)
44 define(<X2>, <r12>)
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,
53 C uint8_t *src)
54 .text
55 .align 2
56 PROLOGUE(_nettle_aes_encrypt)
57 teq LENGTH, #0
58 beq .Lend
59 ldr SRC, [sp]
61 push {r4,r5,r6,r7,r8,r10,r11,lr}
62 .Lblock_loop:
63 mov KEY, CTX
64 AES_LOAD(SRC,KEY,W0)
65 AES_LOAD(SRC,KEY,W1)
66 AES_LOAD(SRC,KEY,W2)
67 AES_LOAD(SRC,KEY,W3)
69 push {LENGTH, DST, SRC}
70 ldr ROUND, [CTX, #+AES_NROUNDS]
71 add TABLE, TABLE, #AES_TABLE0
73 b .Lentry
74 .align 2
75 .Lround_loop:
76 C Transform X -> W
77 AES_ENCRYPT_ROUND(X0, X1, X2, X3, W0, W1, W2, W3, KEY)
79 .Lentry:
80 subs ROUND, ROUND,#2
81 C Transform W -> X
82 AES_ENCRYPT_ROUND(W0, W1, W2, W3, X0, X1, X2, X3, KEY)
84 bne .Lround_loop
86 sub TABLE, TABLE, #AES_TABLE0
87 C Final round
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}
95 AES_STORE(DST,W0)
96 AES_STORE(DST,W1)
97 AES_STORE(DST,W2)
98 AES_STORE(DST,W3)
100 subs LENGTH, LENGTH, #16
101 bhi .Lblock_loop
103 pop {r4,r5,r6,r7,r8,r10,r11,pc}
105 .Lend:
106 bx lr
107 EPILOGUE(_nettle_aes_encrypt)