Commit f58c8a6
authored
polyval: add
Fixes #315
The `cpufeatures::new!` macro in `avx2.rs` only checks for `pclmulqdq`:
cpufeatures::new!(clmul, "pclmulqdq");
But the functions it guards are annotated with both `avx2` and
`pclmulqdq`:
#[target_feature(enable = "avx2", enable = "pclmulqdq")]
pub(super) unsafe fn expand_key(h: &[u8; 16]) -> ExpandedKey { ... }
On CPUs that support PCLMULQDQ but **not** AVX2 (e.g. Intel Pentium
Gold, Celeron, some Atom processors), the runtime check incorrectly
passes, AVX2-annotated functions are called, and the process crashes
with `SIGILL` on VEX-encoded instructions.
## Fix
```diff
-cpufeatures::new!(clmul, "pclmulqdq");
+cpufeatures::new!(clmul, "pclmulqdq", "avx2");
```
This ensures the intrinsics path is only used when both features are
available. CPUs without AVX2 correctly fall back to the software
implementation in `backend/soft.rs`.
## Testing
Verified on Intel Pentium Gold G5420 (PCLMULQDQ: yes, AVX2: no). Before
the fix, any AES-GCM operation crashed with SIGILL. After the fix,
polyval correctly uses the software fallback and all operations succeed.avx2 to runtime CPU feature check (#316)1 parent 929ee7a commit f58c8a6
1 file changed
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
| 34 | + | |
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| |||
0 commit comments