Mundane: Rust cryptography library that is difficult to misuse
github.com
github.com
It's an unproven library, but the author takes security pretty seriously. There's no unsafe, heavy testing, and fuzzing done for both safety (fuzzing with a sanitizer) and constant-time operation verification to minimize the danger of a timing attack.
Here's an example of the API.
let key = aead::SecretKey::default();
let ciphertext = aead::seal(&key, "msg".as_bytes())?;
let plaintext = aead::open(&key, &ciphertext)?;
It doesn't get much easier than that. Also, notice the lack of a user-facing nonce. Can't screw it up if it isn't there.There are also lots of details that are right in the library. Traits like PartialEq are implemented using constant-time operations so that users don't have to know or remember to use special operations provided by the library for comparison. Methods that return types without these protections (like getting the raw bytes out of a PasswordHash) are helpfully named things like "unprotected_as_encoded".
[1] https://github.com/brycx/orion
[2] https://docs.rs/orion/0.15.5/orion/aead/index.html#example
Where would i learn what i need to use smart tools by other people? Where would i learn enough to decide how to choose solving my above problems with Orion vs GPG?
That's been my biggest problem with crypto. I know enough to know to be wary, but not much beyond that. Choosing tools with that mindset is difficult. And so far, taking a crypto class is just teaching me fundamentals of building my own protocols - where as i just want to use existing tech, safely, and in the right situations.
My naive guess, without knowing exactly what the sticking point is for you, is that Orion could do a better job on the modules page [1] explaining exactly what each module is for and when to use it.
Right now, I'd say the state of the library, rather than its intention, is that it's extremely usable for people who pretty much know what they want, and fairly hard for the average developer to misuse.
But I believe the author would be very interested in something that makes the library cater better to people who don't want to learn crypto, but just want to get things done using it.
[1] https://docs.rs/orion/0.15.5/orion/index.html#modules
EDIT: After some thought, I think I would say that the API for Orion is maybe an 8/10 for beginners, but the documentation is still at maybe 5/10 or 6/10 for beginners. Someone who is familiar with crypto would probably be able to look at the documentation and know what they're doing, but for someone unfamiliar with crypto, I can see how there isn't a ton in the way of explanation of the various primitives. That would be a good area for improvement for the library.
Crypto puts people who know the unknowns in an awkward position. If i was fully ignorant i'd probably find more progress, as i'd be willing to just throw bytes around and see what works. Yet i've seen so many horror stories and tales of caution that i'm left never knowing if it's safe to do X in Y scenario.
Combine that with my goal of using this code in Desktop, Mobile, WASM (maybe web, definitely mobile, etc) - and a bunch of scary new attack vectors get introduced and compound confusion.
It's difficult to know where to start haha. Anyway, hopefully this answers your question :)
If you study those docs you'll get the modern terminology used by most other libraries as well as the intended use-cases for the different cryptographic constructs.
Your examples point to public-key use-cases, and I don't see any public-key crypto support in this Orion library, so probably you just wouldn't use it ;)
I really appreciate your feedback, thank you! After reading this, I think your point-of-view hasn't been taken correctly into account when creating and reviewing the documentation. I'll definitely take this up to consideration in regards to possible improvements.
For some more insight (as someone else was asking), i replied with a bit more depth here: https://news.ycombinator.com/item?id=25449538
Thanks for the awesome looking library. I'll go ahead and fumble my way through it soon, i'm sure it's not as complex as i'm making it. I'm just not sure what usage is "safe" - so i look forward to documentation that helps me understand Safety in this context :)
Here's the tracking issue for a first security audit: https://github.com/brycx/orion/issues/21.
Near the bottom of that issue, an employee from NCC reached out and said that they may be interested in funding an audit for Orion, though it's been a couple months and that hasn't gone anywhere (that I know of).
Small correction: It was actually an employee of Mobilecoin, the company that funded the audits for RustCrypto, which were performed by NCC.
https://jbp.io/2020/06/14/rustls-audit.html
(I also don't think all of RustCrypto has been audited, only very limited parts AIUI.)
See https://www.reddit.com/r/rust/comments/fa8a96/audit_of_the_r...
It is also has a focus on hard to misuse API design and uses some BoringSSL primitives as well, while notably not depending on it's build system (go, Perl, ...)
A cursory glance at the code suggests that `mundane` is purely an API wrapper for BoringSSL at the moment, and does not implement any crypto in Rust.
Ring has a policy[0] of only supporting the latest released version with users being expected to always upgrade to latest Ring. This in itself is not so bad, but coupled with the lack of any guarantees around API stability means that it can be a very tricky dependency to work with. This problem is compounded by it only being possible to link one version of Ring in to the same program.
Even if you don't depend on Ring directly, Ring could appear as a dependency of many of your dependencies. This forces you into upgrading all of your Ring-depending dependencies in lockstep. You cannot upgrade any until all of these dependencies support the same latest version of Ring.
This is a real shame because Ring otherwise looks fantastic. The API is misuse resistant and looks quite pleasant, and the documentation is thorough. Its current versioning and stability policy however is a massive liability for any project that relies on it. I hope this changes eventually.
[0]: https://github.com/briansmith/ring#versioning--stability
I am planning to fix this in ring early in 2021 (January)...
> Even if you don't depend on Ring directly, Ring could appear as a dependency of many of your dependencies. This forces you into upgrading all of your Ring-depending dependencies in lockstep. You cannot upgrade any until all of these dependencies support the same latest version of Ring.
Then you won't need to upgrade everything in lockstep.
That said, I still do recommend everybody only use the latest version.
This is definitely the piece that gives the current versioning policy its sharp edge, so it's great news that the fix will arrive soon.
Thanks for your hard work on Ring!
This is my experience as well, it's one of the best crypto libs and the devs are topnotch, yet relying on it is often painful, many libraries out there are rendered unusable.
It sounds like he's willing to listen to feedback about the policy, but would rather have focused time dedicated to discussing it rather than long drawn out inconclusive tickets.
I'm appreciative of all the work that has gone into Ring, its certainly not something I could have done or have any expertise in, but it is a landmine to depend on.
[1]: https://doc.rust-lang.org/1.8.0/book/inline-assembly.html
I’ve also used tooling[2] to measure any timing issues in libraries like dalek (ed25519) and it couldn’t find any (so good luck if you’re trying to exploit that over the network)
[2]: https://github.com/rozbb/dudect-bencher
Today I’d be more worried by memory safety bugs created by the use of C or assembly, or logic bugs due to only a few people being able to audit an implementation.
You are right that ring has a much-reduced set of build dependencies compared to Mundane/BoringSSL. However, it is also true that Google implemented some build system support (to support Mundane?) that will help ring's custom build system a lot too, once I find some time to make use of it.
I mean this is kinda like a rust library with a dependency on a Java JVM.
I will point out that BoringSSL is also mainly developed by Google, so...kinda?
I still trust it, just a kinda interesting fact
It is still possible to [make Mundane] link against system's OpenSSL. However, that's a bit different set of worms to locate it, auto-generate working FFI bindings, etc.
It tries really hard to hide all the crypto mumbo-jumbo from the users so that they don’t have to be experts in algorithm choice and protocol design in order to safely use a library instead of shooting themselves in a foot.
Themis is also a wrapper over OpenSSL/BoringSSL, relying on proven crypto implementations instead of trading a simpler build system for god knows how many sleeper primitive implementation bugs. However, binary packages exist for major distros, so if you don't want to build from source you can avoid that easily.
Also, docs for humans do exist [2], packages exist, etc.
This is not an official port of Tink, and is not supported by Google's cryptography teams.
Sounds similar to the motivation behind nacl[1], though my understanding is that most development now happens in libsodium[2].
This is awesome! I love you!
> BoringSSL is a fork of OpenSSL that is designed to meet Google's needs.
> Although BoringSSL is an open source project, it is not intended for general use, as OpenSSL is. We don't recommend that third parties depend upon it. Doing so is likely to be frustrating because there are no guarantees of API or ABI stability.
You're right though, they should at a minimum link to it more prominently.
Documentation as is is virtually non-existent there. Unless you're already familiar with how these functions are supposed to work.
Because google support wouldn't be reliable enough /s
But honestly, doesn't the license usually tell such things?
ring is also hard to misuse, and more actively maintained by far.