summaryrefslogtreecommitdiffstats
path: root/openpgp/src/crypto/backend
AgeCommit message (Collapse)Author
2023-03-14openpgp: Immediately create ProtectedMPIs for secrets.Justus Winter
- Avoid creating an MPI first, as this may leak the secrets.
2023-03-08openpgp: Add a new backend based on the Botan cryptographic library.Justus Winter
2023-03-02openpgp: Combine ciphertext and tag in Aead::decrypt_verify.Justus Winter
- It is easier (and cheaper) to tear apart in backends that need ciphertext and tag to be separate than to combine it for backends that expect the tag to be appended to the ciphertext. - The caller doesn't have to do anything, because in OpenPGP on the wire the tag is already appended to the ciphertext. The one exception is our current implementation of SKESKv5, but in our upcoming SKESKv6 implementation, we store the tag appended to the ciphertext, so it will be easy to use this interface there.
2023-03-01openpgp: Add support for brainpoolP384r1.Justus Winter
- One of the brainpool curves was not included in our enum Curve, because at the time we implemented ECC support, it wasn't part of the RFC4880bis document. - Unfortunately, we failed to mark enum Curve as non-exhaustive, so we cannot add a variant without breaking the API. - We can, however, support the curve by matching on its OID.
2023-03-01openpgp: Fix crash in the CNG backend.Justus Winter
2023-02-28openpgp: Stop secrets leaking into the heap during key generation.Justus Winter
2023-02-28openpgp: Further simplify AEAD abstraction.Justus Winter
- Hand in the additional authenticated data when constructing the context.
2023-02-27openpgp: Rework the AEAD abstraction.Justus Winter
- Combine `encrypt` and `tag` to `encrypt_seal` similarly to we previously combined `decrypt_verify`. This better matches AEAD constructions, and the original interface was mostly informed by Nettle's relatively low-level interface.
2023-02-23openpgp: Fix nonce size when using OCB with OpenSSL.Justus Winter
- Previously, the IV length defaulted to 12. - We have to set the IV length before supplying the IV in {de,en}crypt_init. Otherwise, it will be silently truncated.
2023-02-14openpgp: Fix hash algorithm detection.Wiktor Kwapisiewicz
- Hash algorithm detection previously checked only conversion to Nid. - More thorough check which involves construction of the Hasher object is needed. - Adjust the code and add a comment. - Fixes https://gitlab.com/sequoia-pgp/sequoia/-/issues/979
2023-01-19Fix EC curve detection.Wiktor Kwapisiewicz
- Some systems have smaller set of supported curves and even though the curve identifiers are compiled in the usage of the curve fails. - Try to construct an `EcGroup` using retrieved `Nid` as this is a cheap check that will fail if the curve is truly unsupported. - Fixes #976.
2022-12-22openpgp: Add OpenSSL cryptographic backend.Wiktor Kwapisiewicz
- Adds the backend behind `crypto-openssl` feature. - Add CI configuration to run tests with the new backend. - See #333.
2022-12-21openpgp: Check for supported AEAD ciphersuite in tests.Wiktor Kwapisiewicz
- Previously the AEAD roundtrip test checked supported symmetric ciphers and AEAD algorithms separately but only certain combinations of them are valid in some libraries. - See: https://openpgp-wg.gitlab.io/rfc4880bis/#name-preferred-aead-ciphersuites
2022-12-21openpgp: Make AEAD interface functions fallible.Wiktor Kwapisiewicz
- Some backends may want to propagate their internal errors to the caller. - Modify all functions to return Results and their clients to either propagate the error or handle it.
2022-12-21openpgp: Change `decrypt` into `decrypt_verify`.Wiktor Kwapisiewicz
- Some backends want to verify the AEAD block by themselves and need the tag to be passed in. - Change two step `decrypt` + `digest` into a one step `decrypt_verify`. - Old backends are modified to work like they did previously by utilizing decryption and the digest operation. - New backends can implement `decrypt_verify` using their respective cryptographic primitives.
2022-08-16openpgp: Expose `HashAlgorithm::oid()` on all crypto backends.Wiktor Kwapisiewicz
- Expose `oid()` function for all cryptographic backends. - Fix the description to accurately describe the bytes that are being returned. - Add the reference and note to the common use of this function. - Add practical example of computing the entire `DigestInfo` structure. - Add mention of the change to the NEWS file. - Add test case to check if the values match what Nettle is using. - Fixes #919.
2022-08-15openpgp: Avoid hardcoding EAX for memory encryption.Justus Winter
- Previously, we used EAX for memory encryption because it was supported by all cryptographic backends. However, this is problematic for OpenSSL, which doesn't support EAX. - Instead, have the backends provide a default algorithm to use that they support.
2022-05-11openpgp: Add crypto::backend that identifies the backend.Justus Winter
- This returns a short, human-readable description of the cryptographic backend for use in version strings to improve bug reports. - Fixes #818.
2022-05-11openpgp: Add explicit forwarder for crypto::random.Justus Winter
- This harmonizes the docstring across the different backends. Also, it avoids monomorphization of the backend functions.
2022-05-05openpgp: Fix ECDH parameter selection on generation and import.Justus Winter
- Select an appropriate hash algorithm for the ECDH KDF and an appropriate cipher for the ECDH KEK depending on the curve. Harmonize that for import and generation. - Fixes #841.
2022-02-15openpgp: Fallible conversion to GenericArray references.Justus Winter
- The former commit fixes a crash that should never have happened: with a fallible conversion to GenericArrays, the error can be handled at runtime. - Unfortunately, the upstream crate does not offer a convenient fallible conversion. Implement and use it.
2022-02-15openpgp: Fix crash converting nonce slices to arrays.Justus Winter
- Doing the conversion before matching on the algorithm tries to convert nonces of different sizes to an array suitable for EAX, leading to a panic.
2021-12-13openpgp: Ensure rand:0.7 for rust-crypto.Nora Widdecke
- ed25519-dalek requires rand:0.7 types, so make sure they are used, and not the ones form rand:0.8.
2021-12-02openpgp: Use unused-must-use.Nora Widdecke
- Rustc 1.57.0 complains that the returned Protected value is never used. let _ = Protected::from(Sy); Does the trick while keeping the original intention.
2021-11-29openpgp: Clearly return the Error.Nora Widdecke
- It's clearer to cast the error with .into() insead of ?. - Found by clippy::try_err.
2021-11-29Remove needless borrows.Nora Widdecke
- Found by clippy::needless_borrow.
2021-11-29Allow many single character names.Nora Widdecke
- The RSA parameters have single character names, this is fine. - Clippy lint: clippy::many_single_char_names.
2021-11-29Remove unnecessary conversions.Nora Widdecke
- Found with clippy::useless_conversion.
2021-11-29Remove unnecessary borrows.Nora Widdecke
- Fixed with the help of clippy::needless_borrow.
2021-11-25openpgp: Remove unnecessary references.Nora Widdecke
2021-11-18openpgp: Use a WASM-friendly SystemTime::now wrapper.Justus Winter
- Fixes #769.
2021-10-05openpgp: Fix crash in the CNG backend.Justus Winter
2021-10-05openpgp: Implement ECDH and ECDSA over NistP256 with RustCrypto.Justus Winter
2021-10-05openpgp: Add a RustCrypto backend.Nikhil Benesch
- This adds a cryptographic backend based on the RustCrypto crates. The backend is marked as experimental, as the RustCrypto crates' authors state that they have not been audited and may not perform computations in constant time. Nevertheless, it may be useful in certain environments, e.g. WebAssembly. - The backend implements RSA, EdDSA and ECDH over Curve25519, IDEA, 3DES, CAST5, Blowfish, AES, Twofish, EAX, MD5, SHA1, RipeMD160, and the SHA2 family. - Notably missing are DSA, ElGamal, and ECDSA and ECDH over the NIST curves. - See #333.
2021-09-30openpgp: Use new padding methods in the CNG backend.Justus Winter
2021-09-30openpgp: Simplify code.Justus Winter
- r is a mem::Protected, no need to explicitly clean it up.
2021-09-30Allow short single-character argument and variable namesLars Wirzenius
Generally speaking, single-character names are not great for the person reading the code later. They don't usually act as a cognitive aid to understand the code. However, this in code implementing cryptographic operations that implements mathematical formulas that canonically use single-letter names it's clearer to use the same name in the code. Thus, I only tell clippy those names are OK in these cases. Found by clippy lint many_single_char_names: https://rust-lang.github.io/rust-clippy/master/index.html#many_single_char_names
2021-09-30Allow ::new to not return SelfLars Wirzenius
It is Rust custom that the new method for a type returns an instance of that type. However, sometimes that's not wanted. Tell clippy that these cases are OK. I opted to not do this globally, because that would prevent clippy from catching future cases. Found by clippy warning new_ret_no_self: https://rust-lang.github.io/rust-clippy/master/index.html#new_ret_no_self
2021-09-29openpgp: Pad the DSA public key to the size of the modulus.Justus Winter
- Works around a crash in the CNG bindings. - See https://github.com/emgre/win-crypto-ng/issues/39.
2021-09-29openpgp: Use new padding methods in the CNG backend.Justus Winter
- This makes the code more succinct and also more robust (consider for example that `field_sz - r.value().len()` may underflow.
2021-09-29openpgp: Avoid secret-dependent time difference.Justus Winter
- Using ProtectedMPI::value_padded avoids this cleanly. - Fixes #716.
2021-09-29openpgp: Use the new padding methods in the CNG backend.Justus Winter
2021-09-28openpgp: Use the new padding methods in the Nettle backend.Justus Winter
2021-09-21Avoid matching on &Foo, when a plain Foo pattern worksLars Wirzenius
The extra & in a pattern (match arm or if let) is unnecessary and only makes the code harder to read. In most places it's enough to just remove the & from the pattern, but in a few places a dereference (*) needs to be added where the value captured in the pattern is used, as removing the & changes the type of the captured value to be a reference. Overall, the changes are almost mechanical. Although the diff is huge, it should be easy to read. The clippy lint match_ref_pats warns about this. See: https://rust-lang.github.io/rust-clippy/master/index.html#match_ref_pats
2021-09-16openpgp: Make list of supported algorithms backend-dependent.Justus Winter
2021-09-16openpgp: Fix documentation.Justus Winter
2021-09-15openpgp: Avoid creating unused borrows.Justus Winter
2021-09-08openpgp: Don't assume that we only use Ed25519 for EdDSA.Justus Winter
2021-09-08openpgp: Avoid magic constant.Justus Winter
2021-09-08openpgp: Avoid catchall.Justus Winter