3

Does CPython hashlib's SHA256 employ the Intel SHA extensions ? If yes, since which version(s)?

Since CPython uses OpenSSL for its crypto primitives it should also use its hardware acceleration capabilities (AESNI-SHA256 was added to OpenSSL between 1.0.1l and 1.0.2 on 22 Jan 2015), but I can't find out if and since when SHA256 hardware acceleration is used. I tried to understand the sha256module.c source but got lost in the abstractions :(

Bonus question: AFAIK, the CPython for Windows release statically links OpenSSL. When was it upgraded to a version of OpenSSL that can theoretically use SHA-NI, and: Does it use them? (Sorry, I couldn't even Google that)

Florian Sesser
  • 5,972
  • 1
  • 25
  • 26
  • 3
    For Python 3.8, I have tested both WSL and Windows and both "seem" to use the extensions. I basically wrote a C program that I know for a fact uses the extensions and compared the speeds. There is only ~1 second of difference over 100m hashes. – Melih Yıldız' Apr 24 '21 at 21:58

0 Answers0