From 93256dea4f70afa8cb97b12bae102265e11043cc Mon Sep 17 00:00:00 2001 From: Lukas Burkhalter Date: Wed, 17 Jan 2024 11:37:54 +0100 Subject: [PATCH] refactor: Replacer ioutil.ReadAll with io.ReadAll --- openpgp/armor/armor_test.go | 4 +- openpgp/integration_tests/end_to_end_test.go | 7 ++- .../integration_tests/v2/end_to_end_test.go | 7 ++- openpgp/packet/compressed_test.go | 5 +- openpgp/packet/opaque.go | 3 +- openpgp/packet/packet_test.go | 5 +- openpgp/packet/private_key.go | 3 +- .../packet/symmetric_key_encrypted_test.go | 3 +- .../packet/symmetrically_encrypted_test.go | 7 ++- openpgp/packet/userattribute.go | 3 +- openpgp/packet/userid.go | 3 +- openpgp/read_test.go | 44 +++++++++--------- openpgp/v2/read_test.go | 46 +++++++++---------- openpgp/v2/write_test.go | 17 ++++--- openpgp/write_test.go | 5 +- 15 files changed, 75 insertions(+), 87 deletions(-) diff --git a/openpgp/armor/armor_test.go b/openpgp/armor/armor_test.go index 595612493..861b35473 100644 --- a/openpgp/armor/armor_test.go +++ b/openpgp/armor/armor_test.go @@ -7,7 +7,7 @@ package armor import ( "bytes" "hash/adler32" - "io/ioutil" + "io" "testing" ) @@ -29,7 +29,7 @@ func TestDecodeEncode(t *testing.T) { t.Errorf("result.Header: got:%#v", result.Header) } - contents, err := ioutil.ReadAll(result.Body) + contents, err := io.ReadAll(result.Body) if err != nil { t.Error(err) } diff --git a/openpgp/integration_tests/end_to_end_test.go b/openpgp/integration_tests/end_to_end_test.go index 09b2221bb..303cdd612 100644 --- a/openpgp/integration_tests/end_to_end_test.go +++ b/openpgp/integration_tests/end_to_end_test.go @@ -6,7 +6,6 @@ import ( "bytes" "encoding/json" "io" - "io/ioutil" "os" "strings" "testing" @@ -42,7 +41,7 @@ func TestEndToEnd(t *testing.T) { if err != nil { panic(err) } - raw, err := ioutil.ReadAll(file) + raw, err := io.ReadAll(file) if err != nil { panic(err) } @@ -118,7 +117,7 @@ func decryptionTest(t *testing.T, vector testVector, sk openpgp.EntityList) { t.Fatal(err) } - body, err := ioutil.ReadAll(md.UnverifiedBody) + body, err := io.ReadAll(md.UnverifiedBody) if err != nil { t.Fatal(err) } @@ -218,7 +217,7 @@ func encDecTest(t *testing.T, from testVector, testVectors []testVector) { t.Fatalf("Failed to find the signing Entity") } - plaintext, err := ioutil.ReadAll(md.UnverifiedBody) + plaintext, err := io.ReadAll(md.UnverifiedBody) if err != nil { t.Fatalf("Error reading encrypted contents: %s", err) } diff --git a/openpgp/integration_tests/v2/end_to_end_test.go b/openpgp/integration_tests/v2/end_to_end_test.go index 2ed9e4b2a..d44792375 100644 --- a/openpgp/integration_tests/v2/end_to_end_test.go +++ b/openpgp/integration_tests/v2/end_to_end_test.go @@ -7,7 +7,6 @@ import ( "crypto" "encoding/json" "io" - "io/ioutil" "os" "strings" "testing" @@ -50,7 +49,7 @@ func TestEndToEnd(t *testing.T) { if err != nil { panic(err) } - raw, err := ioutil.ReadAll(file) + raw, err := io.ReadAll(file) if err != nil { panic(err) } @@ -128,7 +127,7 @@ func decryptionTest(t *testing.T, vector testVector, sk openpgp.EntityList) { t.Fatal(err) } - body, err := ioutil.ReadAll(md.UnverifiedBody) + body, err := io.ReadAll(md.UnverifiedBody) if err != nil { t.Fatal(err) } @@ -235,7 +234,7 @@ func encDecTest(t *testing.T, from testVector, testVectors []testVector) { t.Fatalf("Failed to find the signing Entity") } - plaintext, err := ioutil.ReadAll(md.UnverifiedBody) + plaintext, err := io.ReadAll(md.UnverifiedBody) if err != nil { t.Fatalf("Error reading encrypted contents: %s", err) } diff --git a/openpgp/packet/compressed_test.go b/openpgp/packet/compressed_test.go index 5cf3dba90..776d20813 100644 --- a/openpgp/packet/compressed_test.go +++ b/openpgp/packet/compressed_test.go @@ -9,7 +9,6 @@ import ( "crypto/rand" "encoding/hex" "io" - "io/ioutil" mathrand "math/rand" "testing" ) @@ -31,7 +30,7 @@ func TestCompressed(t *testing.T) { return } - contents, err := ioutil.ReadAll(c.Body) + contents, err := io.ReadAll(c.Body) if err != nil && err != io.EOF { t.Error(err) return @@ -75,7 +74,7 @@ func TestCompressDecompressRandomizeFast(t *testing.T) { if !ok { t.Error("didn't find Compressed packet") } - contents, err := ioutil.ReadAll(c.Body) + contents, err := io.ReadAll(c.Body) if err != nil && err != io.EOF { t.Error(err) } diff --git a/openpgp/packet/opaque.go b/openpgp/packet/opaque.go index 4f8204079..cef7c661d 100644 --- a/openpgp/packet/opaque.go +++ b/openpgp/packet/opaque.go @@ -7,7 +7,6 @@ package packet import ( "bytes" "io" - "io/ioutil" "github.com/ProtonMail/go-crypto/openpgp/errors" ) @@ -26,7 +25,7 @@ type OpaquePacket struct { } func (op *OpaquePacket) parse(r io.Reader) (err error) { - op.Contents, err = ioutil.ReadAll(r) + op.Contents, err = io.ReadAll(r) return } diff --git a/openpgp/packet/packet_test.go b/openpgp/packet/packet_test.go index 770b8b5ba..526871df0 100644 --- a/openpgp/packet/packet_test.go +++ b/openpgp/packet/packet_test.go @@ -9,7 +9,6 @@ import ( "encoding/hex" "fmt" "io" - "io/ioutil" "testing" "github.com/ProtonMail/go-crypto/openpgp/errors" @@ -101,7 +100,7 @@ var partialLengthReaderTests = []struct { func TestPartialLengthReader(t *testing.T) { for i, test := range partialLengthReaderTests { r := &partialLengthReader{readerFromHex(test.hexInput), 0, true} - out, err := ioutil.ReadAll(r) + out, err := io.ReadAll(r) if test.err != nil { if err != test.err { t.Errorf("%d: expected different error got:%s want:%s", i, err, test.err) @@ -173,7 +172,7 @@ func TestReadHeader(t *testing.T) { continue } - body, err := ioutil.ReadAll(contents) + body, err := io.ReadAll(contents) if err != nil { if !test.unexpectedEOF || err != io.ErrUnexpectedEOF { t.Errorf("%d: unexpected error from contents: %s", i, err) diff --git a/openpgp/packet/private_key.go b/openpgp/packet/private_key.go index cff3d5dac..099b4d9ba 100644 --- a/openpgp/packet/private_key.go +++ b/openpgp/packet/private_key.go @@ -15,7 +15,6 @@ import ( "crypto/subtle" "fmt" "io" - "io/ioutil" "math/big" "strconv" "time" @@ -312,7 +311,7 @@ func (pk *PrivateKey) parse(r io.Reader) (err error) { return } } else { - privateKeyData, err = ioutil.ReadAll(r) + privateKeyData, err = io.ReadAll(r) if err != nil { return } diff --git a/openpgp/packet/symmetric_key_encrypted_test.go b/openpgp/packet/symmetric_key_encrypted_test.go index 6896d68d7..bf7463bba 100644 --- a/openpgp/packet/symmetric_key_encrypted_test.go +++ b/openpgp/packet/symmetric_key_encrypted_test.go @@ -9,7 +9,6 @@ import ( "crypto/rand" "encoding/hex" "io" - "io/ioutil" mathrand "math/rand" "testing" @@ -55,7 +54,7 @@ func TestDecryptSymmetricKeyAndEncryptedDataPacket(t *testing.T) { t.Fatal(err) } - contents, err := ioutil.ReadAll(r) + contents, err := io.ReadAll(r) if err != nil && err != io.EOF && err != io.ErrUnexpectedEOF { t.Fatal(err) } diff --git a/openpgp/packet/symmetrically_encrypted_test.go b/openpgp/packet/symmetrically_encrypted_test.go index f4dc8a161..21204b39d 100644 --- a/openpgp/packet/symmetrically_encrypted_test.go +++ b/openpgp/packet/symmetrically_encrypted_test.go @@ -11,7 +11,6 @@ import ( "encoding/hex" goerrors "errors" "io" - "io/ioutil" "testing" "github.com/ProtonMail/go-crypto/openpgp/errors" @@ -49,7 +48,7 @@ func TestMDCReader(t *testing.T) { for stride := 1; stride < len(mdcPlaintext)/2; stride++ { r := &testReader{data: mdcPlaintext, stride: stride} mdcReader := &seMDCReader{in: r, h: sha1.New()} - body, err := ioutil.ReadAll(mdcReader) + body, err := io.ReadAll(mdcReader) if err != nil { t.Errorf("stride: %d, error: %s", stride, err) continue @@ -69,7 +68,7 @@ func TestMDCReader(t *testing.T) { r := &testReader{data: mdcPlaintext, stride: 2} mdcReader := &seMDCReader{in: r, h: sha1.New()} - _, err := ioutil.ReadAll(mdcReader) + _, err := io.ReadAll(mdcReader) if err != nil { t.Errorf("corruption test, error: %s", err) return @@ -200,7 +199,7 @@ func TestAeadRfcVector(t *testing.T) { return } - decrypted, err := ioutil.ReadAll(aeadReader) + decrypted, err := io.ReadAll(aeadReader) if err != nil { t.Errorf("error when reading: %s", err) return diff --git a/openpgp/packet/userattribute.go b/openpgp/packet/userattribute.go index 88ec72c6c..63814ed13 100644 --- a/openpgp/packet/userattribute.go +++ b/openpgp/packet/userattribute.go @@ -9,7 +9,6 @@ import ( "image" "image/jpeg" "io" - "io/ioutil" ) const UserAttrImageSubpacket = 1 @@ -63,7 +62,7 @@ func NewUserAttribute(contents ...*OpaqueSubpacket) *UserAttribute { func (uat *UserAttribute) parse(r io.Reader) (err error) { // RFC 4880, section 5.13 - b, err := ioutil.ReadAll(r) + b, err := io.ReadAll(r) if err != nil { return } diff --git a/openpgp/packet/userid.go b/openpgp/packet/userid.go index 614fbafd5..3c7451a3c 100644 --- a/openpgp/packet/userid.go +++ b/openpgp/packet/userid.go @@ -6,7 +6,6 @@ package packet import ( "io" - "io/ioutil" "strings" ) @@ -66,7 +65,7 @@ func NewUserId(name, comment, email string) *UserId { func (uid *UserId) parse(r io.Reader) (err error) { // RFC 4880, section 5.11 - b, err := ioutil.ReadAll(r) + b, err := io.ReadAll(r) if err != nil { return } diff --git a/openpgp/read_test.go b/openpgp/read_test.go index 7652f5829..da3184012 100644 --- a/openpgp/read_test.go +++ b/openpgp/read_test.go @@ -131,7 +131,7 @@ func checkSignedMessage(t *testing.T, signedHex, expected string) { t.Errorf("bad MessageDetails: %#v", md) } - contents, err := ioutil.ReadAll(md.UnverifiedBody) + contents, err := io.ReadAll(md.UnverifiedBody) if err != nil { t.Errorf("error reading UnverifiedBody: %s", err) } @@ -229,7 +229,7 @@ func TestSignedEncryptedMessage(t *testing.T) { t.Errorf("#%d: bad MessageDetails: %#v", i, md) } - contents, err := ioutil.ReadAll(md.UnverifiedBody) + contents, err := io.ReadAll(md.UnverifiedBody) if err != nil { t.Errorf("#%d: error reading UnverifiedBody: %s", i, err) } @@ -248,7 +248,7 @@ func TestSignedEncryptedMessage(t *testing.T) { t.Errorf("#%d: error serializing verified signature: %s", i, err) } - sigData, err := ioutil.ReadAll(&sig) + sigData, err := io.ReadAll(&sig) if err != nil { t.Errorf("#%d: error reading verified signature: %s", i, err) } @@ -267,7 +267,7 @@ func TestSignedEncryptedMessage(t *testing.T) { } } - sigData, err := ioutil.ReadAll(&sig) + sigData, err := io.ReadAll(&sig) if err != nil { t.Errorf("#%d: error reading unverified signature: %s", i, err) } @@ -289,7 +289,7 @@ func TestUnspecifiedRecipient(t *testing.T) { return } - contents, err := ioutil.ReadAll(md.UnverifiedBody) + contents, err := io.ReadAll(md.UnverifiedBody) if err != nil { t.Errorf("error reading UnverifiedBody: %s", err) } @@ -324,7 +324,7 @@ func TestSymmetricallyEncrypted(t *testing.T) { return } - contents, err := ioutil.ReadAll(md.UnverifiedBody) + contents, err := io.ReadAll(md.UnverifiedBody) if err != nil { t.Errorf("ReadAll: %s", err) } @@ -450,7 +450,7 @@ func TestSignatureUnknownNotation(t *testing.T) { t.Error(err) return } - _, err = ioutil.ReadAll(md.UnverifiedBody) + _, err = io.ReadAll(md.UnverifiedBody) if err != nil { t.Error(err) return @@ -481,7 +481,7 @@ func TestSignatureKnownNotation(t *testing.T) { t.Error(err) return } - _, err = ioutil.ReadAll(md.UnverifiedBody) + _, err = io.ReadAll(md.UnverifiedBody) if err != nil { t.Error(err) return @@ -568,7 +568,7 @@ func TestSignatureV3Message(t *testing.T) { return } - _, err = ioutil.ReadAll(md.UnverifiedBody) + _, err = io.ReadAll(md.UnverifiedBody) if err != nil { t.Error(err) return @@ -603,7 +603,7 @@ func TestReadV6Messages(t *testing.T) { t.Error(err) return } - contents, err := ioutil.ReadAll(md.UnverifiedBody) + contents, err := io.ReadAll(md.UnverifiedBody) if err != nil { t.Error(err) return @@ -622,7 +622,7 @@ func TestReadV6Messages(t *testing.T) { t.Error(err) return } - contents, err = ioutil.ReadAll(md.UnverifiedBody) + contents, err = io.ReadAll(md.UnverifiedBody) if err != nil { t.Error(err) return @@ -642,7 +642,7 @@ func TestSymmetricDecryptionArgon2(t *testing.T) { if err != nil { t.Fatal(err) } - armoredEncryptedMessage, err := ioutil.ReadAll(file) + armoredEncryptedMessage, err := io.ReadAll(file) if err != nil { t.Fatal(err) } @@ -662,7 +662,7 @@ func TestSymmetricDecryptionArgon2(t *testing.T) { t.Error(err) return } - contents, err := ioutil.ReadAll(md.UnverifiedBody) + contents, err := io.ReadAll(md.UnverifiedBody) if err != nil { t.Errorf("error reading UnverifiedBody: %s", err) } @@ -687,7 +687,7 @@ func TestAsymmestricAeadOcbOpenPGPjsCompressedMessage(t *testing.T) { if err != nil { t.Fatal(err) } - armoredEncryptedMessage, err := ioutil.ReadAll(ciphertext) + armoredEncryptedMessage, err := io.ReadAll(ciphertext) if err != nil { t.Fatal(err) } @@ -704,7 +704,7 @@ func TestAsymmestricAeadOcbOpenPGPjsCompressedMessage(t *testing.T) { return } // Read contents - contents, err := ioutil.ReadAll(md.UnverifiedBody) + contents, err := io.ReadAll(md.UnverifiedBody) if err != nil && err != io.ErrUnexpectedEOF { t.Errorf("error reading UnverifiedBody: %s", err) } @@ -727,7 +727,7 @@ func TestSymmetricAeadEaxOpenPGPJsMessage(t *testing.T) { if err != nil { t.Fatal(err) } - fileBytes, err := ioutil.ReadAll(file) + fileBytes, err := io.ReadAll(file) if err != nil { t.Fatal(err) } @@ -757,7 +757,7 @@ func TestSymmetricAeadEaxOpenPGPJsMessage(t *testing.T) { ld := p.(*packet.LiteralData) // Read contents - contents, err := ioutil.ReadAll(ld.Body) + contents, err := io.ReadAll(ld.Body) if err != nil && err != io.ErrUnexpectedEOF { t.Errorf("error reading UnverifiedBody: %s", err) } @@ -779,7 +779,7 @@ func TestCorruptedMessageInvalidSigHeader(t *testing.T) { if err != nil { t.Fatal(err) } - armoredEncryptedMessage, err := ioutil.ReadAll(file) + armoredEncryptedMessage, err := io.ReadAll(file) if err != nil { t.Fatal(err) } @@ -813,7 +813,7 @@ func TestCorruptedMessageWrongLength(t *testing.T) { if err != nil { t.Fatal(err) } - armoredEncryptedMessage, err := ioutil.ReadAll(file) + armoredEncryptedMessage, err := io.ReadAll(file) if err != nil { t.Fatal(err) } @@ -827,7 +827,7 @@ func TestCorruptedMessageWrongLength(t *testing.T) { t.Error(err) return } - _, err = ioutil.ReadAll(md.UnverifiedBody) + _, err = io.ReadAll(md.UnverifiedBody) if err == nil { t.Fatal("Parsing error expected") } @@ -878,7 +878,7 @@ func TestMessageWithoutMdc(t *testing.T) { t.Fatal("reading the message should have worked") } - b, err := ioutil.ReadAll(md.UnverifiedBody) + b, err := io.ReadAll(md.UnverifiedBody) if err != nil { t.Fatal("reading the message should have worked") } @@ -911,7 +911,7 @@ func TestReadV5Messages(t *testing.T) { t.Error(err) return } - contents, err := ioutil.ReadAll(md.UnverifiedBody) + contents, err := io.ReadAll(md.UnverifiedBody) if err != nil { t.Error(err) return diff --git a/openpgp/v2/read_test.go b/openpgp/v2/read_test.go index 8f274e215..024ae608c 100644 --- a/openpgp/v2/read_test.go +++ b/openpgp/v2/read_test.go @@ -135,7 +135,7 @@ func checkSignedMessage(t *testing.T, signedHex, expected string) { t.Errorf("bad MessageDetails: %#v", md) } - contents, err := ioutil.ReadAll(md.UnverifiedBody) + contents, err := io.ReadAll(md.UnverifiedBody) if err != nil { t.Errorf("error reading UnverifiedBody: %s", err) } @@ -240,7 +240,7 @@ func TestSignedEncryptedMessage(t *testing.T) { t.Errorf("#%d: bad MessageDetails: %#v", i, md) } - contents, err := ioutil.ReadAll(md.UnverifiedBody) + contents, err := io.ReadAll(md.UnverifiedBody) if err != nil { t.Errorf("#%d: error reading UnverifiedBody: %s", i, err) } @@ -262,7 +262,7 @@ func TestSignedEncryptedMessage(t *testing.T) { t.Errorf("#%d: error serializing verified signature: %s", i, err) } - sigData, err := ioutil.ReadAll(&sig) + sigData, err := io.ReadAll(&sig) if err != nil { t.Errorf("#%d: error reading verified signature: %s", i, err) } @@ -284,7 +284,7 @@ func TestUnspecifiedRecipient(t *testing.T) { return } - contents, err := ioutil.ReadAll(md.UnverifiedBody) + contents, err := io.ReadAll(md.UnverifiedBody) if err != nil { t.Errorf("error reading UnverifiedBody: %s", err) } @@ -319,7 +319,7 @@ func TestSymmetricallyEncrypted(t *testing.T) { return } - contents, err := ioutil.ReadAll(md.UnverifiedBody) + contents, err := io.ReadAll(md.UnverifiedBody) if err != nil { t.Errorf("ReadAll: %s", err) } @@ -441,7 +441,7 @@ func TestSignatureUnknownNotation(t *testing.T) { t.Error(err) return } - _, err = ioutil.ReadAll(md.UnverifiedBody) + _, err = io.ReadAll(md.UnverifiedBody) if err != nil { t.Error(err) return @@ -471,7 +471,7 @@ func TestSignatureKnownNotation(t *testing.T) { t.Error(err) return } - _, err = ioutil.ReadAll(md.UnverifiedBody) + _, err = io.ReadAll(md.UnverifiedBody) if err != nil { t.Error(err) return @@ -561,7 +561,7 @@ func TestSignatureV3Message(t *testing.T) { return } - _, err = ioutil.ReadAll(md.UnverifiedBody) + _, err = io.ReadAll(md.UnverifiedBody) if err != nil { t.Error(err) return @@ -599,7 +599,7 @@ func TestSignatureOldStyleMessage(t *testing.T) { return } - _, err = ioutil.ReadAll(md.UnverifiedBody) + _, err = io.ReadAll(md.UnverifiedBody) if err != nil { t.Error(err) return @@ -631,7 +631,7 @@ func TestReadV6Messages(t *testing.T) { t.Error(err) return } - contents, err := ioutil.ReadAll(md.UnverifiedBody) + contents, err := io.ReadAll(md.UnverifiedBody) if err != nil { t.Error(err) return @@ -650,7 +650,7 @@ func TestReadV6Messages(t *testing.T) { t.Error(err) return } - contents, err = ioutil.ReadAll(md.UnverifiedBody) + contents, err = io.ReadAll(md.UnverifiedBody) if err != nil { t.Error(err) return @@ -673,7 +673,7 @@ func TestSymmetricDecryptionArgon2(t *testing.T) { if err != nil { t.Fatal(err) } - armoredEncryptedMessage, err := ioutil.ReadAll(file) + armoredEncryptedMessage, err := io.ReadAll(file) if err != nil { t.Fatal(err) } @@ -693,7 +693,7 @@ func TestSymmetricDecryptionArgon2(t *testing.T) { t.Error(err) return } - contents, err := ioutil.ReadAll(md.UnverifiedBody) + contents, err := io.ReadAll(md.UnverifiedBody) if err != nil { t.Errorf("error reading UnverifiedBody: %s", err) } @@ -718,7 +718,7 @@ func TestAsymmestricAeadOcbOpenPGPjsCompressedMessage(t *testing.T) { if err != nil { t.Fatal(err) } - armoredEncryptedMessage, err := ioutil.ReadAll(ciphertext) + armoredEncryptedMessage, err := io.ReadAll(ciphertext) if err != nil { t.Fatal(err) } @@ -735,7 +735,7 @@ func TestAsymmestricAeadOcbOpenPGPjsCompressedMessage(t *testing.T) { return } // Read contents - contents, err := ioutil.ReadAll(md.UnverifiedBody) + contents, err := io.ReadAll(md.UnverifiedBody) if err != nil && err != io.ErrUnexpectedEOF { t.Errorf("error reading UnverifiedBody: %s", err) } @@ -758,7 +758,7 @@ func TestSymmetricAeadEaxOpenPGPJsMessage(t *testing.T) { if err != nil { t.Fatal(err) } - fileBytes, err := ioutil.ReadAll(file) + fileBytes, err := io.ReadAll(file) if err != nil { t.Fatal(err) } @@ -792,7 +792,7 @@ func TestSymmetricAeadEaxOpenPGPJsMessage(t *testing.T) { ld := p.(*packet.LiteralData) // Read contents - contents, err := ioutil.ReadAll(ld.Body) + contents, err := io.ReadAll(ld.Body) if err != nil && err != io.ErrUnexpectedEOF { t.Errorf("error reading UnverifiedBody: %s", err) } @@ -814,7 +814,7 @@ func TestCorruptedMessageInvalidSigHeader(t *testing.T) { if err != nil { t.Fatal(err) } - armoredEncryptedMessage, err := ioutil.ReadAll(file) + armoredEncryptedMessage, err := io.ReadAll(file) if err != nil { t.Fatal(err) } @@ -848,7 +848,7 @@ func TestCorruptedMessageWrongLength(t *testing.T) { if err != nil { t.Fatal(err) } - armoredEncryptedMessage, err := ioutil.ReadAll(file) + armoredEncryptedMessage, err := io.ReadAll(file) if err != nil { t.Fatal(err) } @@ -862,7 +862,7 @@ func TestCorruptedMessageWrongLength(t *testing.T) { t.Error(err) return } - _, err = ioutil.ReadAll(md.UnverifiedBody) + _, err = io.ReadAll(md.UnverifiedBody) if err == nil { t.Fatal("Parsing error expected") } @@ -913,7 +913,7 @@ func TestMessageWithoutMdc(t *testing.T) { t.Fatal("reading the message should have worked") } - b, err := ioutil.ReadAll(md.UnverifiedBody) + b, err := io.ReadAll(md.UnverifiedBody) if err != nil { t.Fatal("reading the message should have worked") } @@ -944,7 +944,7 @@ func TestMultiSignedMessage(t *testing.T) { t.Errorf("expected 2 signature candidates, got: %d", len(md.SignatureCandidates)) } - _, err = ioutil.ReadAll(md.UnverifiedBody) + _, err = io.ReadAll(md.UnverifiedBody) if err != nil { t.Fatal(err) } @@ -994,7 +994,7 @@ func testMalformedMessage(t *testing.T, keyring EntityList, message string) { if err != nil { return } - _, err = ioutil.ReadAll(md.UnverifiedBody) + _, err = io.ReadAll(md.UnverifiedBody) if err == nil { t.Error("Expected malformed message error") return diff --git a/openpgp/v2/write_test.go b/openpgp/v2/write_test.go index f121ef7cd..0b61578b4 100644 --- a/openpgp/v2/write_test.go +++ b/openpgp/v2/write_test.go @@ -8,7 +8,6 @@ import ( "bytes" "crypto/rand" "io" - "io/ioutil" mathrand "math/rand" "testing" "time" @@ -510,7 +509,7 @@ func TestIntendedRecipientsEncryption(t *testing.T) { if !md.CheckRecipients { t.Error("should check for intended recipient") } - _, err = ioutil.ReadAll(md.UnverifiedBody) + _, err = io.ReadAll(md.UnverifiedBody) if err != nil { t.Errorf("error reading encrypted contents: %s", err) } @@ -534,7 +533,7 @@ func TestIntendedRecipientsEncryption(t *testing.T) { if !md.CheckRecipients { t.Error("should check for intended recipient") } - _, err = ioutil.ReadAll(md.UnverifiedBody) + _, err = io.ReadAll(md.UnverifiedBody) if err != nil { t.Errorf("error reading encrypted contents: %s", err) } @@ -557,7 +556,7 @@ func TestIntendedRecipientsEncryption(t *testing.T) { if md.CheckRecipients { t.Error("should not check for intended recipient") } - _, err = ioutil.ReadAll(md.UnverifiedBody) + _, err = io.ReadAll(md.UnverifiedBody) if err != nil { t.Errorf("error reading encrypted contents: %s", err) } @@ -619,7 +618,7 @@ func TestMultiSignEncryption(t *testing.T) { } // Check reading with v4 key - _, err = ioutil.ReadAll(md.UnverifiedBody) + _, err = io.ReadAll(md.UnverifiedBody) if err != nil { t.Errorf("error reading encrypted contents: %s", err) } @@ -637,7 +636,7 @@ func TestMultiSignEncryption(t *testing.T) { if err != nil { t.Errorf("error reading message: %s", err) } - _, err = ioutil.ReadAll(md.UnverifiedBody) + _, err = io.ReadAll(md.UnverifiedBody) if err != nil { t.Errorf("error reading encrypted contents: %s", err) } @@ -655,7 +654,7 @@ func TestMultiSignEncryption(t *testing.T) { if err != nil { t.Errorf("error reading message: %s", err) } - _, err = ioutil.ReadAll(md.UnverifiedBody) + _, err = io.ReadAll(md.UnverifiedBody) if err != nil { t.Errorf("error reading encrypted contents: %s", err) } @@ -766,7 +765,7 @@ func TestEncryption(t *testing.T) { } } - plaintext, err := ioutil.ReadAll(md.UnverifiedBody) + plaintext, err := io.ReadAll(md.UnverifiedBody) if err != nil { t.Errorf("#%d: error reading encrypted contents: %s", i, err) continue @@ -872,7 +871,7 @@ func TestSigning(t *testing.T) { t.Errorf("#%d: failed to find the signing Entity", i) } - plaintext, err := ioutil.ReadAll(md.UnverifiedBody) + plaintext, err := io.ReadAll(md.UnverifiedBody) if err != nil { t.Errorf("#%d: error reading contents: %v", i, err) continue diff --git a/openpgp/write_test.go b/openpgp/write_test.go index 9e3d36b4e..5f9995529 100644 --- a/openpgp/write_test.go +++ b/openpgp/write_test.go @@ -8,7 +8,6 @@ import ( "bytes" "crypto/rand" "io" - "io/ioutil" mathrand "math/rand" "testing" "time" @@ -551,7 +550,7 @@ func TestEncryption(t *testing.T) { } } - plaintext, err := ioutil.ReadAll(md.UnverifiedBody) + plaintext, err := io.ReadAll(md.UnverifiedBody) if err != nil { t.Errorf("#%d: error reading encrypted contents: %s", i, err) continue @@ -651,7 +650,7 @@ func TestSigning(t *testing.T) { t.Errorf("#%d: failed to find the signing Entity", i) } - plaintext, err := ioutil.ReadAll(md.UnverifiedBody) + plaintext, err := io.ReadAll(md.UnverifiedBody) if err != nil { t.Errorf("#%d: error reading contents: %v", i, err) continue