-
Notifications
You must be signed in to change notification settings - Fork 131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hardware accelerated AES for ARM #10
Comments
Should we plan to use stdsimd? |
Excellent! I've subscribed to both issues and will try to implement both ARM and x86 versions once they get implemented in the |
FYI, I recently added aarch64 AES intrinsics in rust-lang/stdarch#398. I believe AES intrinsics for x86 are in there already. |
Yes, I've seen it, thank you for this addition! When I'll have time I'll try to play with them and implement the crate. (if no one beats me to it that is) AES-NI intrinsics already utilized in the |
@jack-signal I saw you have hardware accelerated Any interest in upstreaming that? |
At this point everything Signal is putting out, including that crate, is AGPL, I doubt there is interest in relicensing so probably wouldn't work. It's worth pointing out though that the linked code is just for AES-256 in forward direction because that is all we needed, and it doesn't implement any of the RustCrypto traits so a ways off from something you could use. Someone recently pointed me at the MIT licensed https://github.com/shadowsocks/crypto2/blob/master/src/blockcipher/aes/aarch64.rs which might work better as a starting point. But that code doesn't do instruction pipelining, and the key schedule isn't constant time :( |
Ugh, alright, it seems both those approaches are a no-go. |
@newpavlov were you thinking of trying to do an implementation of this from scratch? |
SUPERCOP contains a public domain implementation of the full AES-GCM including one based on ARMv8 intrinsics which works on 8-blocks-at-a-time in parallel: |
@tarcieri |
@newpavlov no worries! I have an Apple M1 Mac Mini that as of yesterday now has the beta Rust compiler I can test things on. I might experiment to see if I can get it working. |
@newpavlov you can always get an AWS EC2 instance to test code, until the end of 2020 one |
qemu supports the Aarch64 crypto extensions and is pretty easy to integrate into
Then you can build and test Aarch64 code on x86-64 |
As it were, we already use https://github.com/RustCrypto/block-ciphers/blob/7236bce/.github/workflows/aes.yml#L149-L181 |
I was able to translate this public domain implementation of AES-128: https://github.com/noloader/AES-Intrinsics/blob/master/aes-arm.c My translation is here. It runs successfully on my Apple M1, and passes the supplied test vector: https://gist.github.com/tarcieri/f10b0c58a56dfab4917c3832f93b25af It still needs a round key expansion but that's not terribly difficult. Likewise for AES-192 and AES-256 support. The implementation is using |
Sidebar, but in researching AES on ARM I came across this paper which looks potentially helpful: "Efficient Parallel Implementation of CTR Mode of ARX-Based Block Ciphers on ARMv8 Microcontrollers" |
I landed ARMv8 Cryptography Extensions support in #250, however it's only tested on and therefore presently gated on If you're interested in support for 32-bit ARMv8 targets or other types of ARM acceleration, please leave a comment on this issue or make a new issue. |
Similar to
aesni
crate it would be nice to have hardware accelerated AES support for ARM using specialized instructions.The text was updated successfully, but these errors were encountered: