summaryrefslogtreecommitdiffstats
path: root/openpgp/src
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-14openpgp: Avoid leaking secrets when parsing secret key material.Justus Winter
2023-03-14openpgp: Avoid leaking secrets when constructing ProtectedMPIs.Justus Winter
2023-03-14openpgp: Avoid a heap allocation during MPI parsing.Justus Winter
- Not only was the heap allocation superfluous, it also leaked secrets into the heap.
2023-03-14openpgp: Simplify trimming of leading zeros.Justus Winter
2023-03-13openpgp: New constructor hex::Dumper::with_offset.Justus Winter
2023-03-13openpgp: Fix dumping fields ending on a 16 byte boundary.Justus Winter
2023-03-13openpgp: Fix test.Justus Winter
- Previously, NotAsFarAsWeKnow was interpreted as identifier making the if let binding irrefutable. - Fixes 7afee60b7cf0f19559bfccd8c42fdc77f6b9c655.
2023-03-08openpgp: Add a new backend based on the Botan cryptographic library.Justus Winter
2023-03-07openpgp: Protect SecretKeyMaterial during memory encryption.Justus Winter
2023-03-07openpgp: Prevent leaking secrets accessing encrypted memory.Justus Winter
- Track the length of the plaintext data. This makes it possible to use unchunked AEAD and decrypt the data without copying it into a growing vector. Also, avoid io::copy, as this leaks secrets into its buffer.
2023-03-07openpgp: Fix secret leaking into the heap moving it into Protected.Justus Winter
2023-03-07openpgp: Prevent secrets from leaking into the BufferedReader stack.Justus Winter
- When parsing secrets using the BufferedReader protocol, they may leak into buffers of the readers in the BufferedReader stack. This is is most problematic when parsing SecretKeyMaterial. - Deprecate SecretKeyMaterial::parse* in favor of variants that operate on bytes. Then, we can use the memory-backed BufferedReader which does not introduce additional buffering (and neither does the Dub reader used in the PackedHeaderParser).
2023-03-07openpgp: New constructor to allocate protected memory.Justus Winter
2023-03-06openpgp: Eagerly erase type in the PacketHeaderParser.Justus Winter
- The PacketHeaderParser returns erased BufferedReaders anyway, so we might as well do it early. This avoids any accidental specialization and hence code duplication.
2023-03-06openpgp: Dedup ComponentBundle::binding_signature.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: Add high-level encryption and signing roundtrip tests.Justus Winter
2023-03-01openpgp: Fix crash in the CNG backend.Justus Winter
2023-03-01openpgp: Add low-level ElGamal PKESK decryption test.Justus Winter
2023-03-01openpgp: Fix documentation.Justus Winter
2023-03-01openpgp: Don't assert that ElGamal is not supported in test.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-27openpgp: Fix logging data written to the hash dumper.Justus Winter
2023-02-27openpgp: Securely erase partially decrypted memory before crashing.Justus Winter
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-23openpgp: Add compile-time switch to disable memory encryption.Justus Winter
- This is useful for debugging, fuzzing, andn benchmarking.
2023-02-17openpgp: Add streaming decryptor tests using passwords.Justus Winter
2023-02-16openpgp: Fix salt generation in impl Arbitrary for S2K.Justus Winter
2023-02-16openpgp: Enable test.Justus Winter
- The OpenSSL backend supports OCB, so we should test it!
2023-02-16openpgp: Fix documentation.Justus Winter
2023-02-15openpgp: Don't check subpacket area length when parsing.Justus Winter
- Previously, we checked that the subpacket area fits a v4 signature when parsing. However, the subpacket area size depends on the packet version, and our SubpacketArea is independent of the signature version. - The size will be checked when serializing the signatures. It is not useful to check them when parsing the signatures.
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-02-10openpgp: Optimize writing KeyIDs using Formatter API.Wiktor Kwapisiewicz
2023-02-10openpgp: Optimize writing Fingerprints using Formatter API.Wiktor Kwapisiewicz
2023-02-04openpgp: Fix typo.Heiko Schaefer
Reported by: kpcyrd.
2023-02-02openpgp: Handle an unexpected EOF in `RawCertParser::next` betterNeal H. Walfield
- When `RawCertParser::next` encounters EOF while reading the packet body, stop processing the input.
2023-02-01openpgp: Avoid creating a Buffered reader when parsing packets.Neal H. Walfield
- For each packet type, add a private function `from_buffered_reader`. - Implement `Parse::from_reader` and `Parse::from_bytes` in terms of `from_buffered_reader`. For `Parse::from_bytes`, this means that we can wrap the input in a `buffered_reader::Memory`, which is much faster than a `buffered_reader::Generic`, which we use now. - Note: `PacketParserBuilder` and by extension `Cert` already implement this optimimzation.
2023-01-23buffered-reader, openpgp: Fix overflow calculating buffer capacitiesJustus Winter
- Fixes #3e188fb312ad4db1395f5e836bffaf2034b88a42.
2023-01-19openpgp: Improve tracing.Justus Winter
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.
2023-01-06openpgp: Add convenient accessor functions to RawCert.Neal H. Walfield
- The main reason to use a `RawCertParser` is to avoid having to parse certificates that are definitely not needed in the current context. - Add some convenient accessor functions to `RawCert`: `RawCert::primary_key`, `RawCert::keys`, `RawCert::subkeys`, and `RawCert::UserID` to make this easier.
2023-01-06openpgp: Split certificates without parsing the packets.Neal H. Walfield
- Add `RawCertParser`, which splits keyrings into individual certificates, similar to `CertParser`, but without invoking the heavy machinery of the `CertParser`. - `RawCertParser` uses the OpenPGP framing information to identify the packets, and it makes sure that the packets form a valid TPK or TSK as per Sections 11.1 and 11.2 of RFC 4880, respectively.
2023-01-06openpgp: When a packet source returns an error, don't assume EOF.Neal H. Walfield
- When a packet source returns an error to `CertParser::next`, don't assume that that means EOF. Subsequent calls may still return packets.
2023-01-06openpgp: Don't wait for EOF to return a queued error.Neal H. Walfield
- When `CertParser::next` is called and there is a queued error, return it immediately; don't wait for an EOF.
2023-01-06openpgp: Better handle multiple errors.Neal H. Walfield
- When `CertParser::next` encounters an error reading the next packet, and then encounters an error creating the queued certificate, queue the second error, and return the first one.
2023-01-06openpgp: Fix PacketParser to return the packet preceding any junk.Neal H. Walfield
- If the `PacketParser` encounters junk (i.e., corruption) and is able to find a valid packet within `RECOVERY_THRESHOLD` bytes of the end of the last valid packet, it recovers by converting the junk to an `Unknown` packet, and continuing to parse. - Extend this recovery mechanism to junk at the end of the file. If the `PacketParser` encounters up to `RECOVERY_THRESHOLD` bytes of junk at the end of the file, convert that data into an `Unknown` packet instead of immediately returning an error. - By returning an `Unknown` packet instead of an error, we also return the last buffered packet, which was otherwise lost. - When converting `RECOVERY_THRESHOLD` bytes of junk into an `Unknown` packet, queue an error (in `PacketParserState`) so that the next call to `PacketParser::next` will not continue trying to parse the input, but return an unrecoverable error. - Fixes #967.