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:
parent
cea317653e
commit
06c877ec86
43 changed files with 1913 additions and 546 deletions
34
jasmin/zupt_x25519_fe.jazz
Normal file
34
jasmin/zupt_x25519_fe.jazz
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
/* Zupt — X25519 Constant-Time Conditional Swap (Jasmin)
|
||||
* Copyright (c) 2026 Cristian Cezar Moisés — MIT License
|
||||
*
|
||||
* CT-REQUIRED: fe_cswap must not leak cond via timing.
|
||||
* This is the only CT-critical field operation in X25519.
|
||||
* fe_add/fe_sub/fe_mul use C fallback (data-independent timing
|
||||
* on x86-64 — ADD/MUL have fixed latency).
|
||||
*
|
||||
* 4 × u64 limbs, pure register operations, no intrinsics needed.
|
||||
*/
|
||||
|
||||
export fn zupt_fe_cswap(
|
||||
reg u64 a_ptr,
|
||||
reg u64 b_ptr,
|
||||
reg u64 cond)
|
||||
{
|
||||
reg u64 mask ta tb diff;
|
||||
inline int i;
|
||||
|
||||
mask = 0;
|
||||
mask -= cond;
|
||||
|
||||
for i = 0 to 4 {
|
||||
ta = [a_ptr + 8 * i];
|
||||
tb = [b_ptr + 8 * i];
|
||||
diff = ta;
|
||||
diff ^= tb;
|
||||
diff &= mask;
|
||||
ta ^= diff;
|
||||
tb ^= diff;
|
||||
[a_ptr + 8 * i] = ta;
|
||||
[b_ptr + 8 * i] = tb;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue