
What is it?
Pure Rust implementations of static Diffie-Hellman key-exchange and ECDSA. It includes impls for both plain vanilla DH, elliptic-curve DH along with ECDSA impls for p256, p384.
- The standard DH implementation is a (vanilla) object oriented api. It has support for multiple DH Groups DH5, DH14, DH15, DH16, DH17, DH18.
- The ECDH implementation comes with a textbook implementation of
Affine-Pointarithemtic asProjective-Pointarithmetic in RustCrypto is only implemented for curves p256, secp256k1 and support for more curves is on the cards but not yet available. - ECDSA impls use the ECDH module for key generation.
- The crate makes use of
min-const-genericsextensively for code-reuse. You'll need rust-1.51 which has added support for it.min-const-genericsis now stable onrust-nightly.
Usage:
use ;
Output:
)
)
use ;
use ;
Output:
)
)
)
Imp: This crate does not in anyway aim to replace RustCrypto ECC impls. I'm working on a prototype networking protocol that needs ECDH. and RustCrypto doesn't support a few curves (p-521 and Brainpool) yet. It also doesnt have out-of-the-box support for static ECDH for implemented curves. So, I put this together.
Caveats:
With that in mind, here are the caveats
- This crate has NOT been tested (it only includes a few working examples)
- Performance was not a consideration - the arithmetic used in this crate is the textbook version of
Affine-Pointmath and relies on thenum_bigint_digcrate. Although, preliminary testing seems to indicate that its (actually) good. My assumption isnum_bigint_digis the cause but cannot confirm. - It is a
no_std libbut its not dynamic-memory allocation free as num_bigint_dig relies onalloc. Side-channelattacks have not been considered no attention has been paid to things likeconstant time equalityoperations.- This crate borrows some of its types from RustCrypto's elliptic-curve library so as to build a uniform api and make it easy to integrate
rustcrypto-eccfor when it adds support for other curves. - This crate includes curves that are not yet supported (or fully supported) by the RustCrypto project. List of supported curves -
- p256 - This is the 1 impl in this crate that you could probably use in a production environment as it was
lifted(in an as-is from) from a pretty well-tested crate -rust-hpke, which in-turn uses RustCrypto's p256 crate as its base crate. - P384 - Implemented with
Affine-Pointmath and a few additional types from RustoCrypto library. - P521 - support to be added (the impl will be similar to P384)
- Brainpool - supported to be added (the impl will be pretty similar to P384)
- p256 - This is the 1 impl in this crate that you could probably use in a production environment as it was