Skip to content
Permalink
Browse files

Replace tinkio.ProtoFile with keyset.BinaryReader (#1492)

* Replace tinkio.ProtoFile with keyset.BinaryReader

tinkio.ProtoFile can be replaced with the BinaryReader/BinaryWriter
  • Loading branch information
gdbelvin committed Mar 17, 2020
1 parent 1cc4602 commit 139f966f54ae970be6f6e401a84f29cc1657f9b0
@@ -18,6 +18,7 @@ import (
"context"
"flag"
"log"
"os"
"strings"
"time"

@@ -72,9 +73,12 @@ var hammerCmd = &cobra.Command{
if err != nil {
log.Fatal(err)
}
handle, err := keyset.Read(
&tinkio.ProtoKeysetFile{File: keysetFile},
masterKey)
f, err := os.Open(keysetFile)
if err != nil {
log.Fatal(err)
}
defer f.Close()
handle, err := keyset.Read(keyset.NewBinaryReader(f), masterKey)
if err != nil {
log.Fatal(err)
}
@@ -17,6 +17,7 @@ package cmd
import (
"fmt"
"log"
"os"

"github.com/google/tink/go/keyset"
"github.com/google/tink/go/signature"
@@ -66,7 +67,12 @@ var createCmd = &cobra.Command{
return err
}

return handle.Write(&tinkio.ProtoKeysetFile{File: keysetFile}, masterKey)
f, err := os.OpenFile(keysetFile, os.O_WRONLY|os.O_CREATE, 0600)
if err != nil {
return err
}
defer f.Close()
return handle.Write(keyset.NewBinaryWriter(f), masterKey)
},
}

@@ -98,9 +104,12 @@ The actual keys are not listed, only their corresponding metadata.
if err != nil {
log.Fatal(err)
}
handle, err := keyset.Read(
&tinkio.ProtoKeysetFile{File: keysetFile},
masterKey)
f, err := os.Open(keysetFile)
if err != nil {
log.Fatal(err)
}
defer f.Close()
handle, err := keyset.Read(keyset.NewBinaryReader(f), masterKey)
if err != nil {
log.Fatal(err)
}
@@ -19,6 +19,7 @@ import (
"encoding/base64"
"fmt"
"log"
"os"

"github.com/google/tink/go/keyset"
"github.com/google/tink/go/signature"
@@ -59,9 +60,12 @@ User email MUST match the OAuth account used to authorize the update.
if err != nil {
log.Fatal(err)
}
handle, err := keyset.Read(
&tinkio.ProtoKeysetFile{File: keysetFile},
masterKey)
f, err := os.Open(keysetFile)
if err != nil {
log.Fatal(err)
}
defer f.Close()
handle, err := keyset.Read(keyset.NewBinaryReader(f), masterKey)
if err != nil {
log.Fatal(err)
}

This file was deleted.

0 comments on commit 139f966

Please sign in to comment.
You can’t perform that action at this time.