Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove refs to deprecated io/ioutil #334

Merged
merged 1 commit into from
Jun 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions examples/tpm-genaik/genaik.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"crypto/sha1"
"flag"
"fmt"
"io/ioutil"
"os"

"github.com/google/go-tpm/tpm"
Expand Down Expand Up @@ -72,7 +71,7 @@ func main() {
return
}

if err := ioutil.WriteFile(*blobname, blob, 0600); err != nil {
if err := os.WriteFile(*blobname, blob, 0600); err != nil {
fmt.Fprintf(os.Stderr, "Couldn't write to file %s: %s\n", *blobname, err)
return
}
Expand Down
6 changes: 3 additions & 3 deletions examples/tpm-sign/extend_pcr.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"crypto/sha1"
"flag"
"fmt"
"io/ioutil"
"io"
"os"

"github.com/google/go-tpm/tpm"
Expand Down Expand Up @@ -48,9 +48,9 @@ func extendPcrAction() {
} else {
var data []byte
if *dataPath == "" {
data, err = ioutil.ReadAll(os.Stdin)
data, err = io.ReadAll(os.Stdin)
} else {
data, err = ioutil.ReadFile(*dataPath)
data, err = os.ReadFile(*dataPath)
}
if err != nil {
fmt.Fprintf(os.Stderr, "Unable to read input: %s\n", err)
Expand Down
5 changes: 2 additions & 3 deletions examples/tpm-sign/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"crypto/x509"
"flag"
"fmt"
"io/ioutil"
"os"
"strconv"
"strings"
Expand Down Expand Up @@ -83,7 +82,7 @@ func generateAction() {
return
}
fmt.Printf("Writing keyblob to %s\n", *keyblobPath)
if err = ioutil.WriteFile(*keyblobPath, keyblob, 0644); err != nil {
if err = os.WriteFile(*keyblobPath, keyblob, 0644); err != nil {
fmt.Fprintf(os.Stderr, "Error writing keyblob file: %s\n", err)
return
}
Expand All @@ -100,7 +99,7 @@ func generateAction() {
return
}
fmt.Printf("Writing public key to %s\n", *pubKeyPath)
if err = ioutil.WriteFile(*pubKeyPath, pubKeyBytes, 0644); err != nil {
if err = os.WriteFile(*pubKeyPath, pubKeyBytes, 0644); err != nil {
fmt.Fprintf(os.Stderr, "Error writing public key file: %s\n", err)
return
}
Expand Down
10 changes: 5 additions & 5 deletions examples/tpm-sign/sign.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"crypto/sha1"
"flag"
"fmt"
"io/ioutil"
"io"
"os"

"github.com/google/go-tpm/tpm"
Expand Down Expand Up @@ -69,7 +69,7 @@ func signAction() {
copy(migrationAuth[:], ma[:])
}

keyblob, err := ioutil.ReadFile(*keyblobPath)
keyblob, err := os.ReadFile(*keyblobPath)
if err != nil {
fmt.Fprintf(os.Stderr, "Error reading keyblob file: %s\n", err)
return
Expand All @@ -83,9 +83,9 @@ func signAction() {

var data []byte
if *dataPath == "" {
data, err = ioutil.ReadAll(os.Stdin)
data, err = io.ReadAll(os.Stdin)
} else {
data, err = ioutil.ReadFile(*dataPath)
data, err = os.ReadFile(*dataPath)
}
if err != nil {
fmt.Fprintf(os.Stderr, "Error reading input data: %s\n", err)
Expand All @@ -104,7 +104,7 @@ func signAction() {
return
}
fmt.Printf("Writing signature to %s\n", *signaturePath)
if err = ioutil.WriteFile(*signaturePath, signature, 0644); err != nil {
if err = os.WriteFile(*signaturePath, signature, 0644); err != nil {
fmt.Fprintf(os.Stderr, "Unable to write signature to file: %s\n", err)
return
}
Expand Down
10 changes: 5 additions & 5 deletions examples/tpm-sign/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"crypto/x509"
"flag"
"fmt"
"io/ioutil"
"io"
"os"
)

Expand All @@ -41,22 +41,22 @@ func verifyAction() {
var err error
var data []byte
if *dataPath == "" {
data, err = ioutil.ReadAll(os.Stdin)
data, err = io.ReadAll(os.Stdin)
} else {
data, err = ioutil.ReadFile(*dataPath)
data, err = os.ReadFile(*dataPath)
}
if err != nil {
fmt.Fprintf(os.Stderr, "Error reading input data: %s\n", err)
return
}

signature, err := ioutil.ReadFile(*signaturePath)
signature, err := os.ReadFile(*signaturePath)
if err != nil {
fmt.Fprintf(os.Stderr, "Error reading signature file: %s\n", err)
return
}

pubKeyBytes, err := ioutil.ReadFile(*pubKeyPath)
pubKeyBytes, err := os.ReadFile(*pubKeyPath)
if err != nil {
fmt.Fprintf(os.Stderr, "Error reading public key file: %s\n", err)
return
Expand Down
3 changes: 1 addition & 2 deletions examples/tpm2-ekcert/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"errors"
"flag"
"fmt"
"io/ioutil"
"os"
"reflect"

Expand Down Expand Up @@ -64,7 +63,7 @@ func main() {
fmt.Println(string(cert))
return
}
if err := ioutil.WriteFile(*outPath, cert, os.ModePerm); err != nil {
if err := os.WriteFile(*outPath, cert, os.ModePerm); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
Expand Down
11 changes: 5 additions & 6 deletions tpm/tpm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"crypto/rsa"
"crypto/sha1"
"crypto/x509"
"io/ioutil"
mathrand "math/rand"
"os"
"testing"
Expand Down Expand Up @@ -372,7 +371,7 @@ func TestLoadKey2(t *testing.T) {
defer rwc.Close()

// Get the key from aikblob, assuming it exists. Otherwise, skip the test.
blob, err := ioutil.ReadFile("./aikblob")
blob, err := os.ReadFile("./aikblob")
if err != nil {
t.Skip("No aikblob file; skipping test")
}
Expand All @@ -394,7 +393,7 @@ func TestQuote2(t *testing.T) {
defer rwc.Close()

// Get the key from aikblob, assuming it exists. Otherwise, skip the test.
blob, err := ioutil.ReadFile("./aikblob")
blob, err := os.ReadFile("./aikblob")
if err != nil {
t.Skip("No aikblob file; skipping test")
}
Expand Down Expand Up @@ -429,7 +428,7 @@ func TestGetPubKey(t *testing.T) {
defer rwc.Close()

// Get the key from aikblob, assuming it exists. Otherwise, skip the test.
blob, err := ioutil.ReadFile("./aikblob")
blob, err := os.ReadFile("./aikblob")
if err != nil {
t.Skip("No aikblob file; skipping test")
}
Expand Down Expand Up @@ -458,7 +457,7 @@ func TestQuote(t *testing.T) {
defer rwc.Close()

// Get the key from aikblob, assuming it exists. Otherwise, skip the test.
blob, err := ioutil.ReadFile("./aikblob")
blob, err := os.ReadFile("./aikblob")
if err != nil {
t.Skip("No aikblob file; skipping test")
}
Expand Down Expand Up @@ -493,7 +492,7 @@ func TestQuote(t *testing.T) {

func TestUnmarshalRSAPublicKey(t *testing.T) {
// Get the key from aikblob, assuming it exists. Otherwise, skip the test.
blob, err := ioutil.ReadFile("./aikblob")
blob, err := os.ReadFile("./aikblob")
if err != nil {
t.Skip("No aikblob file; skipping test")
}
Expand Down