Skip to content

Commit

Permalink
Merge pull request #118 from josephlr/proto
Browse files Browse the repository at this point in the history
Regenerate tpm.pb.go
  • Loading branch information
alexmwu authored Jun 25, 2021
2 parents c82ef44 + efc5316 commit c172233
Show file tree
Hide file tree
Showing 8 changed files with 215 additions and 188 deletions.
1 change: 1 addition & 0 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ test_task:
modules_cache:
fingerprint_script: cat go.sum
folder: $GOPATH/pkg/mod
gen_script: go generate ./...
build_script: go build -v ./...
windows_build_script: GOOS=windows go build -v ./...
test_script: go test -v ./...
Expand Down
5 changes: 4 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM golang:latest
# We need OpenSSL headers to build the simulator
RUN apt-get update && apt-get install -y \
libssl-dev libtspi-dev \
libssl-dev libtspi-dev protobuf-compiler \
&& rm -rf /var/lib/apt/lists/*
# We need golangci-lint for linting
ARG VERSION=1.23.7
Expand All @@ -14,3 +14,6 @@ RUN curl -SL \
--strip-components=1 \
--wildcards "*/golangci-lint" \
&& rm golangci.tar.gz
# We need protoc-gen-go to generate code
ENV GOBIN=/usr/local/bin/
RUN go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
10 changes: 5 additions & 5 deletions client/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ func (k *Key) Seal(sensitive []byte, opts SealOpts) (*tpmpb.SealedBytes, error)
}

for pcrNum := range pcrs.GetPcrs() {
sb.Pcrs = append(sb.Pcrs, int32(pcrNum))
sb.Pcrs = append(sb.Pcrs, pcrNum)
}
sb.Hash = pcrs.GetHash()
sb.Srk = tpmpb.ObjectType(k.pubArea.Type)
Expand Down Expand Up @@ -306,8 +306,8 @@ func (k *Key) Unseal(in *tpmpb.SealedBytes, opts CertifyOpts) ([]byte, error) {
k.rw,
k.Handle(),
/*parentPassword=*/ "",
in.Pub,
in.Priv)
in.GetPub(),
in.GetPriv())
if err != nil {
return nil, fmt.Errorf("failed to load sealed object: %w", err)
}
Expand Down Expand Up @@ -359,8 +359,8 @@ func (k *Key) Unseal(in *tpmpb.SealedBytes, opts CertifyOpts) ([]byte, error) {
}
}

sel := tpm2.PCRSelection{Hash: tpm2.Algorithm(in.Hash)}
for _, pcr := range in.Pcrs {
sel := tpm2.PCRSelection{Hash: tpm2.Algorithm(in.GetHash())}
for _, pcr := range in.GetPcrs() {
sel.PCRs = append(sel.PCRs, int(pcr))
}

Expand Down
14 changes: 0 additions & 14 deletions proto/README.md

This file was deleted.

25 changes: 25 additions & 0 deletions proto/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Package proto contains protocol buffers that are exchanged between the client
// and server. Note, some of these types have additional helper methods.
//
// Generating Protocol Buffer Code
//
// Anytime the Protocol Buffer defintions change, the generated Go code must be
// regenerated. This can be done with "go generate". Just run:
// go generate ./...
//
// Alternatively, you can manually invoke protoc yourself. In the root of this project, run:
// protoc --go_out=. --go_opt=module=github.com/google/go-tpm-tools **/*.proto
//
// Upstream documentation:
// https://developers.google.com/protocol-buffers/docs/reference/go-generated
//
// Code Generation Dependencies
//
// To generate the Go code, your system must have "protoc" installed. See:
// https://github.com/protocolbuffers/protobuf#protocol-compiler-installation
//
// The "protoc-gen-go" tool must also be installed. To install it, run:
// go install google.golang.org/protobuf/cmd/protoc-gen-go
package proto

//go:generate protoc --go_out=. --go_opt=module=github.com/google/go-tpm-tools/proto tpm.proto
2 changes: 0 additions & 2 deletions proto/pcrs.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Package proto contains protocol buffers that are exchanged between the client
// and server. Note, some of these types have additional helper methods.
package proto

import (
Expand Down
Loading

0 comments on commit c172233

Please sign in to comment.