Skip to content

Commit

Permalink
Integrate review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
lubux committed Jul 5, 2024
1 parent 446301b commit 598d031
Show file tree
Hide file tree
Showing 8 changed files with 6 additions and 30 deletions.
3 changes: 0 additions & 3 deletions openpgp/packet/aead_encrypted.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ type AEADEncrypted struct {
const aeadEncryptedVersion = 1

func (ae *AEADEncrypted) parse(buf io.Reader) error {
if V5Disabled {
return errors.UnsupportedError("support for parsing v5 entities is disabled; change `config.V5Disabled` if needed")
}
headerData := make([]byte, 4)
if n, err := io.ReadFull(buf, headerData); n < 4 {
return errors.AEADError("could not read aead header:" + err.Error())
Expand Down
21 changes: 0 additions & 21 deletions openpgp/packet/aead_encrypted_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ var maxChunkSizeExp = 62
const maxPlaintextLength = 1 << 18

func TestAeadRFCParse(t *testing.T) {
if V5Disabled {
t.Skip()
}
for _, sample := range samplesAeadEncryptedDataPacket {
key, _ := hex.DecodeString(sample.cek)
packetBytes, _ := hex.DecodeString(sample.full)
Expand Down Expand Up @@ -58,9 +55,6 @@ func TestAeadRFCParse(t *testing.T) {
// authentication tags: One for the empty chunk, and the final auth. tag. This
// test also checks if it cannot decrypt a corrupt stream of empty plaintext.
func TestAeadEmptyStream(t *testing.T) {
if V5Disabled {
t.Skip()
}
key := randomKey(16)
config := randomConfig()
raw, _, err := randomStream(key, 0, config)
Expand Down Expand Up @@ -118,9 +112,6 @@ func TestAeadEmptyStream(t *testing.T) {

// Tests if encrypt/decrypt functions are callable and correct with a nil config
func TestAeadNilConfigStream(t *testing.T) {
if V5Disabled {
t.Skip()
}
// Sample key
key := randomKey(16)
randomLength := mathrand.Intn(maxPlaintextLength) + 1
Expand Down Expand Up @@ -159,9 +150,6 @@ func TestAeadNilConfigStream(t *testing.T) {

// Encrypts and decrypts a random stream, checking correctness and integrity
func TestAeadStreamRandomizeSlow(t *testing.T) {
if V5Disabled {
t.Skip()
}
key := randomKey(16)
config := randomConfig()
randomLength := mathrand.Intn(maxPlaintextLength) + 1
Expand Down Expand Up @@ -202,9 +190,6 @@ func TestAeadStreamRandomizeSlow(t *testing.T) {

// Encrypts a random stream, corrupt some bytes, and check if it fails
func TestAeadCorruptStreamRandomizeSlow(t *testing.T) {
if V5Disabled {
t.Skip()
}
key := randomKey(16)
config := randomConfig()
randomLength := mathrand.Intn(maxPlaintextLength) + 1
Expand Down Expand Up @@ -248,9 +233,6 @@ func TestAeadCorruptStreamRandomizeSlow(t *testing.T) {

// Encrypts a random stream, truncate the end, and check if it fails
func TestAeadTruncatedStreamRandomizeSlow(t *testing.T) {
if V5Disabled {
t.Skip()
}
key := randomKey(16)
config := randomConfig()
randomLength := mathrand.Intn(maxPlaintextLength)
Expand Down Expand Up @@ -296,9 +278,6 @@ func TestAeadTruncatedStreamRandomizeSlow(t *testing.T) {

// Encrypts a random stream, truncate the end, and check if it fails
func TestAeadUnclosedStreamRandomizeSlow(t *testing.T) {
if V5Disabled {
t.Skip()
}
key := randomKey(16)
config := randomConfig()
ptLen := mathrand.Intn(maxPlaintextLength)
Expand Down
4 changes: 2 additions & 2 deletions openpgp/packet/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ var (
)

// A global feature flag to indicate v5 support.
// Can be set via a build tag go test -tags v5.
// If the build tag is missing config_build.go will set it to true.
// Can be set via a build tag, e.g.: `go build -tags v5 ./...`
// If the build tag is missing config_v5.go will set it to true.
//
// Disables parsing of v5 keys, v5 signatures and AEAD-encrypted data packets.
// These are non-standard entities, which in the crypto-refresh have been superseded
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion openpgp/packet/private_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ func (pk *PrivateKey) parse(r io.Reader) (err error) {
v6 := pk.PublicKey.Version == 6

if V5Disabled && v5 {
return errors.UnsupportedError("support for parsing v5 entities is disabled; change `config.V5Disabled` if needed")
return errors.UnsupportedError("support for parsing v5 entities is disabled; build with `-tags v5` if needed")
}

var buf [1]byte
Expand Down
2 changes: 1 addition & 1 deletion openpgp/packet/public_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ func (pk *PublicKey) parse(r io.Reader) (err error) {
}

if V5Disabled && pk.Version == 5 {
return errors.UnsupportedError("support for parsing v5 entities is disabled; change `config.V5Disabled` if needed")
return errors.UnsupportedError("support for parsing v5 entities is disabled; build with `-tags v5` if needed")
}

if pk.Version >= 5 {
Expand Down
2 changes: 1 addition & 1 deletion openpgp/packet/signature.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ func (sig *Signature) parse(r io.Reader) (err error) {
}

if V5Disabled && sig.Version == 5 {
return errors.UnsupportedError("support for parsing v5 entities is disabled; change `config.V5Disabled` if needed")
return errors.UnsupportedError("support for parsing v5 entities is disabled; build with `-tags v5` if needed")
}

if sig.Version == 6 {
Expand Down
2 changes: 1 addition & 1 deletion openpgp/packet/symmetric_key_encrypted.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (ske *SymmetricKeyEncrypted) parse(r io.Reader) error {
}

if V5Disabled && ske.Version == 5 {
return errors.UnsupportedError("Support for parsing v5 entities is disabled; change `config.V5Disabled` if needed")
return errors.UnsupportedError("support for parsing v5 entities is disabled; build with `-tags v5` if needed")
}

if ske.Version > 5 {
Expand Down

0 comments on commit 598d031

Please sign in to comment.