| 1 |
#include "crypto_asm_property.h" |
| 2 |
#include "crypto_asm_hidden.h" |
| 3 |
// linker define fe25519_freeze |
| 4 |
|
| 5 |
/* Assembly for freezing to unique element in the field */ |
| 6 |
|
| 7 |
.p2align 4 |
| 8 |
ASM_HIDDEN _CRYPTO_SHARED_NAMESPACE(fe25519_freeze) |
| 9 |
.globl _CRYPTO_SHARED_NAMESPACE(fe25519_freeze) |
| 10 |
ASM_HIDDEN CRYPTO_SHARED_NAMESPACE(fe25519_freeze) |
| 11 |
.globl CRYPTO_SHARED_NAMESPACE(fe25519_freeze) |
| 12 |
|
| 13 |
_CRYPTO_SHARED_NAMESPACE(fe25519_freeze): |
| 14 |
CRYPTO_SHARED_NAMESPACE(fe25519_freeze): |
| 15 |
|
| 16 |
ldp x1, x2, [x0, #0] |
| 17 |
ldp x3, x4, [x0, #16] |
| 18 |
|
| 19 |
mov x5, #0x7fffffffffffffff |
| 20 |
mov x6, #19 |
| 21 |
|
| 22 |
and x7, x4, x5 |
| 23 |
lsr x4, x4, #63 |
| 24 |
mul x4, x4, x6 |
| 25 |
adds x1, x1, x4 |
| 26 |
adcs x2, x2, xzr |
| 27 |
adcs x3, x3, xzr |
| 28 |
adc x4, x7, xzr |
| 29 |
|
| 30 |
and x7, x4, x5 |
| 31 |
lsr x4, x4, #63 |
| 32 |
mul x4, x4, x6 |
| 33 |
adds x1, x1, x4 |
| 34 |
adcs x2, x2, xzr |
| 35 |
adcs x3, x3, xzr |
| 36 |
adc x4, x7, xzr |
| 37 |
|
| 38 |
cmp x4, x5 |
| 39 |
ccmn x1, #20, #0, eq |
| 40 |
add x7, x1, x6 |
| 41 |
and x8, x2, x3 |
| 42 |
ccmn x8, #1, #0, hi |
| 43 |
|
| 44 |
csel x1, x1, x7, ne |
| 45 |
csel x2, x2, xzr, ne |
| 46 |
csel x3, x3, xzr, ne |
| 47 |
csel x4, x4, xzr, ne |
| 48 |
|
| 49 |
stp x1, x2, [x0, #0] |
| 50 |
stp x3, x4, [x0, #16] |
| 51 |
|
| 52 |
ret |
| 53 |
.section .note.GNU-stack,"",@progbits |