summaryrefslogtreecommitdiffstats
path: root/openpgp/src/cert/parser/mod.rs
AgeCommit message (Collapse)Author
2022-11-18openpgp: Improve tests with marker packets.Justus Winter
2022-11-18openpgp: Ignore marker packets when validating cert streams.Justus Winter
- While we correctly ignored marker packets in the CertParser, we did not ignore them in the CertValidator. This made sq inspect complain about marker packets in certrings.
2022-06-08openpgp: New error condition, UnsupportedCert2.Justus Winter
- In contrast to UnsupportedCert, this variant carries all the packets that we failed to parse into a cert. Notably, this includes primary keys that we don't understand. Keeping the packets with the errors allows us to at least roundtrip the packets.
2022-05-12openpgp: Improve tracing.Justus Winter
2021-12-03openpgp: Derive Default.Nora Widdecke
- Replace manual implementations of Default where the derive(Default) is identical. - Suggested by clippy, https://rust-lang.github.io/rust-clippy/master/index.html#derivable_impl
2021-11-29openpgp: Use functional update syntax.Nora Widdecke
- Instead of creating a default struct and immediately afterwards changing a field, use this type of initialization syntax: Struct { field: value, ..Default::default() }. - Suggested by clippy::field_reassign_with_default.
2021-09-30Tell clippy it's OK not to implement traitsLars Wirzenius
Certain method names are typically provided by traits, and it can be confusing to readers when a method uses that name without the type implementing the trait. Mark the cases we have to tell clippy these cases are OK. Implementing the corresponding traits would have changed API so I opted not to do that. Found by clippy lint new_without_default: https://rust-lang.github.io/rust-clippy/master/index.html#new_without_default
2021-09-30Join nested if statements with logical and into one statementLars Wirzenius
Instead of this: if foo { if bar { ... } } do this: if foo && bar { ... } Nesting statements implies a more complicated code structure than it really is. Thus it's arguably simpler to write a combined condition by joining the two conditions with a logical and operation. Found by clippy lint collapsible_if: https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
2021-09-30Use std::mem::take instead of std::mem::replace, for clarityLars Wirzenius
Replace let bar = std::mem::replace(&foo, Default::Default()); with let bar = std::mem::take(&foo); The new version seems a little clearer. Found by clippy: https://rust-lang.github.io/rust-clippy/master/index.html#mem_replace_with_default Sponsored-by: author
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.
2021-07-09openpgp: Fix CertParser::reset.Nora Widdecke
Preserve the filters through CertParser::reset.
2021-05-20openpgp: Fix CertParser to return errors in the right order.Neal H. Walfield
- Consider a keyring of the form: `[ Alice, NUL, Bob ]`. The CertParser should return `[ Ok(Alice), Err(SomeError), Ok(Bob) ]`. Currently, we get `[ Err(SomeError), Ok(Alice), Ok(Bob) ]`, because the error is returned eagerly. - Fix it. - Fixes #699.
2021-04-09Lint: Use next instead of nth(0).Nora Widdecke
- https://rust-lang.github.io/rust-clippy/master/index.html#iter_nth_zero
2021-04-09Lint: Use is_empty().Nora Widdecke
- https://rust-lang.github.io/rust-clippy/master/index.html#len_zero - https://rust-lang.github.io/rust-clippy/master/index.html#comparison_to_empty
2021-04-09Lint: Use matches! macro.Nora Widdecke
- https://rust-lang.github.io/rust-clippy/master/index.html#match_like_matches_macro
2021-04-09Lint: Remove unnecessary conversions.Nora Widdecke
- https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion
2021-04-09Lint: Use lazy evaluation.Nora Widdecke
- https://rust-lang.github.io/rust-clippy/master/index.html#or_fun_call
2020-12-22openpgp: Improve debugging output.Neal H. Walfield
2020-12-11openpgp: Standardize fn main() in doctests.Azul
- Avoid the additional `fn f()`.
2020-12-11openpgp: Replace `.unwrap()` in doctests with `?`Azul
- See #480.
2020-12-11openpgp: Make Cert::CertParser Send and Sync.Azul
- See #615.
2020-12-10buffered-reader: Require Cookies to be Send and Sync.Azul
- This way the entire `BufferedReader<C>` will be `Send` and `Sync`. - Modify all other crates accordingly. - See #615.
2020-10-26openpgp: Refactor some matches for legibilityIgor Matuszewski
2020-10-26openpgp: Use std::matches! instead of custom destructures_to macroIgor Matuszewski
2020-10-20openpgp: Support reading certificates from multiple armor blocks.Justus Winter
- Fixes #256.
2020-10-19openpgp: Fix documentation.Justus Winter
2020-10-14Use 'Examples' for the examples section.Justus Winter
- See #480.
2020-10-05openpgp: Avoid allocating backing arrays.Justus Winter
- Three of the five vectors will never contain any values.
2020-05-13openpgp: Improve documentation for cert::CertParserNeal H. Walfield
- See #466.
2020-05-13openpgp: Add conversions for CertParserNeal H. Walfield
- Implement `From<Vec<Result<Packet>>>` and `From<Vec<Packet>>` for `CertParser`.
2020-05-12openpgp: Add a unit test for CertParserNeal H. Walfield
- Add a unit test that checks that `CertParser` correctly handles invalid and out of place packets.
2020-05-12openpgp: Stop parsing a Cert when we encounter an invalid packetNeal H. Walfield
- When parsing a certificate in `Cert::parse`, stop when we encounter an invalid packet. - Stop if the first packet is not a valid start of a certificate. - Stop if the packet is not valid for a certificate. - Change `Cert::merge_packets` to check for invalid packets. - If we have a valid certificate followed by an invalid packet, then `Cert::parse` will not immediately return an error, but return the valid certificate. Only if the caller asks for a second certificate will it return an error.
2020-05-12openpgp: Don't enable tracing by defaultNeal H. Walfield
- This slipped in in 6550051e23704d7e6c47e8553e55f0653b14c8cc.
2020-05-08openpgp: Improve tracing in openpgp::cert::parser.Neal H. Walfield
2020-05-08openpgp: Make CertParser::from_iter more generic.Neal H. Walfield
- Instead of taking an iterator over `Result<Packet>`, take an `Into<Result<Packet>>>`.
2020-05-08openpgp: Don't make CertParser generic over the iterator's typeNeal H. Walfield
- Fix `CertParser::iter`'s type to be a `Box<'a + Iterator<Item=Result<Packet>>>` rather than trying to be generic.
2020-05-08openpgp: Replace PacketSource with an OptionNeal H. Walfield
- Having removed the `PacketSource::PacketParser` variant, the `PacketSource` enum is basically an `Option`. So, just turn it into one.
2020-05-08openpgp: Remove the PacketSource::PacketParser variant.Neal H. Walfield
- Now that `PacktSource::Iter` returns a `Result<Packet>` instead of a `Packet`, we can implement `PacketSource::PacketParser` in terms of `PacktSource::Iter`.
2020-05-08openpgp: Change CertParser to take a fallible iteratorNeal H. Walfield
- Change `CertParser` to take a fallible iterator. - This change allows the iterator to propagate parse errors as such. Otherwise, parse errors are indistinguishable from EOF.
2020-05-05openpgp: Change split_sigs' visability.Neal H. Walfield
2020-05-05openpgp: Don't export internal data structures.Neal H. Walfield
- Don't export CertValidity, KeyringValidator, KeyringValidity, or MessageValidity. - Fixes #490.
2020-05-05openpgp: Fix spelling of keyring.Neal H. Walfield
- Keyring is spelt keyring, not key ring. - Cf. https://tools.ietf.org/html/rfc4880#section-3.6
2020-04-29openpgp: Reduce visibility of CertValidator.Wiktor Kwapisiewicz
- Make CertValidator `pub(crate)` instead of `pub`. - Remove unused methods. - Mark `push_token` as `#[cfg(test)]` as it is used only in tests.
2020-04-16Revert "openpgp: Make PacketParserResult a std::result::Result."Justus Winter
This reverts commit 2e1eec5fe4157a391a13554ff7df3075cfe043cc.
2020-04-09openpgp: Make PacketParserResult a std::result::Result.Justus Winter
- This avoids the partial implementation imitating std::option::Option, replacing it with std::result::Result. - As a benefit, std::result::Result is in the prelude, simplifying a lot of parsing loops.
2020-04-03openpgp: Convert `CertParser::from_packet_parser` to `From<PacketParserResult>`Wiktor Kwapisiewicz
2020-04-02openpgp: Rename cert::components to cert::bundle.Neal H. Walfield
- `cert::components` is about `ComponentBundle`s, not `Component`s.
2020-04-02openpgp: Drop KeyID::from_hex in favor of FromStr.Justus Winter
- See #462.
2020-03-09Switch from failure to anyhow.Justus Winter
- Use the anyhow crate instead of failure to implement the dynamic side of our error handling. anyhow::Error derefs to dyn std::error::Error, allowing better interoperability with other stdlib-based error handling libraries. - Fixes #444.