diff --git a/openpgp/packet/aead_encrypted.go b/openpgp/packet/aead_encrypted.go index ea153bc2..98bd876b 100644 --- a/openpgp/packet/aead_encrypted.go +++ b/openpgp/packet/aead_encrypted.go @@ -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()) diff --git a/openpgp/packet/aead_encrypted_test.go b/openpgp/packet/aead_encrypted_test.go index 3ad36d05..97736071 100644 --- a/openpgp/packet/aead_encrypted_test.go +++ b/openpgp/packet/aead_encrypted_test.go @@ -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) @@ -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) @@ -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 @@ -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 @@ -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 @@ -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) @@ -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) diff --git a/openpgp/packet/config.go b/openpgp/packet/config.go index 927ecc4e..a5121062 100644 --- a/openpgp/packet/config.go +++ b/openpgp/packet/config.go @@ -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 diff --git a/openpgp/packet/config_build.go b/openpgp/packet/config_v5.go similarity index 100% rename from openpgp/packet/config_build.go rename to openpgp/packet/config_v5.go diff --git a/openpgp/packet/private_key.go b/openpgp/packet/private_key.go index 9ba9337e..888551d3 100644 --- a/openpgp/packet/private_key.go +++ b/openpgp/packet/private_key.go @@ -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 diff --git a/openpgp/packet/public_key.go b/openpgp/packet/public_key.go index 681511bd..f279789d 100644 --- a/openpgp/packet/public_key.go +++ b/openpgp/packet/public_key.go @@ -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 { diff --git a/openpgp/packet/signature.go b/openpgp/packet/signature.go index 9cc2d744..5a71c79e 100644 --- a/openpgp/packet/signature.go +++ b/openpgp/packet/signature.go @@ -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 { diff --git a/openpgp/packet/symmetric_key_encrypted.go b/openpgp/packet/symmetric_key_encrypted.go index 370f6ca2..f843c35b 100644 --- a/openpgp/packet/symmetric_key_encrypted.go +++ b/openpgp/packet/symmetric_key_encrypted.go @@ -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 {