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