A new crypto library

Why is a trusted, feature-complete crypto library not a top priority for the Rust community?

I read this article a long time ago, and unfortunately the Rust community still doesn't have a good solution today.

A few months ago, I wrote this crypto library, and it supported all AEAD crypto-algorithms. And both the X86 and ARM64 platforms have good performance.

Currently, there is no official release, and you can find the code here: https://github.com/shadowsocks/crypto

Compare performance with Ring, OpenSSL, RustCrypto, Crypto: https://github.com/LuoZijun/crypto-bench

What does "feature-complete" mean for you? I wouldn't say that good crypto libraries are "not a priority" for the community. Maybe most people don't use crypto in the same context as you do. For example, I usually want crypto for the communication between my smartphone apps and server backends – for that, I've found libsodium and sodiumoxide to be the go-to solution, as it's an audited, cross-platform library with bindings to several other laguages.

2 Likes

FYI, there are already two projects called "Rust Crypto":

It'd be quite confusing if there were a third.

As far as an omnibus crate like this goes, ring is both mature and widely used within the Rust ecosystem.

I took a quick look at the source code to your crate. It seems to contain a copy-and-paste version of my zeroize crate without acknowledgement, rather than using the upstream crate. I'm not sure why it doesn't just use the upstream crate?

The AES implementation is based on lookup tables:

This is widely recognized as problematic due to cache timing attacks and other microarchitecture sidechannels. See for example:

10 Likes

This means that there is good support for popular and some not so popular crypto algorithms.

For example, you mentioned the libsodium project, which only supports AES-GCM and Chacha20-Poly1305. It does not support other crypto-algorithms such as Camellia, Aria, AES-CCM, AES-GCM-SIV.

In the real world, some services are beyond your control, such as some HTTPS sites that use cipher suites that aren't so popular or even have weaknesses. If you use libraries like rustls built on top of ring, you won't be able to connect to those HTTPS services.

Finally, I agree that a strict code security audit is required for a cryptographic library.

I know that problem. But I don't want to make some changes to that, because the existing hardware already supports AES instructions, so in X86 and ARM64, the code for AES-NI is actually used, not a software implementation.

Yes, the code for 'zeroize' comes from 'zeroize' crate. But because I personally dislike Procedural Macros.

So I decided to make a copy. If you don't want to, I can delete the code.

The proc macros are disabled by default, and only included if you enable the zeroize_derive feature.

I would appreciate you using the upstream crate or at least crediting the vendored code, including the original copyright information.

It would be better if you didn't include code with known vulnerabilities, rather than providing an insecure fallback.

4 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.