Skip to content

Commit efbcce3

Browse files
committed
PoC for go-nvtrust
1 parent c90d686 commit efbcce3

File tree

13 files changed

+567
-247
lines changed

13 files changed

+567
-247
lines changed

go.work

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
go 1.23.0
1+
go 1.24.0
2+
3+
toolchain go1.24.8
24

35
use (
46
.

go.work.sum

Lines changed: 271 additions & 8 deletions
Large diffs are not rendered by default.

launcher/agent/agent.go

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"bytes"
1010
"context"
1111
"crypto"
12+
"crypto/rand"
1213
"encoding/base64"
1314
"fmt"
1415
"io"
@@ -24,6 +25,8 @@ import (
2425
tg "github.com/google/go-tdx-guest/client"
2526
tlabi "github.com/google/go-tdx-guest/client/linuxabi"
2627

28+
"github.com/NVIDIA/go-nvml/pkg/nvml"
29+
"github.com/confidentsecurity/go-nvtrust/pkg/gonvtrust/gpu"
2730
"github.com/google/go-tpm-tools/cel"
2831
"github.com/google/go-tpm-tools/client"
2932
"github.com/google/go-tpm-tools/internal"
@@ -223,6 +226,13 @@ func (a *agent) AttestWithClient(ctx context.Context, opts AttestAgentOpts, clie
223226
v.IntermediateCerts = certChain
224227
v.AkCert = a.fetchedAK.CertDERBytes()
225228
req.TDCCELAttestation = v
229+
// log TDCCEL attestation data
230+
a.logger.Info(fmt.Sprintf("CCEL data: [%s]\n", base64.StdEncoding.EncodeToString(v.CcelData)))
231+
a.logger.Info(fmt.Sprintf("CCEL ACPI table data: [%s]\n", base64.StdEncoding.EncodeToString(v.CcelAcpiTable)))
232+
a.logger.Info(fmt.Sprintf("TDX quote: [%s]\n", base64.StdEncoding.EncodeToString(v.TdQuote)))
233+
a.logger.Info(fmt.Sprintf("CEL data: [%s]\n", base64.StdEncoding.EncodeToString(v.CanonicalEventLog)))
234+
// collect GPU attestation
235+
collectGpuAttestation(a.logger)
226236
default:
227237
return nil, fmt.Errorf("received an unsupported attestation type! %v", v)
228238
}
@@ -406,3 +416,51 @@ func (c *sigsCache) get() []oci.Signature {
406416
defer c.mu.RUnlock()
407417
return c.items
408418
}
419+
420+
func collectGpuAttestation(logger logging.Logger) {
421+
handler := &gpu.DefaultNVMLHandler{}
422+
gpuAdmin, err := gpu.NewNvmlGPUAdmin(handler)
423+
if err != nil {
424+
logger.Error(fmt.Sprintf("Failed to create GPU admin: %v\n", err))
425+
}
426+
defer gpuAdmin.Shutdown()
427+
428+
// Generate a random nonce (32 bytes)
429+
nonce := make([]byte, 32)
430+
if _, err := rand.Read(nonce); err != nil {
431+
logger.Error(fmt.Sprintf("Failed to generate nonce: %v\n", err))
432+
}
433+
434+
deviceInfos, err := gpuAdmin.CollectEvidence(nonce)
435+
if err != nil {
436+
logger.Error(fmt.Sprintf("Failed to collect GPU evidence\n: %v", err))
437+
}
438+
439+
for i, deviceInfo := range deviceInfos {
440+
device, ret := handler.DeviceGetHandleByIndex(i)
441+
if ret != nvml.SUCCESS {
442+
logger.Error(fmt.Sprintf("Failed to get GPU device: %v\n", nvml.ErrorString(ret)))
443+
}
444+
uuid, ret := device.GetUUID()
445+
if ret != nvml.SUCCESS {
446+
logger.Error(fmt.Sprintf("Failed to get UUID: %v\n", nvml.ErrorString(ret)))
447+
}
448+
449+
vbiosVersion, ret := device.GetVbiosVersion()
450+
if ret != nvml.SUCCESS {
451+
logger.Error(fmt.Sprintf("Failed to get vbios version: %v\n", nvml.ErrorString(ret)))
452+
}
453+
454+
driverVersion, ret := handler.SystemGetDriverVersion()
455+
if ret != nvml.SUCCESS {
456+
logger.Error(fmt.Sprintf("Failed to get vbios version: %v\n", nvml.ErrorString(ret)))
457+
}
458+
logger.Info(fmt.Sprintf("Found GPU UUID [%s] at index %d\n", uuid, i))
459+
logger.Info(fmt.Sprintf("Found GPU VBIOS version [%s] at index %d\n", vbiosVersion, i))
460+
logger.Info(fmt.Sprintf("Found GPU DRIVER version [%s] at index %d\n", driverVersion, i))
461+
logger.Info(fmt.Sprintf("Found GPU Arch [%s] at index %d\n", deviceInfo.Arch(), i))
462+
logger.Info("Found GPU attetation data [%s] at index %d\n", base64.StdEncoding.EncodeToString(deviceInfo.AttestationReport()), i)
463+
b64CertChainData, _ := deviceInfo.Certificate().EncodeBase64()
464+
logger.Info("Found GPU attestation cert chain data [%s] at index %d\n", b64CertChainData, i)
465+
}
466+
}

launcher/go.mod

Lines changed: 36 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
module github.com/google/go-tpm-tools/launcher
22

3-
go 1.23.0
3+
go 1.24.0
4+
5+
toolchain go1.24.8
46

57
require (
6-
cloud.google.com/go/compute/metadata v0.5.2
7-
cloud.google.com/go/logging v1.12.0
8+
cloud.google.com/go/compute/metadata v0.8.0
9+
cloud.google.com/go/logging v1.13.0
810
cos.googlesource.com/cos/tools.git v0.0.0-20250414225215-0cf736c0714c
11+
github.com/NVIDIA/go-nvml v0.13.0-1
912
github.com/cenkalti/backoff/v4 v4.3.0
13+
github.com/confidentsecurity/go-nvtrust v0.2.2
1014
github.com/containerd/containerd v1.7.23
1115
github.com/containerd/containerd/v2 v2.0.1
1216
github.com/coreos/go-systemd/v22 v22.5.0
1317
github.com/golang-jwt/jwt/v4 v4.5.1
14-
github.com/google/go-cmp v0.6.0
18+
github.com/google/go-cmp v0.7.0
1519
github.com/google/go-configfs-tsm v0.3.3-0.20240919001351-b4b5b84fdcbc
1620
github.com/google/go-tdx-guest v0.3.2-0.20241009005452-097ee70d0843
1721
github.com/google/go-tpm v0.9.0
@@ -20,18 +24,18 @@ require (
2024
github.com/opencontainers/go-digest v1.0.0
2125
github.com/opencontainers/image-spec v1.1.0
2226
github.com/opencontainers/runtime-spec v1.2.0
23-
golang.org/x/oauth2 v0.23.0
24-
google.golang.org/api v0.205.0
25-
google.golang.org/genproto/googleapis/api v0.0.0-20241015192408-796eee8c2d53
26-
google.golang.org/protobuf v1.35.1
27+
golang.org/x/oauth2 v0.30.0
28+
google.golang.org/api v0.247.0
29+
google.golang.org/genproto/googleapis/api v0.0.0-20250818200422-3122310a409c
30+
google.golang.org/protobuf v1.36.7
2731
)
2832

2933
require (
30-
cloud.google.com/go v0.116.0 // indirect
31-
cloud.google.com/go/auth v0.10.1 // indirect
32-
cloud.google.com/go/auth/oauth2adapt v0.2.5 // indirect
33-
cloud.google.com/go/confidentialcomputing v1.8.0 // indirect
34-
cloud.google.com/go/longrunning v0.6.1 // indirect
34+
cloud.google.com/go v0.120.0 // indirect
35+
cloud.google.com/go/auth v0.16.4 // indirect
36+
cloud.google.com/go/auth/oauth2adapt v0.2.8 // indirect
37+
cloud.google.com/go/confidentialcomputing v1.10.1 // indirect
38+
cloud.google.com/go/longrunning v0.6.7 // indirect
3539
github.com/AdaLogics/go-fuzz-headers v0.0.0-20240806141605-e8a1dd7889d6 // indirect
3640
github.com/AdamKorcz/go-118-fuzz-build v0.0.0-20231105174938-2b5cbb29f3e2 // indirect
3741
github.com/Microsoft/go-winio v0.6.2 // indirect
@@ -49,23 +53,21 @@ require (
4953
github.com/distribution/reference v0.6.0 // indirect
5054
github.com/docker/go-events v0.0.0-20190806004212-e31b211e4f1c // indirect
5155
github.com/felixge/httpsnoop v1.0.4 // indirect
52-
github.com/go-logr/logr v1.4.2 // indirect
56+
github.com/go-logr/logr v1.4.3 // indirect
5357
github.com/go-logr/stdr v1.2.2 // indirect
5458
github.com/godbus/dbus/v5 v5.1.0 // indirect
5559
github.com/gogo/protobuf v1.3.2 // indirect
5660
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
57-
github.com/golang/protobuf v1.5.4 // indirect
5861
github.com/google/certificate-transparency-go v1.1.2 // indirect
59-
github.com/google/gce-tcb-verifier v0.2.3-0.20240905212129-12f728a62786 // indirect
6062
github.com/google/go-attestation v0.5.1 // indirect
6163
github.com/google/go-eventlog v0.0.2-0.20241003021507-01bb555f7cba // indirect
6264
github.com/google/go-sev-guest v0.13.0 // indirect
6365
github.com/google/go-tspi v0.3.0 // indirect
6466
github.com/google/logger v1.1.1 // indirect
65-
github.com/google/s2a-go v0.1.8 // indirect
67+
github.com/google/s2a-go v0.1.9 // indirect
6668
github.com/google/uuid v1.6.0 // indirect
67-
github.com/googleapis/enterprise-certificate-proxy v0.3.4 // indirect
68-
github.com/googleapis/gax-go/v2 v2.13.0 // indirect
69+
github.com/googleapis/enterprise-certificate-proxy v0.3.6 // indirect
70+
github.com/googleapis/gax-go/v2 v2.15.0 // indirect
6971
github.com/klauspost/compress v1.17.11 // indirect
7072
github.com/moby/locker v1.0.1 // indirect
7173
github.com/moby/sys/mountinfo v0.7.2 // indirect
@@ -77,22 +79,22 @@ require (
7779
github.com/pkg/errors v0.9.1 // indirect
7880
github.com/sirupsen/logrus v1.9.3 // indirect
7981
go.opencensus.io v0.24.0 // indirect
80-
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.56.0 // indirect
81-
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.56.0 // indirect
82-
go.opentelemetry.io/otel v1.31.0 // indirect
83-
go.opentelemetry.io/otel/metric v1.31.0 // indirect
84-
go.opentelemetry.io/otel/trace v1.31.0 // indirect
82+
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
83+
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.61.0 // indirect
84+
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.61.0 // indirect
85+
go.opentelemetry.io/otel v1.36.0 // indirect
86+
go.opentelemetry.io/otel/metric v1.36.0 // indirect
87+
go.opentelemetry.io/otel/trace v1.36.0 // indirect
8588
go.uber.org/multierr v1.11.0 // indirect
86-
golang.org/x/crypto v0.35.0 // indirect
87-
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc // indirect
88-
golang.org/x/net v0.36.0 // indirect
89-
golang.org/x/sync v0.11.0 // indirect
90-
golang.org/x/sys v0.30.0 // indirect
91-
golang.org/x/text v0.22.0 // indirect
92-
golang.org/x/time v0.7.0 // indirect
93-
google.golang.org/genproto v0.0.0-20241021214115-324edc3d5d38 // indirect
94-
google.golang.org/genproto/googleapis/rpc v0.0.0-20241021214115-324edc3d5d38 // indirect
95-
google.golang.org/grpc v1.67.1 // indirect
89+
golang.org/x/crypto v0.41.0 // indirect
90+
golang.org/x/net v0.43.0 // indirect
91+
golang.org/x/sync v0.16.0 // indirect
92+
golang.org/x/sys v0.35.0 // indirect
93+
golang.org/x/text v0.28.0 // indirect
94+
golang.org/x/time v0.12.0 // indirect
95+
google.golang.org/genproto v0.0.0-20250603155806-513f23925822 // indirect
96+
google.golang.org/genproto/googleapis/rpc v0.0.0-20250818200422-3122310a409c // indirect
97+
google.golang.org/grpc v1.74.2 // indirect
9698
)
9799

98100
replace (

0 commit comments

Comments
 (0)