-
-
Notifications
You must be signed in to change notification settings - Fork 523
Use more RustCrypto #328
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
Use more RustCrypto #328
Conversation
aa35f0e
to
197f05a
Compare
Nice side benefit:
|
Oh, looks like the benefit all came from bumping the toolchain version, and this actually increases the size a little (1,858,608 to 1,870,912). Oh well. |
Now that RustCrypto aes-gcm-siv supports runtime-detected ARMv8 and x86_64 crypto intrinsics, we don't need our own implementation, which will be removed from signal-crypto in a later commit.
Also turn on the AES crate's use of ARMv8 intrinsics
Same as before, but for the wrapper exposed to the app languages.
This was never exposed in Swift, so there's no effective change.
The signal-crypto struct Aes256Ctr32 is still useful because we use a different nonce size than RustCrypto's "full block", and we provide a convenience constructor to specify an initial counter value.
8316a22
to
4519eb4
Compare
@@ -86,7 +86,7 @@ private Native() {} | |||
|
|||
public static native byte[] Aes256GcmSiv_Decrypt(long aesGcmSiv, byte[] ctext, byte[] nonce, byte[] associatedData); | |||
public static native void Aes256GcmSiv_Destroy(long handle); | |||
public static native byte[] Aes256GcmSiv_Encrypt(long aesGcmSiv, byte[] ptext, byte[] nonce, byte[] associatedData); | |||
public static native byte[] Aes256GcmSiv_Encrypt(long aesGcmSivObj, byte[] ptext, byte[] nonce, byte[] associatedData); |
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.
Why the Obj naming here?
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.
It comes from the Rust source, which renamed a parameter named aes_gcm_siv
so that it wouldn't shadow the package name.
Now that RustCrypto crates support runtime-detected ARMv8 and x86_64 crypto intrinsics, we don't need our own implementations of AES to get good performance.* We still have our own wrapper for AES-256-CTR, and we have a streaming version of AES-256-GCM, but overall this makes the signal-crypto crate a lot smaller.
This is a lot of changes for one PR, but that's because our PR tests ensure that Cargo doesn't include two incompatible versions of a dependency in the output binary. This means that in order to pick up the new version of the
aead
crate, I had to remove all uses of the old version.*
blocked on RustCrypto/utils#435 getting into a releasedone!