pqcrypto icon indicating copy to clipboard operation
pqcrypto copied to clipboard

Aarch64 feature detection

Open thomwiggers opened this issue 10 months ago • 7 comments

Should fix #82

thomwiggers avatar Mar 03 '25 11:03 thomwiggers

I can confirm that

[patch.crates-io]
pqcrypto-traits = { git = "https://github.com/rustpq/pqcrypto", branch = "aarch64-feature-detection" }
pqcrypto-mldsa = { git = "https://github.com/rustpq/pqcrypto", branch = "aarch64-feature-detection" }
pqcrypto-mlkem = { git = "https://github.com/rustpq/pqcrypto", branch = "aarch64-feature-detection" }

fixes Fatal signal 4 (SIGILL), code 1 (ILL_ILLOPC) on Android Pixel 7 for me.

icota avatar Mar 16 '25 17:03 icota

On second glance it only fixes ml-dsa. If I try to get an ml-kem keypair I still encounter:

signal 4 (SIGILL), code 1 (ILL_ILLOPC), fault addr 0x000000744d312fb4
    x0  0000007451950550  x1  000000744cdd9828  x2  00000074519503d0  x3  0000000000000018
    x4  00000074519503d0  x5  000000000000001f  x6  0000000000000010  x7  7f7f7f7f7f7f7f7f
    x8  0000000000000003  x9  0000000000000014  x10 000000000000001f  x11 f41107a453e2076c
    x12 0000000000021003  x13 000000007fffffff  x14 0000000000000000  x15 0000027433a5a687
    x16 000000744d5e4480  x17 0000007830d67940  x18 0000007443da0000  x19 b4000076f9369c70
    x20 b400007599339900  x21 000000744d5af710  x22 0000000000005232  x23 00000000000051dc
    x24 00000074519606c0  x25 00000074519606c0  x26 0000007451960a28  x27 0000007451960a80
    x28 0000000000206000  x29 0000007451950160
    lr  000000744d312f6c  sp  0000007451950110  pc  000000744d312fb4  pst 0000000020001000

icota avatar Mar 16 '25 18:03 icota

I can fix the above by having ml-dsa check for sha3 instead of merely neon. But I'm not sure if that's a proper fix. I'll make a PR to this branch regardless.

icota avatar Mar 16 '25 18:03 icota

Would be great if you could test this again

thomwiggers avatar Mar 17 '25 04:03 thomwiggers

@thomwiggers it crashes on https://github.com/rustpq/pqcrypto/commit/097a7b437821aff5828a4407c12a2508440bc1ed

icota avatar Mar 17 '25 08:03 icota

Can you elaborate? There are no differences with #84 in how the code is called (though I'm suspicious that the cfg guards in #84 are broken which leads to the code not getting included).

thomwiggers avatar Mar 17 '25 09:03 thomwiggers

From my perspective your fix works: ML-DSA runs on a RasPi now. Thanks a lot for your support!

hfunke avatar Mar 17 '25 13:03 hfunke