summaryrefslogtreecommitdiffstats
path: root/openpgp/src/crypto/mod.rs
AgeCommit message (Collapse)Author
2021-10-14Allow clippy::unnecessary_lazy_evaluationsLars Wirzenius
Replacing the closure with just the value it returns would be simpler, but it would result in more computation happening at runtime if the result is Ok. See https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_lazy_evaluations This clippy warning wasn't caught by CI, because we don't yet have clippy in CI.
2021-09-30Use match for tri-state conditionLars Wirzenius
A chain of if statements is not guaranteed to test every possible case, the way match does. Thus it seems better to use match here, when there are three possible results from a comparison. Found by clippy lint comparison_chain: https://rust-lang.github.io/rust-clippy/master/index.html#comparison_chain
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-28openpgp: Add methods for padding and truncating MPI values.Justus Winter
- Cryptographic values are often expected to have a certain size. Handling this is repetitive and error prone. - This is especially problematic because MPI-encoding strips leading zero bytes. Introduce two methods for that purpose. - Fixes #759.
2021-09-28openpgp: Add two functions for padding and truncating values.Justus Winter
- Cryptographic values are often expected to have a certain size. Handling this is repetitive and error prone. Introduce two functions for that purpose.
2021-09-28openpgp: Add ECDSA test vectors from FIPS 186-4.Justus Winter
2021-08-27ffi, openpgp: Cleanup links after cargo intraconv.Nora Widdecke
- openpgp: Make broken relative links absolute: - find -name "*.rs" -exec sed -i -E 's,^( *//[/!](.*): )((super::)+packet),\1crate::packet,' {} + - find -name "*.rs" -exec sed -i -E 's,^( *//[/!](.*): )((super::)+cert),\1crate::cert,' {} + - find -name "*.rs" -exec sed -i -E 's,^( *//[/!](.*): )((super::)+parse),\1crate::parse,' {} + - find -name "*.rs" -exec sed -i -E 's,^( *//[/!](.*): )((super::)+policy),\1crate::policy,' {} + - find -name "*.rs" -exec sed -i -E 's,^( *//[/!](.*): )((super::)+serialize),\1crate::serialize,' {} + - find -name "*.rs" -exec sed -i -E 's,^( *//[/!](.*): )((super::)+armor),\1crate::armor,' {} + - find -name "*.rs" -exec sed -i -E 's,^( *//[/!](.*): )((super::)+types),\1crate::types,' {} + - find -name "*.rs" -exec sed -i -E 's,^( *//[/!] *(\[`PacketPile`\]):).*$,\1 crate::PacketPile,' {} + - openpgp: Link to PacketParser and Policy structs, not the modules. - ffi: Make links to sequoia_openpgp and sequoia_net absolute - find -name "*.rs" -exec sed -i -E 's,^( *//[/!](.*): )((super::)+sequoia_openpgp),\1sequoia_openpgp,' {} + - find -name "*.rs" -exec sed -i -E 's,^( *//[/!](.*): )((super::)+sequoia_net),\1sequoia_net,' {} +
2021-08-27Convert markdown to intra-doc links.Nora Widdecke
- Apply cargo intraconv.
2020-12-08openpgp: Use parens for assert_send_and_sync!.Azul
2020-12-08openpgp: Ensure public types are Send and Sync.Azul
- See #627.
2020-08-17openpgp: Move crypto::Keygrip to the ipc crate.Justus Winter
2020-08-17openpgp: Move crypto::sexp to the ipc crate.Justus Winter
- This is only used to communicate with the GnuPG agent, so it should not be in the openpgp crate.
2020-08-17openpgp: Make crypto::ecdh::decrypt_shared public.Justus Winter
- This will be used by all the implementations of crypto::Decryptor, and if we don't want them to end up in the openpgp crate, we need to make it public.
2020-08-13openpgp: Add examples for Password.Justus Winter
- See #474.
2020-08-11openpgp: Move hash_buffered_reader, drop hash_reader.Justus Winter
- Previously, we provided hash_reader to downstream users to verify detached signatures. Nowadays, we have the DetachedVerifier that does the same in a much more convenient way. Therefore, we drop hash_reader, and move its non-public sibling hash_buffered_reader to a more appropriate location.
2020-08-10openpgp: Correctly handle text signatures when verifying.Justus Winter
- Text signatures require normalizing the line endings to "\r\n" before the text is hashed. This change implements this for the consumption of signatures. The next commit will handle the production of such signatures. - See #530.
2020-08-04openpgp: Improve documentation.Justus Winter
- See #474.
2020-08-04openpgp: Improve documentation of mod asymmetric.Justus Winter
- See #474.
2020-07-31openpgp: Improve the introduction of module crypto.Justus Winter
- See #474.
2020-07-31openpgp: Improve documentation of crypto::Password.Justus Winter
- See #474.
2020-07-31openpgp: Improve documentation of crypto::SessionKey.Justus Winter
- See #474.
2020-06-22openpgp: Move random generation to Nettle backendIgor Matuszewski
2020-06-22openpgp: Introduce crypto::backend facade moduleIgor Matuszewski
2020-04-08openpgp: Move around some crypto pub re-exportsIgor Matuszewski
To keep it consistent with other re-exports and to easier see at a glance what is re-exported from the module.
2020-04-08openpgp: Rename crypto::mpis to crypto::mpiIgor Matuszewski
To be consistent; we don't use plural forms for modules anywhere else and Rust always uses singular forms.
2020-03-25openpgp: Provide crypto::hash_buffered_reader.Justus Winter
2020-03-09openpgp: Update nettle to 7.0.0.Justus Winter
2020-02-24openpgp: De-optimize crypto::random.Justus Winter
- Previously, we used a thread-local cache of the Yarrow CPRNG state. However, without fork(2)-detection this is not safe. For now, just initialize a fresh one on every invocation.
2020-01-03openpgp: Rename hash_file to hash_reader, improve documentation.Justus Winter
2020-01-03openpgp: Simplify SignatureGroup::hashes.Justus Winter
- The hash context knows the algorithm now.
2020-01-03openpgp: Simplify crypto::hash_file.Justus Winter
- The context knows the algorithm now.
2020-01-03openpgp: Move crypto::s2k::S2K to crypto.Justus Winter
- The module contains only one exported item.
2020-01-03openpgp: Make Protected::into_vec private, remove from SessionKey.Justus Winter
2019-12-19openpgp: Encrypt passwords in memory.Justus Winter
2019-12-19openpgp: Make crypto::mem public and improve the documentation.Justus Winter
2019-12-19openpgp: Prepare to encrypt passwords.Justus Winter
- Remove direct access, provide Password::map instead.
2019-12-03openpgp: Rename openpgp::conversions to openpgp::fmt.Justus Winter
2019-11-25openpgp: Rename openpgp::constants to openpgp::types.Justus Winter
- Fixes #381.
2019-11-07openpgp: Use a Vec instead of a HashMap.Neal H. Walfield
- A SignatureGroup currently contains a hash mapping hash algorithms to hash contexts. Typically this will only contain one or two mappings. At most it will contain one mapping for each algorithm that we support (currently, we support 7 hash algorithms). - Given the small expected and small maximum size, a vector is the better data structure: - The small number of elements means that look up time will be comparable whether we do a linear scan or look in a hash (in fact, the linear scan is probably cache friendlier). - Iterating over a vector is faster than iterating over a hash map. The is the fast path. - A vector takes up less space. - Change SignatureGroup::hashes to use a Vec instead of a HashMap.
2019-07-15openpgp: Implement AsMut<[u8]> for SessionKey.Justus Winter
2019-07-15Prepare for Rust 2018.Justus Winter
- This is the result of running `cargo fix --edition`, with some manual adjustments. - The vast majority of changes merely qualify module paths with 'crate::'. - Two instances of adding an anonymous pattern to a trait's function. - `async` is a keyword in Rust 2018, and hence it needs to be escaped (e.g. in the case of the net::r#async module). - The manual adjustments were needed due to various shortcomings of the analysis employed by `cargo fix`, e.g. unexpanded macros, procedural macros, lalrpop grammars.
2019-07-02openpgp: New function crypto::random.Justus Winter
- Add and use a function that fills a buffer with a thread-local random number generator.
2019-07-02openpgp: Simplify SessionKey::new.Justus Winter
2019-07-02openpgp: Introduce an abstraction for hash contexts.Justus Winter
- See #302.
2019-07-02openpgp: Make the crypto::hash module public, remove re-export.Justus Winter
2019-06-27openpgp: Refactor memory protection.Justus Winter
- Create a new module for memory protection. Move common code from `Password` and `SessionKey` to a new type `Protected`.
2019-06-24openpgp: Add a function to convert SessionKeys back to Vec<u8>.Justus Winter
2019-06-06openpgp: New type representing s-expressions.Justus Winter
- *S-Expressions* as described in the internet draft [S-Expressions], are a way to communicate cryptographic primitives like keys, signatures, and ciphertexts between agents or implementations. [S-Expressions]: https://people.csail.mit.edu/rivest/Sexp.txt
2019-05-30openpgp: New trait crypto::Decryptor.Justus Winter
2019-05-14openpgp: Add a filesystem-like framework for test data.Justus Winter
- Fixes #267.