Crates.io | libes |
lib.rs | libes |
version | 0.9.1 |
source | src |
created_at | 2022-10-24 22:29:15.766374 |
updated_at | 2023-04-09 06:39:31.004134 |
description | Collection of Elliptic Curve Integrated Encryption Scheme(s) |
homepage | https://github.com/TJRoh01/libes |
repository | https://github.com/TJRoh01/libes |
max_upload_size | |
id | 696330 |
size | 133,028 |
library of encryption scheme(s) is a collection of ECIES variants.
The goal of this is library is to become a one-stop shop for everything ECIES.
For code documentation, usage explanations, and examples please see Docs.rs.
During beta development, versions 0.2+.Z, backwards compatibility for decryption is guaranteed.
This means that data encrypted using library version X.Y.Z can be decrypted using any superseding library version as long as X is the same, even if the algorithm used for encryption was yanked it will still be available for decryption until X is incremented.
The public API structure will not change, but algorithms that are potentially found to be broken for any reason will be immediately removed and the library will be released with an incremented Y in X.Y.Z, and versions implementing that algorithm will be yanked.
The private API is still under development, so make sure that you always use the latest version 0.Y.Z to receive all patches that are released. An incremented Z in X.Y.Z will not require any modifications in your code, of course with the exception for an algorithm being yanked.
The rust cryptography ecosystem is swarming with crates, with varying degrees of quality and documentation. I have taken it onto myself to navigate this, and I want to share my findings with those who are trying to make sense of it like me.
In doing this I commit myself to:
TBD
ECIES stands for Elliptic Curve Integrated Encryption Scheme. It is a type of cryptographic procedure which allows encrypting data for a specific recipient given only the data to be encrypted and the recipients public key, everything else is derived from the input or generated using a CSPRNG (Cryptographically Secure Pseudo-Random Number Generator).
Wikipedia
Crypto++
Practical Cryptography for Developers
Cryptographic algorithms have evolved over time, and thus have grown into two distinct ECIES variants as of writing.
Originally, ECIES relied on a key exchange operation, an encryption operation, and a separate MAC operation.
A MAC (Message Authentication Code) is necessary to provide Authenticity on top of Confidentiality. By exploiting vulnerabilities and/or compromised parameters, encrypted data could potentially be manipulated to produce a desired output, other than what the sender intended. A MAC can be used separately from the encrypted data to verify that such manipulation did not take place.
More recently adopted encryption algorithms like AES256-GCM and ChaCha20-Poly1305 are AEAD (Authenticated Encryption with Additional Data) algorithms which in addition to a ciphertext, also produce an Authentication Tag which serves the same purpose that a MAC does in this case, but is integrated in the encryption algorithm itself.
The library and documentation will refer to these two variants as:
Iterating further on ECIES-AEAD, it could be further integrated by synthesizing the IV/Nonce rather than generating it randomly. This would eliminate the need to store & transmit the IV/Nonce, as well as reduce the overhead by one or two dozen bytes. Because there is already random data in the ephemeral key, the risk of deriving the same IV/Nonce twice is about equivalent with generating it randomly, and thus it should be safe to do so. This third variant will be referred to as ECIES-SYN.
DISCLAIMER: ECIES-SYN has not received a security audit! ECIES-SYN is my own idea, which I will only implement for algorithms that I have done extensive research on to ensure that it is cryptographically secure to do so. Regardless, I am not a cryptography researcher and I can not give a guarantee that issues will not arise in the future. If ECIES-SYN turns out to be useful/popular and resources allow, I will make sure that it receives a security audit.
See the README.md on GitHub.
See the README.md on GitHub.
See the README.md on GitHub.
This library respects SemVer, and guarantees decryption backwards compatibility.
This means that data encrypted using library version X.Y.Z can be decrypted using any superseding library version as long as X is the same.
For example, data encrypted using version 0.5.7 can be decrypted using version 0.5.7 or 0.11.1, but not using versions 1.2.3, 0.5.6, or 0.4.10.
Effort will be made to keep X, the major version, decryption backwards compatible as well, but no guarantee is given.
All algorithm combinations are gated behind features, to reduce how much is being compiled. Features are named exactly like the algorithm names in the support matrices (if there are alternative names like P-521 and secp521r1 then they are aliases, so you can enable either). This library uses traits to implement appropriate functionality on valid user-defined variants.
NOTE: No ECIES variants are available without activating any features, at minimum one of each feature categories must be activated:
NOTE: For a ECIES combination to be valid the Elliptic Curve, Encryption, and Authentication algorithms must all support the same ECIES variant.
Matrix entries are of form Encryption & Decryption
or Encryption
/Decryption
Algorithm/ECIES Variant | ECIES-MAC | ECIES-AEAD | ECIES-SYN |
---|---|---|---|
x25519 | 🚀 | 🚀 | 🚀 |
ed25519 | 🚀 | 🚀 | 🚀 |
K-256 / secp256k1 | 🚀 | 🚀 | 🚀 |
P-256 / secp256r1 | 🚀 | 🚀 | 🚀 |
P-384 / secp384r1 | 🚀 | 🚀 | 🚀 |
P-521 / secp521r1 | 🤔 | 🤔 | 🤔 |
Algorithm/ECIES Variant | ECIES-MAC | ECIES-AEAD | ECIES-SYN |
---|---|---|---|
ChaCha20-Poly1305 | 🚀 | 🚀 | 🚀 |
XChaCha20-Poly1305 | 🚀 | 🚀 | 🚀 |
AES128-GCM | 🚫1 | 🚫1 | 🚫1 |
AES256-GCM | 🚀 | 🚀 | 🚀 |
Algorithm/ECIES Variant | ECIES-MAC |
---|---|
HMAC-SHA256 | 🚀 |
HMAC-SHA512 | 🤔 |
Licensed under either of:
at your option.
All contributions are very appreciated.
For all other issues, please try to include enough information so that it is possible to determine what to do or plan without having to ask too many follow-up questions.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this project by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
AES128-GCM uses a 128-bit key and a 96-bit nonce, and when using a CSPRNG as the de-facto source to generate them, the collision risk in a 224-bit space is unsatisfactory. Due to this encryption is not implemented, along with decryption in order to not encourage using this variant in other libraries. Note: like AES128-GCM, AES256-GCM and some other encryption algorithms in this library also use a 96-bit nonce, but unlike AES256-GCM they have larger keys like 256 bits, which when combined with a 96-bit nonce makes the collision risk acceptable. ↩ ↩2 ↩3