libtom / libtomcrypt

LibTomCrypt is a fairly comprehensive, modular and portable cryptographic toolkit that provides developers with a vast array of well known published block ciphers, one-way hash functions, chaining modes, pseudo-random number generators, public key cryptography and a plethora of other routines.
https://www.libtom.net
Other
1.55k stars 457 forks source link

Add AES-NI #557

Closed sjaeckel closed 1 year ago

sjaeckel commented 3 years ago

This PR adds support for the AES-NI instructions as discussed in e.g. #480 or #551

karel-m commented 3 years ago

Basically fine.

I am just thinking about having:

aes_autodetect_desc

on top of:

aesni_desc
aes_desc

I have to think it over.

karel-m commented 3 years ago

Or even:

aesni_desc      (new AES-NI)
aessw_desc      (old SW implementation aes_desc renamed to aessw_desc)
aes_desc        (aes with runtime autodetection of aessw/aesni variant)

With this all calls like find_cipher("aes") (we have it at many places) will choose autodetected aessw/aesni variant.

sjaeckel commented 3 years ago
aesni_desc      (new AES-NI)
aessw_desc      (old SW implementation aes_desc renamed to aessw_desc)
aes_desc        (aes with runtime autodetection of aessw/aesni variant)

With this all calls like find_cipher("aes") (we have it at many places) will choose autodetected aessw/aesni variant.

I like the idea but what's the purpose of the aesni_desc? It should still check whether the CPU has support as otherwise bad things will happen.

My proposal would therefor be to make aesni the new default:

aes_desc        (aes with runtime autodetection of aessw/aesni variant)
aessw_desc      (old SW implementation aes_desc renamed to aessw_desc)

What do you think?

I'm having an early WIP about adding support for the AES instructions on ARMv8, there we could then basically use the same pattern and add a aes_arm.c which provides aes_desc and also does autodetection!?

sjaeckel commented 3 years ago

Hah, having a second look I understand your reasoning ... I have to think about it a bit more!

isarrider commented 1 year ago

@sjaeckel will there be an update?