| 1 |
#include "crypto_asm_property.h" |
| 2 |
#include "crypto_asm_hidden.h" |
| 3 |
// linker define fe25519_nsquare |
| 4 |
|
| 5 |
/* Assembly for feedback field squaring */ |
| 6 |
|
| 7 |
.p2align 4 |
| 8 |
ASM_HIDDEN _CRYPTO_SHARED_NAMESPACE(fe25519_nsquare) |
| 9 |
.globl _CRYPTO_SHARED_NAMESPACE(fe25519_nsquare) |
| 10 |
ASM_HIDDEN CRYPTO_SHARED_NAMESPACE(fe25519_nsquare) |
| 11 |
.globl CRYPTO_SHARED_NAMESPACE(fe25519_nsquare) |
| 12 |
|
| 13 |
_CRYPTO_SHARED_NAMESPACE(fe25519_nsquare): |
| 14 |
CRYPTO_SHARED_NAMESPACE(fe25519_nsquare): |
| 15 |
|
| 16 |
sub sp, sp, #16 |
| 17 |
str x19, [sp, #0] |
| 18 |
|
| 19 |
ldp x3, x4, [x1, #0] |
| 20 |
ldp x5, x6, [x1, #16] |
| 21 |
|
| 22 |
mov x17, #0x8000000000000000 |
| 23 |
mov x18, #38 |
| 24 |
mov x19, #19 |
| 25 |
|
| 26 |
.L: |
| 27 |
mul x9, x4, x3 |
| 28 |
umulh x10, x4, x3 |
| 29 |
mul x1, x5, x3 |
| 30 |
adds x10, x10, x1 |
| 31 |
umulh x11, x5, x3 |
| 32 |
mul x1, x6, x3 |
| 33 |
adcs x11, x11, x1 |
| 34 |
umulh x12, x6, x3 |
| 35 |
adc x12, x12, xzr |
| 36 |
|
| 37 |
mul x16, x5, x4 |
| 38 |
umulh x7, x5, x4 |
| 39 |
mul x1, x6, x4 |
| 40 |
adds x7, x7, x1 |
| 41 |
umulh x1, x6, x4 |
| 42 |
adc x1, x1, xzr |
| 43 |
|
| 44 |
adds x11, x11, x16 |
| 45 |
adcs x12, x12, x7 |
| 46 |
mul x16, x6, x5 |
| 47 |
umulh x14, x6, x5 |
| 48 |
adcs x13, x1, x16 |
| 49 |
adc x14, x14, xzr |
| 50 |
|
| 51 |
adds x9, x9, x9 |
| 52 |
adcs x10, x10, x10 |
| 53 |
adcs x11, x11, x11 |
| 54 |
adcs x12, x12, x12 |
| 55 |
adcs x13, x13, x13 |
| 56 |
adcs x14, x14, x14 |
| 57 |
cset x15, cs |
| 58 |
|
| 59 |
mul x8, x3, x3 |
| 60 |
umulh x1, x3, x3 |
| 61 |
adds x9, x9, x1 |
| 62 |
|
| 63 |
mul x1, x4, x4 |
| 64 |
adcs x10, x10, x1 |
| 65 |
umulh x16, x4, x4 |
| 66 |
adcs x11, x11, x16 |
| 67 |
|
| 68 |
mul x1, x5, x5 |
| 69 |
adcs x12, x12, x1 |
| 70 |
umulh x16, x5, x5 |
| 71 |
adcs x13, x13, x16 |
| 72 |
|
| 73 |
mul x1, x6, x6 |
| 74 |
adcs x14, x14, x1 |
| 75 |
umulh x16, x6, x6 |
| 76 |
adc x15, x15, x16 |
| 77 |
|
| 78 |
mul x1, x12, x18 |
| 79 |
umulh x4, x12, x18 |
| 80 |
adds x8, x8, x1 |
| 81 |
mul x1, x13, x18 |
| 82 |
umulh x5, x13, x18 |
| 83 |
adcs x9, x9, x1 |
| 84 |
mul x1, x14, x18 |
| 85 |
umulh x6, x14, x18 |
| 86 |
adcs x10, x10, x1 |
| 87 |
mul x1, x15, x18 |
| 88 |
umulh x7, x15, x18 |
| 89 |
adcs x11, x11, x1 |
| 90 |
cset x16, cs |
| 91 |
adds x11, x11, x6 |
| 92 |
adc x7, x7, x16 |
| 93 |
|
| 94 |
cmn x11, x11 |
| 95 |
adc x7, x7, x7 |
| 96 |
mul x7, x7, x19 |
| 97 |
|
| 98 |
bic x11, x11, x17 |
| 99 |
adds x3, x8, x7 |
| 100 |
adcs x4, x9, x4 |
| 101 |
adcs x5, x10, x5 |
| 102 |
adc x6, x11, xzr |
| 103 |
|
| 104 |
sub x2, x2, #1 |
| 105 |
cmp x2, xzr |
| 106 |
bne .L |
| 107 |
|
| 108 |
stp x3, x4, [x0, #0] |
| 109 |
stp x5, x6, [x0, #16] |
| 110 |
|
| 111 |
ldr x19, [sp, #0] |
| 112 |
add sp, sp, #16 |
| 113 |
|
| 114 |
ret |
| 115 |
.section .note.GNU-stack,"",@progbits |