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 .file "ecc-521-modp.asm"
35 C ecc_521_modp (const struct ecc_curve *ecc, mp_limb_t *rp)
42 PROLOGUE(nettle_ecc_521_modp)
43 push {r4,r5,r6,r7,r8,lr}
45 C Use that B^17 = 2^23 (mod p)
46 ldr F3, [RP, #+68] C 17
49 adds T0, T0, F3, lsl #23
53 C 5 iterations, reading limbs 18-20, 21-23, 24-26, 27-29, 30-32
54 C and adding to limbs 1-3, 4-6, 7-9, 19-12, 13-15
56 ldm RP, {T0,T1,T2} C 1+3*k -- 3+3*k
58 ldm HP!, {F1,F2,F3} C 18+3*k -- 20+3*k
59 orr F0, F0, F1, lsl #23
61 orr F1, F1, F2, lsl #23
63 orr F2, F2, F3, lsl #23
72 ldr F0, [RP], #-64 C 16
76 C Handling of high limbs
77 C F0 = rp[16] + carry in + F3 >> 9
78 adcs F0, F0, F3, lsr #9
79 C Copy low 9 bits to H, then shift right including carry
83 C Add in F1 = rp[33], with weight 2^1056 = 2^14
84 adds F0, F0, F1, lsl #14
88 ldm RP, {T0, T1} C 0-1
93 ldm RP, {T0,T1,T2,F0,F1,F2,F3} C 2-8
101 stm RP!, {T0,T1,T2,F0,F1,F2,F3} C 2-8
102 ldm RP, {T0,T1,T2,F0,F1,F2,F3} C 9-15
111 stm RP, {T0,T1,T2,F0,F1,F2,F3,H} C 9-16
113 pop {r4,r5,r6,r7,r8,pc}
114 EPILOGUE(nettle_ecc_521_modp)