6 ms·
Liblithium: A lightweight and portable cryptography library
- jedisct1 4y agoLooks like this is heavily based on libhydrogen, but without nonce-misuse resistance (not a good idea in this context IMHO)? Nothing wrong with that, and I'm glad that libhydrogen was useful for Tesla, but mentioning it would have been polite.
- TontonNestor 4y agoI would be careful with Gimli https://eprint.iacr.org/2020/744 https://eprint.iacr.org/2020/744
- jedisct1 4y agoThere are no practical attacks on Gimli when used as intended. That being said, Gimli in libhydrogen may eventually be replaced by Xoodoo.
- bugfix-66 4y agoPublished by Tesla? It's unwise to use cryptographic code written by engineers working 72 hour weeks at an "extremely hardcore" company. Here is the Gimli spec: https://gimli.cr.yp.to/spec.html https://gimli.cr.yp.to/spec.html Here is the attack illustrating weaknesses in the design: https://eprint.iacr.org/2017/743 https://eprint.iacr.org/2017/743 Here is a statement from the Gimli team arguing that it is still secure despite the published 22-round attack: https://gimli.cr.yp.to/statement.html https://gimli.cr.yp.to/statement.html Finally, Hamburg's "attack" will not be feasible in the foreseeable future, even with quantum computers. Even if the "attack" were extended to the full 24 rounds, it would not contradict any security claims made in the Gimli paper. Daniel J. Bernstein (djb) is a wizard, but use Gimli at your own risk.
- mananaysiempre 4y agoJudging from the statement (I haven’t the cryptographic kung fu to distil the paper myself), the attack seems to be more of an exploration of how vulnerable the (relatively new) ways the Gimli suite builds everything out of a single crypto core can be when used badly, not something applicable to the usage that’s actually specified. Or is that still concerning? (Plus it does seem worse than brute force from the numbers given, though I can’t judge whether that makes it uninteresting in general, either.)
- bugfix-66 4y agoYes, you clearly don't understand it. That's ok, but you probably shouldn't confuse the issue. Basically the attack shows that Gimli's speed and simplicity introduces exploitable flaws and reduces its security: Bernstein et al. have proposed a new permutation, Gimli, which aims to provide simple and performant implementations on a wide variety of platforms. One of the tricks used to make Gimli performant is that it processes data mostly in 96-bit columns, only occasionally swapping 32-bit words between them. Here we show that this trick is dangerous by presenting a distinguisher for reduced-round Gimli. https://eprint.iacr.org/2017/743 https://eprint.iacr.org/2017/743
- adrian_b 4y agoYet the attack, as very clearly stated at your link, does require much more computing resources and time than a standard brute force attack. So I can only agree with DJB that the attack, in its present form, is completely useless. At most, it can be argued that maybe someone will find a way to use the ideas from your link to conceive a new attack that is much more efficient. I do not find this more convincing than the threat that someone will find an efficient attack based on completely different ideas. Any more recent cryptographic algorithm is riskier than the older algorithms, because it is less understood. However Gimli is intended for slow microcontrollers, where the encrypted data cannot be very valuable, otherwise one would use a slightly more expensive CPU like Cortex-A55 (a few dollars instead of less than a dollar, for a MCU/MPU package), with standard cryptographic libraries. So the damage done by an attacker decrypting the MCU communication cannot be great, therefore it is an acceptable risk to use a less trusted algorithm, if that reduces a lot the hardware cost.
- deleted 4y ago[deleted]
- unwind 4y agoI should not be allowed into the same room as crypto development, and have certainly never tried to "attack" a crypto algorithm. Still, reading that, against 22.5 (of 24) rounds of the Gimli computation, the attack is claimed to need 2^129 bits of memory. That is 77,371,252,455,336,267,181,195,264 TB if math is right, which does seem to gently push that "attack" into a rather theoretical plane? Not sure what I'm missing, from your tone I would expect a smoking hole and this doesn't seem to be that.
- sbf501 4y agoIt is not a crypto library, it is an Ed25519 EdDSA library. It has nothing else in it apparently. WolfCrypt is a better solution and is FIPS certified. EDIT: I didn't know what GIMLI was.
- lvh 4y agoNo, it's an Ed25519 library _and_ a Gimli library. Gimli can be used to make a wide range of functions, including MACs, hashes and stream ciphers, just like SHAKE. (That is not an endorsement.)
- wahern 4y agoMaybe a little pedantic, but per the website liblithium doesn't implement Ed25519. It uses a signature scheme based on X25519, which is usually used for key exchange. From the perspective of interoperability, the liblithium scheme is nearly as different from Ed25519 as it is from ECDSA P-256, notwithstanding that you can technically convert Ed25519 keys to X25519 keys.
- sbf501 4y agoHow do you convert from Ed25519 to X25519 when certain bits have been masked off the MSB range? Do you mean X25519 -> Ed25519 or am I misunderstanding?
- wahern 4y agoAFAIU, you can go in both directions, though in one of the directions (I think X25519 -> Ed25519) you have to discover or choose one among equivalent keys. I've implemented some ciphers, and many more security protocols, but I won't pretend to understand the math well enough to directly address your question. But I believe schemes sharing keys between Ed25519 and X25519 generally rest on this paper: https://eprint.iacr.org/2021/509.pdf https://eprint.iacr.org/2021/509.pdf That paper describes the process in both directions, IIUC. See page 4, > In this case the recipient translates the public key from edwards25519 to an X25519 public key using the map from [17] and page 6, > We will retrieve the two candidates for the v-coordinate from the curve equation and choose one of them uniformly at random. We then change coordinates to edwards25519 using the map in [17, 4.1]. This change of coordinates preserves addition on the curve and the basepoint of curve25519 is mapped to the basepoint on edwards255196. See https://libsodium.gitbook.io/doc/advanced/ed25519-curve25519 https://libsodium.gitbook.io/doc/advanced/ed25519-curve25519 for an actual implementation converting Ed25519 to X25519 keys. See also https://www.rfc-editor.org/rfc/rfc7748.html#section-4.1 https://www.rfc-editor.org/rfc/rfc7748.html#section-4.1 (citation reference 17, above) for the mapping function(s), though it sounds like you may have already been familiar with it. Maybe there's some nuance wrt converting public vs private key components I'm ignoring. But libsodium provides routines for converting both public and private Ed25519 keys to X25519 independently--i.e. doesn't require the private Ed25519 key to convert the public key. Because EdDSA is more common and widely deployed than X25519/X448 key exchange (or signing) schemes, Ed25519 -> X25519 is typically the direction you care about, permitting you to preserve or leverage existing public and private key management infrastructure.
- svnpenn 4y agoDoesn't C have years and years of repeated security flaws due to lack of memory safety? What's the motivation to continue releasing greenfield projects in C?
- remexre 4y agoSounds like this is intended to run on targets rustc would not support, given the claim that it "does not assume 8-bit addressability". Also, while I'm fully on board the "Rust as a default userspace systems language," the machine code I've gotten out of trying #[no_std] Rust to write part of a bare-metal project was heinously bloated. This is without even using any non-libcore dependencies! Something like 3/4s of the machine instructions looked like they were related to building error messages for panics, despite the fact that there shouldn't have been any reachable panics (and the code was small and simple enough that I expected LLVM to be able to reason about this without any MIR-level optimizations). Maybe this would be better on a project that could use rustc as its linker, but based on this, I wouldn't necessarily recommend that a bare-metal library intended to be linked to C and hand-written assembly be written in Rust versus, say, verified with Frama-C or other C-specific tools.
- mananaysiempre 4y agoTo be fair, the AVR and STM8 code I’ve got out of GCC and SDCC when feeding them normal (non-8-bitter-adapted) C also sucked—though not to the point of building strings—because the default promotion to int required by the standard really hurts when the minimum required 16-bit int does not fit into a register.
- remexre 4y agooh, yeah, I can totally imagine that; this was being built for AArch64 though; with all the Cortex-A features, even!
- higherhalf 4y agoI'm latching onto a non-main argument to be pedantic, but I'd like to mention that Rust is fine for _non-embedded_ kernel development too, in my experience. As you're likely aware, Rust for embedded sucks when there's no HAL, but should be pretty pleasant otherwise. Have you looked into the cortex-a[1] crate? Some unnecessary instructions could also be a part of an ongoing optimization effort[2][3]. [1]: https://github.com/rust-embedded/cortex-a https://github.com/rust-embedded/cortex-a [2]: https://old.reddit.com/r/rust/comments/yn6105/optimization_of_memcpys_in_rustc_and_llvm_16 https://old.reddit.com/r/rust/comments/yn6105/optimization_o... [3]: https://arewestackefficientyet.com https://arewestackefficientyet.com
- lvh 4y agoThis seems extremely similar to https://github.com/jedisct1/libhydrogen https://github.com/jedisct1/libhydrogen -- X25519 and Gimli. (well, and the name...). It also appears to pull from its test suite and aim for compatibility in some ways.
- Grimburger 4y ago> and the name Frank Denis also wrote libsodium, so guess it is a pun by him? Don't think there was any lib{chemical element} popularised before that, and there's a few now, but could be wrong.
- fmajid 4y agoOr maybe an inside joke at Tesla about what their CEO is in most dire need of.
- beagle3 4y agolibsodium itself is a fork of NaCl[0], an acronym for Networking And Cryptography Library, but also the chemical composition of table salt (Sodium Chloride; the latin name for Sodium is Natrium hence Na) [0] https://en.wikipedia.org/wiki/NaCl_(software) https://en.wikipedia.org/wiki/NaCl_(software)
- highwaylights 4y agoWhich was also the name used by Google for the precursor to WASM. Acronyms all the way down.
- jedisct1 4y agoYes, libhydrogen is a pun, as it is lighter than libsodium. The first version was a rewrite of libsodium, that was small and contained in a single C file. Also introduced xchacha20 for the first time. Then, the Gimli paper was published, and libhydrogen was rewritten to take advantage of it. Smaller than libhydrogen, there's now charm: https://github.com/jedisct1/charm https://github.com/jedisct1/charm , also a pun. The plan was to eventually add bottom (platform abstraction layer), strange (asymmetric cryptography), and top (high-level APIs) to build a modular, component-based library.
- baby 4y agoWondering if the authors heard of embedded disco[1] which uses X25519 and STROBE but with the SHA-3 permutation instead of gimli (and additionally uses Noise for encrypting and authenticating communications) [1]: https://embeddeddisco.com/ https://embeddeddisco.com/ PS: more info: * video: https://www.youtube.com/watch?v=bTGLO4obxco https://www.youtube.com/watch?v=bTGLO4obxco * paper: https://eprint.iacr.org/2019/180 https://eprint.iacr.org/2019/180
- im3w1l 4y agoThis is a bad name as Crystals-Dilithium is a recently standardized post-quantum signature scheme. Bound to cause confusion.
- im3w1l 4y agoOh, nvm this looks to be a few years old.