Skip to content
Open
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
1 change: 1 addition & 0 deletions .bazelversion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
8.4.1
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
bazel-*
launcher/launcher/launcher
*.test
*.test.exe
Expand Down
20 changes: 20 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

load("@bazel_gazelle//:def.bzl", "gazelle")

# gazelle:go_grpc_compilers @io_bazel_rules_go//proto:go_grpc_v2, @io_bazel_rules_go//proto:go_proto
# gazelle:proto_import_prefix github.com/google/go-tpm-tools
# gazelle:prefix github.com/google/go-tpm-tools
gazelle(name = "gazelle")
20 changes: 20 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module(
name = "go-tpm-tools",
version = "0.0.0",
)

bazel_dep(name = "gazelle", version = "0.45.0", repo_name = "bazel_gazelle")
bazel_dep(name = "grpc", version = "1.74.1", repo_name = "com_github_grpc_grpc")
bazel_dep(name = "protobuf", version = "33.1", repo_name = "com_google_protobuf")
bazel_dep(name = "rules_cc", version = "0.2.14", repo_name = "io_bazel_rules_cc")
bazel_dep(name = "rules_go", version = "0.59.0", repo_name = "io_bazel_rules_go")
bazel_dep(name = "openssl", version = "3.3.1.bcr.9", repo_name = "com_github_openssl_openssl")

go_sdk = use_extension("@io_bazel_rules_go//go:extensions.bzl", "go_sdk")
go_sdk.download(version = "1.25.1")

go_deps = use_extension("@bazel_gazelle//:extensions.bzl", "go_deps")
go_deps.from_file(go_mod = "//:go.mod")
use_repo(go_deps, "com_github_google_go_attestation", "com_github_google_go_cmp", "com_github_google_go_configfs_tsm", "com_github_google_go_eventlog", "com_github_google_go_sev_guest", "com_github_google_go_tdx_guest", "com_github_google_go_tpm", "com_github_google_logger", "org_golang_google_protobuf")

go_deps_dev = use_extension("@bazel_gazelle//:extensions.bzl", "go_deps", dev_dependency = True)
41 changes: 41 additions & 0 deletions cel/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
name = "cel",
srcs = [
"canonical_eventlog.go",
"cos_tlv.go",
],
importpath = "github.com/google/go-tpm-tools/cel",
visibility = ["//visibility:public"],
deps = [
"//client",
"@com_github_google_go_configfs_tsm//configfs/configfsi",
"@com_github_google_go_eventlog//register",
"@com_github_google_go_tdx_guest//rtmr",
"@com_github_google_go_tpm//legacy/tpm2",
"@com_github_google_go_tpm//tpmutil",
],
)

go_test(
name = "cel_test",
srcs = [
"canonical_eventlog_test.go",
"cos_tlv_test.go",
],
embed = [":cel"],
deps = [
"//client",
"//internal/test",
"//proto/attest",
"@com_github_google_go_cmp//cmp",
"@com_github_google_go_configfs_tsm//configfs/configfsi",
"@com_github_google_go_configfs_tsm//configfs/fakertmr",
"@com_github_google_go_configfs_tsm//rtmr",
"@com_github_google_go_eventlog//proto/state",
"@com_github_google_go_eventlog//register",
"@com_github_google_go_tpm//legacy/tpm2",
"@com_github_google_go_tpm//tpmutil",
],
)
72 changes: 72 additions & 0 deletions client/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
name = "client",
srcs = [
"attest.go",
"close.go",
"eventlog.go",
"eventlog_linux.go",
"eventlog_other.go",
"handles.go",
"import.go",
"import_certify.go",
"keys.go",
"pcr.go",
"session.go",
"signer.go",
"template.go",
],
importpath = "github.com/google/go-tpm-tools/client",
visibility = ["//visibility:public"],
deps = [
"//internal",
"//proto/attest",
"//proto/tpm",
"@com_github_google_go_sev_guest//abi",
"@com_github_google_go_sev_guest//client",
"@com_github_google_go_tdx_guest//client",
"@com_github_google_go_tdx_guest//client/linuxabi",
"@com_github_google_go_tdx_guest//proto/tdx",
"@com_github_google_go_tpm//legacy/tpm2",
"@com_github_google_go_tpm//tpm2",
"@com_github_google_go_tpm//tpm2/transport",
"@com_github_google_go_tpm//tpmutil",
],
)

go_test(
name = "client_test",
srcs = [
"attest_network_test.go",
"attest_test.go",
"example_test.go",
"handles_test.go",
"import_certify_test.go",
"keys_test.go",
"pcr_test.go",
"quote_test.go",
"seal_test.go",
"signer_test.go",
],
embed = [":client"],
deps = [
"//internal",
"//internal/test",
"//proto/attest",
"//proto/tpm",
"//server",
"//simulator",
"@com_github_google_go_attestation//attest",
"@com_github_google_go_sev_guest//testing",
"@com_github_google_go_sev_guest//testing/client",
"@com_github_google_go_tdx_guest//testing",
"@com_github_google_go_tdx_guest//testing/client",
"@com_github_google_go_tdx_guest//testing/testdata",
"@com_github_google_go_tpm//legacy/tpm2",
"@com_github_google_go_tpm//tpm2",
"@com_github_google_go_tpm//tpm2/transport",
"@com_github_google_go_tpm//tpmutil",
"@org_golang_google_protobuf//proto",
],
)
104 changes: 104 additions & 0 deletions cmd/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
name = "cmd",
srcs = [
"attest.go",
"attest_svsm.go",
"fake_cloudlogging_server.go",
"flags.go",
"flush.go",
"open.go",
"open_other.go",
"open_windows.go",
"pubkey.go",
"read.go",
"register.go",
"root.go",
"seal.go",
"token.go",
"verify.go",
"verify_sev.go",
"verify_svsm.go",
"verify_tdx.go",
],
importpath = "github.com/google/go-tpm-tools/cmd",
visibility = ["//visibility:public"],
deps = [
"//client",
"//internal",
"//proto/attest",
"//proto/tpm",
"//server",
"//verifier",
"//verifier/models",
"//verifier/util",
"@com_github_golang_jwt_jwt_v4//:go_default_library",
"@com_github_golang_protobuf//ptypes/timestamp",
"@com_github_google_gce_tcb_verifier//extract:go_default_library",
"@com_github_google_gce_tcb_verifier//proto/endorsement:go_default_library",
"@com_github_google_gce_tcb_verifier//verify:go_default_library",
"@com_github_google_gce_tcb_verifier_gcetcbendorsement//:go_default_library",
"@com_github_google_go_configfs_tsm//configfs/configfsi",
"@com_github_google_go_configfs_tsm//configfs/linuxtsm",
"@com_github_google_go_configfs_tsm//report",
"@com_github_google_go_sev_guest//abi",
"@com_github_google_go_sev_guest//proto/sevsnp",
"@com_github_google_go_sev_guest//validate",
"@com_github_google_go_sev_guest//verify",
"@com_github_google_go_sev_guest//verify/trust",
"@com_github_google_go_tdx_guest//abi",
"@com_github_google_go_tdx_guest//proto/tdx",
"@com_github_google_go_tdx_guest//validate",
"@com_github_google_go_tdx_guest//verify",
"@com_github_google_go_tpm//legacy/tpm2",
"@com_github_google_go_tpm//tpm2",
"@com_github_google_go_tpm//tpm2/transport",
"@com_github_google_go_tpm//tpmutil",
"@com_github_spf13_cobra//:go_default_library",
"@com_google_cloud_go_compute_metadata//:go_default_library",
"@com_google_cloud_go_logging//:go_default_library",
"@com_google_cloud_go_logging//apiv2/loggingpb:go_default_library",
"@org_golang_google_api//option:go_default_library",
"@org_golang_google_grpc//:grpc",
"@org_golang_google_grpc//credentials/insecure",
"@org_golang_google_protobuf//encoding/prototext",
"@org_golang_google_protobuf//proto",
],
)

go_test(
name = "cmd_test",
srcs = [
"attest_test.go",
"flush_test.go",
"seal_test.go",
"svsm_test.go",
"token_test.go",
"verify_test.go",
],
embed = [":cmd"],
deps = [
"//client",
"//internal/test",
"//proto/attest",
"//verifier/util",
"@com_github_google_gce_tcb_verifier//proto/endorsement:go_default_library",
"@com_github_google_go_configfs_tsm//configfs/configfsi",
"@com_github_google_go_configfs_tsm//configfs/faketsm",
"@com_github_google_go_sev_guest//abi",
"@com_github_google_go_sev_guest//proto/sevsnp",
"@com_github_google_go_sev_guest//testing",
"@com_github_google_go_sev_guest//testing/client",
"@com_github_google_go_sev_guest//validate",
"@com_github_google_go_tdx_guest//testing",
"@com_github_google_go_tdx_guest//testing/client",
"@com_github_google_go_tdx_guest//testing/testdata",
"@com_github_google_go_tpm//legacy/tpm2",
"@com_github_google_go_tpm//tpmutil",
"@org_golang_google_protobuf//encoding/prototext",
"@org_golang_google_protobuf//proto",
"@org_golang_x_oauth2//:go_default_library",
"@org_golang_x_oauth2//google:go_default_library",
],
)
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require (
github.com/google/go-tdx-guest v0.3.2-0.20241009005452-097ee70d0843
github.com/google/go-tpm v0.9.6
github.com/google/logger v1.1.1
google.golang.org/protobuf v1.35.1
google.golang.org/protobuf v1.36.3
)

require (
Expand Down
32 changes: 32 additions & 0 deletions internal/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
name = "internal",
srcs = [
"cert.go",
"pcrs.go",
"public.go",
"quote.go",
],
importpath = "github.com/google/go-tpm-tools/internal",
visibility = ["//:__subpackages__"],
deps = [
"//proto/tpm",
"@com_github_google_go_tpm//legacy/tpm2",
"@com_github_google_go_tpm//tpmutil",
],
)

go_test(
name = "internal_test",
srcs = [
"cert_test.go",
"pcrs_test.go",
],
embed = [":internal"],
deps = [
"//internal/test",
"//proto/tpm",
"@com_github_google_go_tpm//legacy/tpm2",
],
)
59 changes: 59 additions & 0 deletions internal/test/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
name = "test",
srcs = [
"load_random_external_key.go",
"test_cert.go",
"test_data.go",
"test_other.go",
"test_tpm.go",
"test_windows.go",
],
embedsrcs = [
"attestations/gce-cos-85-no-nonce.pb",
"attestations/gce-cos-85-nonce9009.pb",
"certificates/pca_tpm_ecc_enc_cert.pem",
"certificates/pca_tpm_ecc_sign_cert.pem",
"certificates/pca_tpm_rsa_enc_cert.pem",
"certificates/pca_tpm_rsa_sign_cert.pem",
"certificates/uca_tpm_ecc_enc_cert.pem",
"certificates/uca_tpm_ecc_sign_cert.pem",
"certificates/uca_tpm_rsa_enc_cert.pem",
"certificates/uca_tpm_rsa_sign_cert.pem",
"eventlogs/arch-linux-workstation.bin",
"eventlogs/confidential-gke-debug-251000_eventlog.bin",
"eventlogs/cos-101-amd-sev.bin",
"eventlogs/cos-85-amd-sev.bin",
"eventlogs/cos-93-amd-sev.bin",
"eventlogs/debian-10.bin",
"eventlogs/eventlogwithsp800155.bin",
"eventlogs/gdc-host.bin",
"eventlogs/glinux-alex.bin",
"eventlogs/rhel8-uefi.bin",
"eventlogs/ubuntu-1804-amd-sev.bin",
"eventlogs/ubuntu-2104-no-dbx.bin",
"eventlogs/ubuntu-2104-no-secure-boot.bin",
"eventlogs/ubuntu-2404-amd-sevsnp.bin",
"tdx_test_files/tdxReportData.bin",
],
importpath = "github.com/google/go-tpm-tools/internal/test",
visibility = ["//:__subpackages__"],
deps = [
"//simulator",
"@com_github_google_go_attestation//attest",
"@com_github_google_go_tpm//legacy/tpm2",
"@com_github_google_go_tpm//tpm2",
"@com_github_google_go_tpm//tpmutil",
],
)

go_test(
name = "test_test",
srcs = ["simulate_test.go"],
embed = [":test"],
deps = [
"//client",
"//server",
],
)
Loading