-
Notifications
You must be signed in to change notification settings - Fork 126
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
Accelerated AES and SHA2 implementations #878
Conversation
5ae65fe
to
49f4891
Compare
19dbbaa
to
0eb4c5f
Compare
@weaversa, I'm interested in your thoughts regarding the Cryptol API exposed via the new |
This branch now contains built-in implementations of the following primitives: Currently, these primitives are not implemented in the symbolic backends. Attempts to call |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this all looks good as it is, but it makes me think of two meta topics.
First, we have :dumptests
command, and I wonder whether we should have some sort of way of reading and running tests in the same format. That would allow the AES and SHA test vectors to be purely declarative, rather than being interspersed with code.
Second, as of recently we now depend on the cryptonite
library for part of the RPC API. Would it make sense, given that, to use it for these crypto primitives? Does it expose a useful API? I'm not sure it's worth the effort to change, given that we'll eventually be swapping in C code, but I thought I might as well mention it.
I haven't looked much at the As to |
Ah, yeah, I guess it makes sense that |
block functions, ripped out of the SHA package, and expose it via new Cryptol primitives. Using these primitives in place of the defined reference implementations leads to approx 100x speed-up in larger protocols that do a lot of hashing. I don't know if this is the implementation we'll actually end up using, but this verifies the overall idea and helps design the API.
named `SuiteB`, and finish packaging up the primitives.
implementations. Not sure this is actually a good idea, but propigating the constraints around in larger algorithms is very inconvenient.
This implementation is taken fairly directly from the SBV tutorial module. It is a Word32-oriented implementation using TBoxes. We make the implementation avalible via Cryptol primitives that are similar to the AESNI instructions, with primitives for the individual rounds and some utility primitives for performing key expansion.
Expand the lookup tables manually and remove the basic GF(2^8) polynomial arithmetic algorithms. Rename the SHA primitives.
These are taken from the AESAVS document and associated sample test vectors, which may be found here: https://csrc.nist.gov/Projects/cryptographic-algorithm-validation-program/Block-Ciphers
and add a battery of SHA test vectors as well.
This excludes the new SuiteB tests, and moves the `allexamples` test into a separate directory that is also excluded. The standard `test` command still runs all tests.
6e84a5c
to
2581849
Compare
This is a bit of a work in progress, but the initial results are promising. Even a fairly naive Haskell implementation runs about 100x faster than interpreting a reference implementation.
Some questions: