Skip to content

Commit

Permalink
update from tpmtools -> client
Browse files Browse the repository at this point in the history
  • Loading branch information
salrashid123 committed Mar 28, 2022
1 parent 2dffe10 commit e1cb084
Show file tree
Hide file tree
Showing 8 changed files with 1,142 additions and 29 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ $ go run symmetric/main.go --mode=unseal --sealedDataFile=sealed.dat --logtostde
F1006 17:25:15.127396 4319 main.go:147] Unable to Import sealed data: unseal failed: session 1, error code 0x1d : a policy check failed
```

- Attempt to import asymmetric `sealded.dat`
- Attempt to import asymmetric `sealed.dat`

```bash
$ go run asymmetric/import/main.go --importSigningKeyFile=sealed.dat \
Expand Down
8 changes: 4 additions & 4 deletions asymmetric/import/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (

"github.com/golang/glog"
"github.com/golang/protobuf/proto"
pb "github.com/google/go-tpm-tools/proto"
"github.com/google/go-tpm-tools/tpm2tools"
"github.com/google/go-tpm-tools/client"
pb "github.com/google/go-tpm-tools/proto/tpm"
"github.com/google/go-tpm/tpm2"
"github.com/google/go-tpm/tpmutil"
)
Expand Down Expand Up @@ -62,7 +62,7 @@ func importSigningKey(tpmPath string, importSigningKeyFile string, keyHandleOutp

totalHandles := 0
for _, handleType := range handleNames[*flush] {
handles, err := tpm2tools.Handles(rwc, handleType)
handles, err := client.Handles(rwc, handleType)
if err != nil {
return fmt.Errorf("getting handles: %v", err)
}
Expand All @@ -84,7 +84,7 @@ func importSigningKey(tpmPath string, importSigningKeyFile string, keyHandleOutp
glog.V(2).Infof("Using PCR: %i %s", bindPCRValue, hex.EncodeToString(pcr23))
}
glog.V(2).Infof("======= Loading EndorsementKeyRSA ========")
ek, err := tpm2tools.EndorsementKeyRSA(rwc)
ek, err := client.EndorsementKeyRSA(rwc)
if err != nil {
return fmt.Errorf("Unable to get EndorsementKeyRSA: %v", err)
}
Expand Down
6 changes: 3 additions & 3 deletions asymmetric/seal/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (

"github.com/golang/glog"
"github.com/golang/protobuf/proto"
pb "github.com/google/go-tpm-tools/proto"
pb "github.com/google/go-tpm-tools/proto/tpm"

"github.com/google/go-tpm-tools/server"
)
Expand Down Expand Up @@ -126,11 +126,11 @@ func createSigningKeyImportBlob(ekPubFile string, rsaKeyFile string, sealedOutpu
glog.V(2).Infof("Signature: %s", sig)

glog.V(2).Infof("======= CreateSigningKeyImportBlob for RSA Key: ========")
var pcrs *pb.Pcrs
var pcrs *pb.PCRs
if len(pcrMap) == 0 {
pcrs = nil
} else {
pcrs = &pb.Pcrs{Hash: pb.HashAlgo_SHA256, Pcrs: pcrMap}
pcrs = &pb.PCRs{Hash: pb.HashAlgo_SHA256, Pcrs: pcrMap}
}
blob, err := server.CreateSigningKeyImportBlob(ekPub, signingKey, pcrs)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions asymmetric/sign/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"encoding/base64"

"github.com/golang/glog"
"github.com/google/go-tpm-tools/tpm2tools"
"github.com/google/go-tpm-tools/client"
"github.com/google/go-tpm/tpm2"
"github.com/google/go-tpm/tpmutil"
)
Expand Down Expand Up @@ -45,7 +45,7 @@ func main() {

totalHandles := 0
for _, handleType := range handleNames["all"] {
handles, err := tpm2tools.Handles(rwc, handleType)
handles, err := client.Handles(rwc, handleType)
if err != nil {
glog.Fatalf("getting handles: %v", err)
}
Expand Down
19 changes: 15 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
module main

go 1.15
go 1.17

require (
github.com/gogo/protobuf v1.3.1 // indirect
github.com/google/go-tpm v0.3.1 // indirect
github.com/google/go-tpm-tools v0.2.0 // indirect
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
github.com/golang/protobuf v1.5.2
github.com/google/go-tpm v0.3.3
github.com/google/go-tpm-tools v0.3.6

)

require (
github.com/google/certificate-transparency-go v1.1.2 // indirect
github.com/google/go-attestation v0.4.3 // indirect
github.com/google/go-tspi v0.2.1-0.20190423175329-115dea689aad // indirect
golang.org/x/crypto v0.0.0-20210314154223-e6e6c4f2bb5b // indirect
golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069 // indirect
google.golang.org/protobuf v1.27.1 // indirect
)
1,115 changes: 1,108 additions & 7 deletions go.sum

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pcr_utils/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"flag"

"github.com/golang/glog"
"github.com/google/go-tpm-tools/tpm2tools"
"github.com/google/go-tpm-tools/client"
"github.com/google/go-tpm/tpm2"
"github.com/google/go-tpm/tpmutil"
)
Expand Down Expand Up @@ -49,7 +49,7 @@ func main() {

totalHandles := 0
for _, handleType := range handleNames[*flush] {
handles, err := tpm2tools.Handles(rwc, handleType)
handles, err := client.Handles(rwc, handleType)
if err != nil {
glog.Fatalf("getting handles: %v", err)
}
Expand Down
13 changes: 7 additions & 6 deletions symmetric/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ import (

//"github.com/gogo/protobuf/proto"
"github.com/golang/glog"
pb "github.com/google/go-tpm-tools/proto"
"github.com/google/go-tpm-tools/client"

pb "github.com/google/go-tpm-tools/proto/tpm"
"github.com/google/go-tpm-tools/server"
"github.com/google/go-tpm-tools/tpm2tools"
"github.com/google/go-tpm/tpm2"
)

Expand Down Expand Up @@ -79,11 +80,11 @@ func main() {
pub, _ := x509.ParsePKIXPublicKey(block.Bytes)

mySecret := []byte(*secret)
var pcrs *pb.Pcrs
var pcrs *pb.PCRs
if len(pcrMap) == 0 {
pcrs = nil
} else {
pcrs = &pb.Pcrs{Hash: pb.HashAlgo_SHA256, Pcrs: pcrMap}
pcrs = &pb.PCRs{Hash: pb.HashAlgo_SHA256, Pcrs: pcrMap}
}
blob, err := server.CreateImportBlob(pub, mySecret, pcrs)
if err != nil {
Expand Down Expand Up @@ -116,7 +117,7 @@ func main() {

totalHandles := 0
for _, handleType := range handleNames[*flush] {
handles, err := tpm2tools.Handles(rwc, handleType)
handles, err := client.Handles(rwc, handleType)
if err != nil {
glog.Fatalf("getting handles: %v", err)
}
Expand All @@ -129,7 +130,7 @@ func main() {
}
}

ek, err := tpm2tools.EndorsementKeyRSA(rwc)
ek, err := client.EndorsementKeyRSA(rwc)
if err != nil {
glog.Fatalf("Unable to load EK from TPM: %v", err)
}
Expand Down

0 comments on commit e1cb084

Please sign in to comment.