rust-crypto icon indicating copy to clipboard operation
rust-crypto copied to clipboard

AES-NI fails on ‎Westmere

Open henrycg opened this issue 9 years ago • 3 comments

The AES-NI code in aesni_helpers.c uses the AVX instruction vpslldq but Westmere machines (and possibly others) support AES-NI but do not support the AVX instructions. Because of this, the AES implementation in rust-crypto throws an SIGILL exception on these machines.

henrycg avatar Oct 07 '16 20:10 henrycg

Hello, yes, i logged an issue #391 relative to this bug. I'm trying to use PSLLDQ instead, but actually no luck...

yd021976 avatar Oct 22 '16 06:10 yd021976

Hello again, got it working by using PSLLDQ instead of VPSLLDQ .

you can replace this block in aesni_helpers.c, line 62 :

1: \
            pshufd $0xff, %%xmm2, %%xmm2; \
            vpslldq $0x04, %%xmm1, %%xmm3; \
            pxor %%xmm3, %%xmm1; \
            vpslldq $0x4, %%xmm1, %%xmm3; \
            pxor %%xmm3, %%xmm1; \
            vpslldq $0x04, %%xmm1, %%xmm3; \
            pxor %%xmm3, %%xmm1; \
            pxor %%xmm2, %%xmm1; \
            movdqu %%xmm1, (%0); \
            add $0x10, %0; \
            ret; \

By this :

1: \
            pshufd $0xff, %%xmm2, %%xmm2; \
            movdqa %%xmm1, %%xmm3; \
            pslldq $0x04, %%xmm3; \
            pxor %%xmm3, %%xmm1; \
            pslldq $0x04, %%xmm3; \
            pxor %%xmm3, %%xmm1; \
            pslldq $0x04, %%xmm3; \
            pxor %%xmm3, %%xmm1; \
            pxor %%xmm2, %%xmm1; \
            movdqu %%xmm1, (%0); \
            add $0x10, %0; \
            ret; \

yd021976 avatar Oct 22 '16 06:10 yd021976

thank you @yd021976, this helped me

celevra avatar Mar 06 '17 19:03 celevra