Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v6] Update packet versions to the latest crypto refresh #1630

Merged
merged 32 commits into from
Sep 4, 2023

Conversation

twiss
Copy link
Member

@twiss twiss commented Apr 3, 2023

Implement the new packet versions from draft-ietf-openpgp-crypto-refresh-08.

Fixes part of #1442; replaces #1505.

TODO:

  • update AEAD-encryption mechanism for private keys
  • cross-check with go-crypto
  • rebase on top of Ed25519 update to then add test vectors from RFC
  • add changes from Update to the latest version of the crypto refresh twiss/openpgpjs#3
  • add config to support v4 keys with legacy AEAD mode (from werner's draft) -- TODO in separate PR
  • properly squash commits

src/key/helper.js Outdated Show resolved Hide resolved
.eslintrc.js Outdated Show resolved Hide resolved
@larabr larabr changed the title Update packet versions to the latest crypto refresh [v6] Update packet versions to the latest crypto refresh Jul 7, 2023
@larabr larabr force-pushed the v6 branch 2 times, most recently from d0748a0 to d375d62 Compare July 26, 2023 16:32
@larabr larabr force-pushed the update-packet-versions branch 3 times, most recently from 7723b60 to 1623a06 Compare July 31, 2023 14:50
@larabr larabr force-pushed the update-packet-versions branch 4 times, most recently from e1a4816 to 2231abd Compare August 7, 2023 20:08
src/message.js Outdated Show resolved Hide resolved
src/encoding/armor.js Outdated Show resolved Hide resolved
src/message.js Outdated Show resolved Hide resolved
src/message.js Outdated Show resolved Hide resolved
twiss and others added 22 commits September 1, 2023 14:48
Chrome's Web Crypto implementation doesn't support it, and it
seems unnecessary to list it when AES-256 is available.
This has been changed in the crypto refresh.
Key flags, expiration time, algorithm preferences, et cetera, are now
read from the direct-key signature instead of the primary User ID
binding signature for v6 keys.

This also requires a direct-key signature to be present for v6 keys.
The crypto refresh says that we MUST NOT reject messages where the
CRC24 checksum is incorrect. So, we remove the check for it.

Also, remove the checksumRequired config.
The latest crypto refresh specifies an HKDF step to be used for
deriving the key to encrypt the session key with.

It also specifies two additional length fields.
Instead of calling getPreferredAlgo('symmetric') and
getPreferredAlgo('aead'), we define and call getPreferredCipherSuite()
to determine the preferred symmetric and AEAD algorithm.

Additionally, we remove isAEADSupported(), instead we return
aeadAlgorithm: undefined from getPreferredCipherSuite() if AEAD is not
supported (CFB is used instead).

And finally, we define getPreferredCompressionAlgo() to replace
getPreferredAlgo('compression').
Also, set version in PKESK constructor to null,
requiring to explicitly set all fields.

Co-authored-by: Lukas Burkhalter <lukas.burkhalter@proton.ch>
Rather than using the config to determine which algorithms to try
to decrypt session keys for, try the algorithm we know the message
was encrypted with.
…test for modification detection on decryption

Also, address race condition in error handling as part of AEAD message decryption,
which would cause non-uniform errors during testing.
The Packet Tag space is now partitioned into critical packets and non-critical packets.
If an implementation encounters a critical packet where the packet type is unknown in a packet sequence,
it MUST reject the whole packet sequence. On the other hand, an unknown non-critical packet MUST be ignored.

See https://www.ietf.org/archive/id/draft-ietf-openpgp-crypto-refresh-10.html#section-4.3.1 .
Introduces v6 one-pass signature packets required for v6 signatures.
Includes the changes from !305 of the crypto refresh:
https://gitlab.com/openpgp-wg/rfc4880bis/-/merge_requests/305

Also, introduce `OnePassSignaturePacket.fromSignaturePacket` to simplify
OPS generation.
The latest version of the crypto refresh (i.e., !313, !314) specifies that
the  "Hash" header is deprecated, and that an implementation that is verifying
a cleartext signed message MUST ignore this header.
However, we go against this directive, and keep the checks in place to avoid
arbitrary injection of text as part of the "Hash" header payload.
We also mandate that if the hash header is present, the declared
algorithm matches the signature algorithm. This is again to avoid
a spoofing attack where e.g. a SHA1 signature is presented as
using SHA512.
Related CVEs: CVE-2019-11841, CVE-2023-41037.

This commit does not change the writing part of cleartext messages.

# Conflicts:
#	src/cleartext.js
The latest version of the crypto refresh (i.e., !313, !314) specifies that
the "Hash" header is depricated. This commit changes that the Hash header
is only generated if a cleartext message contains a non-V6 signature.
To avoid defaulting to v1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants