ProtonMail / go-crypto

Fork of go/x/crypto, providing an up-to-date OpenPGP implementation
https://pkg.go.dev/github.com/ProtonMail/go-crypto
BSD 3-Clause "New" or "Revised" License
328 stars 99 forks source link

Restrict S2K types #213

Closed twiss closed 1 month ago

twiss commented 1 month ago

RFC9580 says that:

Argon2 is only used with AEAD (S2K usage octet 253).  An
implementation MUST NOT create and MUST reject as malformed any
secret key packet where the S2K usage octet is not AEAD (253) and
the S2K specifier type is Argon2.

Therefore, we disallow reading and writing Argon2 keys without AEAD.

And:

[The Simple and Salted S2K methods] are used only for reading in
backwards compatibility mode.

So, we disallow encrypting keys using those methods.

Since V6 keys don't need backwards compatibility, we also disallow reading Simple S2K there. We still allow reading Salted S2K since the spec says it may be used "when [the password] is high entropy".