Revert "Merge branch 'upstream' into tizen"
[platform/upstream/nettle.git] / arm / ecc-192-modp.asm
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.
14 C
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.
19
20         .file "ecc-192-modp.asm"
21         .arm
22
23 define(<HP>, <r0>) C Overlaps unused ecc argument
24 define(<RP>, <r1>)
25
26 define(<T0>, <r2>)
27 define(<T1>, <r3>)
28 define(<T2>, <r4>)
29 define(<T3>, <r5>)
30 define(<T4>, <r6>)
31 define(<T5>, <r7>)
32 define(<T6>, <r8>)
33 define(<T7>, <r10>)
34 define(<H0>, <T0>) C Overlaps T0 and T1
35 define(<H1>, <T1>)
36 define(<C2>, <HP>)
37 define(<C4>, <r12>)
38
39         C ecc_192_modp (const struct ecc_curve *ecc, mp_limb_t *rp)
40         .text
41         .align 2
42
43 PROLOGUE(nettle_ecc_192_modp)
44         push    {r4,r5,r6,r7,r8,r10}
45         C Reduce two words at a time
46         add     HP, RP, #48
47         add     RP, RP, #8
48         ldmdb   HP!, {H0,H1}
49         ldm     RP, {T2,T3,T4,T5,T6,T7}
50         mov     C4, #0
51         adds    T4, T4, H0
52         adcs    T5, T5, H1
53         adcs    T6, T6, H0
54         adcs    T7, T7, H1
55         C Need to add carry to T2 and T4, do T4 later.
56         adc     C4, C4, #0
57
58         ldmdb   HP!, {H0,H1}
59         mov     C2, #0
60         adcs    T2, T2, H0
61         adcs    T3, T3, H1
62         adcs    T4, T4, H0
63         adcs    T5, T5, H1
64         C Need to add carry to T0 and T2, do T2 later
65         adc     C2, C2, #0
66
67         ldmdb   RP!, {T0, T1}
68         adcs    T0, T0, T6
69         adcs    T1, T1, T7
70         adcs    T2, T2, T6
71         adcs    T3, T3, T7
72         adc     C4, C4, #0
73
74         adds    T2, T2, C2
75         adcs    T3, T3, #0
76         adcs    T4, T4, C4
77         adcs    T5, T5, #0
78         mov     C2, #0
79         adc     C2, C2, #0
80
81         C Add in final carry
82         adcs    T0, T0, #0
83         adcs    T1, T1, #0
84         adcs    T2, T2, C2
85         adcs    T3, T3, #0
86         adcs    T4, T4, #0
87         adc     T5, T5, #0
88
89         stm     RP, {T0,T1,T2,T3,T4,T5}
90
91         pop     {r4,r5,r6,r7,r8,r10}
92         bx      lr
93 EPILOGUE(nettle_ecc_192_modp)