feat: add Jasmin assembly integration for crypto acceleration

- Integrated `zupt_mac_verify_ct` in `zupt_decrypt_buffer()` to replace C XOR loop for HMAC-SHA256
- Integrated `zupt_ct_select_32` in `zupt_mlkem768_decaps()` to replace C `cmov()` for FO transformation
- Added `include/zupt_jasmin.h` with extern declarations and ABI docs
- Added `#ifdef ZUPT_USE_JASMIN` guards with clean C fallbacks in `zupt_crypto.c` and `zupt_mlkem.c`
- Makefile now auto-detects `jasmin/*.s`, assembles and links with `-DZUPT_USE_JASMIN`

Closes #3
This commit is contained in:
Cristian Cezar Moisés 2026-03-28 23:00:28 -03:00
commit 06c877ec86
43 changed files with 1913 additions and 546 deletions

47
jasmin/zupt_x25519_fe.s Normal file
View file

@ -0,0 +1,47 @@
.intel_syntax noprefix
.text
.p2align 5
.global zupt_fe_cswap
.type zupt_fe_cswap, %function
zupt_fe_cswap:
mov rax, 0
sub rax, rdx
mov rcx, qword ptr[rdi]
mov rdx, qword ptr[rsi]
mov r8, rcx
xor r8, rdx
and r8, rax
xor rcx, r8
xor rdx, r8
mov qword ptr[rdi], rcx
mov qword ptr[rsi], rdx
mov rcx, qword ptr[rdi + 8]
mov rdx, qword ptr[rsi + 8]
mov r8, rcx
xor r8, rdx
and r8, rax
xor rcx, r8
xor rdx, r8
mov qword ptr[rdi + 8], rcx
mov qword ptr[rsi + 8], rdx
mov rcx, qword ptr[rdi + 16]
mov rdx, qword ptr[rsi + 16]
mov r8, rcx
xor r8, rdx
and r8, rax
xor rcx, r8
xor rdx, r8
mov qword ptr[rdi + 16], rcx
mov qword ptr[rsi + 16], rdx
mov rcx, qword ptr[rdi + 24]
mov rdx, qword ptr[rsi + 24]
mov r8, rcx
xor r8, rdx
and r8, rax
xor rcx, r8
xor rdx, r8
mov qword ptr[rdi + 24], rcx
mov qword ptr[rsi + 24], rdx
ret
.ident "Jasmin Compiler 2026.03.0"
.section ".note.GNU-stack", "", %progbits