Skip to content

Commit 531d9f5

Browse files
committed
Improve documentation
Document that the `aeadSupported` parameter passed to `SerializeEncryptedKeyAEAD[withHiddenOption]`, `SerializeSymmetricKeyEncryptedAEADReuseKey`, and `SerializeSymmetricallyEncrypted` must match.
1 parent 1efe4a0 commit 531d9f5

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

openpgp/packet/encrypted_key.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,8 @@ func (e *EncryptedKey) Serialize(w io.Writer) error {
321321

322322
// SerializeEncryptedKeyAEAD serializes an encrypted key packet to w that contains
323323
// key, encrypted to pub.
324-
// If aeadSupported is set, PKESK v6 is used else v4.
324+
// If aeadSupported is set, PKESK v6 is used, otherwise v3.
325+
// Note: aeadSupported MUST match the value passed to SerializeSymmetricallyEncrypted.
325326
// If config is nil, sensible defaults will be used.
326327
func SerializeEncryptedKeyAEAD(w io.Writer, pub *PublicKey, cipherFunc CipherFunction, aeadSupported bool, key []byte, config *Config) error {
327328
return SerializeEncryptedKeyAEADwithHiddenOption(w, pub, cipherFunc, aeadSupported, key, false, config)
@@ -330,7 +331,8 @@ func SerializeEncryptedKeyAEAD(w io.Writer, pub *PublicKey, cipherFunc CipherFun
330331
// SerializeEncryptedKeyAEADwithHiddenOption serializes an encrypted key packet to w that contains
331332
// key, encrypted to pub.
332333
// Offers the hidden flag option to indicated if the PKESK packet should include a wildcard KeyID.
333-
// If aeadSupported is set, PKESK v6 is used else v4.
334+
// If aeadSupported is set, PKESK v6 is used, otherwise v3.
335+
// Note: aeadSupported MUST match the value passed to SerializeSymmetricallyEncrypted.
334336
// If config is nil, sensible defaults will be used.
335337
func SerializeEncryptedKeyAEADwithHiddenOption(w io.Writer, pub *PublicKey, cipherFunc CipherFunction, aeadSupported bool, key []byte, hidden bool, config *Config) error {
336338
var buf [36]byte // max possible header size is v6

openpgp/packet/symmetric_key_encrypted.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,8 @@ func SerializeSymmetricKeyEncryptedReuseKey(w io.Writer, sessionKey []byte, pass
204204
// The packet contains the given session key, encrypted by a key derived from
205205
// the given passphrase. The returned session key must be passed to
206206
// SerializeSymmetricallyEncrypted.
207+
// If aeadSupported is set, SKESK v6 is used, otherwise v4.
208+
// Note: aeadSupported MUST match the value passed to SerializeSymmetricallyEncrypted.
207209
// If config is nil, sensible defaults will be used.
208210
func SerializeSymmetricKeyEncryptedAEADReuseKey(w io.Writer, sessionKey []byte, passphrase []byte, aeadSupported bool, config *Config) (err error) {
209211
var version int

openpgp/packet/symmetrically_encrypted.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ func (se *SymmetricallyEncrypted) Decrypt(c CipherFunction, key []byte) (io.Read
7474
// SerializeSymmetricallyEncrypted serializes a symmetrically encrypted packet
7575
// to w and returns a WriteCloser to which the to-be-encrypted packets can be
7676
// written.
77+
// If aeadSupported is set to true, SEIPDv2 is used with the indicated CipherSuite.
78+
// Otherwise, SEIPDv1 is used with the indicated CipherFunction.
79+
// Note: aeadSupported MUST match the value passed to SerializeEncryptedKeyAEAD
80+
// and/or SerializeSymmetricKeyEncryptedAEADReuseKey.
7781
// If config is nil, sensible defaults will be used.
7882
func SerializeSymmetricallyEncrypted(w io.Writer, c CipherFunction, aeadSupported bool, cipherSuite CipherSuite, key []byte, config *Config) (Contents io.WriteCloser, err error) {
7983
writeCloser := noOpCloser{w}

0 commit comments

Comments
 (0)