Skip to content

Commit

Permalink
Fix SEIPDv2 packet parsing error messages (#215)
Browse files Browse the repository at this point in the history
  • Loading branch information
twiss authored Jul 15, 2024
1 parent 4333135 commit ef6d672
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions openpgp/packet/symmetrically_encrypted_aead.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"crypto/cipher"
"crypto/sha256"
"io"
"strconv"

"github.com/ProtonMail/go-crypto/openpgp/errors"
"golang.org/x/crypto/hkdf"
Expand All @@ -25,19 +26,19 @@ func (se *SymmetricallyEncrypted) parseAead(r io.Reader) error {
se.Cipher = CipherFunction(headerData[0])
// cipherFunc must have block size 16 to use AEAD
if se.Cipher.blockSize() != 16 {
return errors.UnsupportedError("invalid aead cipher: " + string(se.Cipher))
return errors.UnsupportedError("invalid aead cipher: " + strconv.Itoa(int(se.Cipher)))
}

// Mode
se.Mode = AEADMode(headerData[1])
if se.Mode.TagLength() == 0 {
return errors.UnsupportedError("unknown aead mode: " + string(se.Mode))
return errors.UnsupportedError("unknown aead mode: " + strconv.Itoa(int(se.Mode)))
}

// Chunk size
se.ChunkSizeByte = headerData[2]
if se.ChunkSizeByte > 16 {
return errors.UnsupportedError("invalid aead chunk size byte: " + string(se.ChunkSizeByte))
return errors.UnsupportedError("invalid aead chunk size byte: " + strconv.Itoa(int(se.ChunkSizeByte)))
}

// Salt
Expand Down

0 comments on commit ef6d672

Please sign in to comment.