zupt/jasmin/zupt_mlkem_select.s
Cristian Cezar Moisés 5bb280eb25 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
2026-03-28 23:03:04 -03:00

39 lines
807 B
ArmAsm

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