scrypt-jane icon indicating copy to clipboard operation
scrypt-jane copied to clipboard

improper test for AVX runtime support, invalid opcode crash

Open vlv-henryg opened this issue 8 years ago • 0 comments

In scrypt-jane-portable-x86.h, the line

    if ((regs.ecx & (1 << 28)) && (xgetbv_flags & 0x6)) cpu_flags |= cpu_avx;

should instead be

    if ((regs.ecx & (1 << 28)) && ((xgetbv_flags & 0x6) == 0x6)) cpu_flags |= cpu_avx;

because both bits (0x04 for YMM registers, and 0x02 for XMM registers) must be set to indicate OS support for AVX. Without this, systems that have AVX disabled by the OS (for example, Windows 7 RTM) will select the AVX implementation and crash on first run.

(Also, thanks for providing your simple-to-integrate implementations of various crypto primitives, they have proven to be immensely useful time and time again.)

vlv-henryg avatar Mar 03 '16 20:03 vlv-henryg