Skip to content

Commit 540c906

Browse files
committed
Preliminary Bazel build support.
1 parent d94cf98 commit 540c906

File tree

42 files changed

+1226
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1226
-1
lines changed

.bazelversion

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
8.4.1

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
bazel-*
12
launcher/launcher/launcher
23
*.test
34
*.test.exe

BUILD.bazel

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Copyright 2023 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
load("@bazel_gazelle//:def.bzl", "gazelle")
16+
17+
# gazelle:go_grpc_compilers @io_bazel_rules_go//proto:go_grpc_v2, @io_bazel_rules_go//proto:go_proto
18+
# gazelle:proto_import_prefix github.com/google/go-tpm-tools
19+
# gazelle:prefix github.com/google/go-tpm-tools
20+
gazelle(name = "gazelle")

MODULE.bazel

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
module(
2+
name = "go-tpm-tools",
3+
version = "0.0.0",
4+
)
5+
6+
bazel_dep(name = "gazelle", version = "0.45.0", repo_name = "bazel_gazelle")
7+
bazel_dep(name = "grpc", version = "1.74.1", repo_name = "com_github_grpc_grpc")
8+
bazel_dep(name = "protobuf", version = "33.1", repo_name = "com_google_protobuf")
9+
bazel_dep(name = "rules_cc", version = "0.2.14", repo_name = "io_bazel_rules_cc")
10+
bazel_dep(name = "rules_go", version = "0.59.0", repo_name = "io_bazel_rules_go")
11+
bazel_dep(name = "openssl", version = "3.3.1.bcr.9", repo_name = "com_github_openssl_openssl")
12+
13+
go_sdk = use_extension("@io_bazel_rules_go//go:extensions.bzl", "go_sdk")
14+
go_sdk.download(version = "1.25.1")
15+
16+
go_deps = use_extension("@bazel_gazelle//:extensions.bzl", "go_deps")
17+
go_deps.from_file(go_mod = "//:go.mod")
18+
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")
19+
20+
go_deps_dev = use_extension("@bazel_gazelle//:extensions.bzl", "go_deps", dev_dependency = True)

cel/BUILD.bazel

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
2+
3+
go_library(
4+
name = "cel",
5+
srcs = [
6+
"canonical_eventlog.go",
7+
"cos_tlv.go",
8+
],
9+
importpath = "github.com/google/go-tpm-tools/cel",
10+
visibility = ["//visibility:public"],
11+
deps = [
12+
"//client",
13+
"@com_github_google_go_configfs_tsm//configfs/configfsi",
14+
"@com_github_google_go_eventlog//register",
15+
"@com_github_google_go_tdx_guest//rtmr",
16+
"@com_github_google_go_tpm//legacy/tpm2",
17+
"@com_github_google_go_tpm//tpmutil",
18+
],
19+
)
20+
21+
go_test(
22+
name = "cel_test",
23+
srcs = [
24+
"canonical_eventlog_test.go",
25+
"cos_tlv_test.go",
26+
],
27+
embed = [":cel"],
28+
deps = [
29+
"//client",
30+
"//internal/test",
31+
"//proto/attest",
32+
"@com_github_google_go_cmp//cmp",
33+
"@com_github_google_go_configfs_tsm//configfs/configfsi",
34+
"@com_github_google_go_configfs_tsm//configfs/fakertmr",
35+
"@com_github_google_go_configfs_tsm//rtmr",
36+
"@com_github_google_go_eventlog//proto/state",
37+
"@com_github_google_go_eventlog//register",
38+
"@com_github_google_go_tpm//legacy/tpm2",
39+
"@com_github_google_go_tpm//tpmutil",
40+
],
41+
)

client/BUILD.bazel

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
2+
3+
go_library(
4+
name = "client",
5+
srcs = [
6+
"attest.go",
7+
"close.go",
8+
"eventlog.go",
9+
"eventlog_linux.go",
10+
"eventlog_other.go",
11+
"handles.go",
12+
"import.go",
13+
"import_certify.go",
14+
"keys.go",
15+
"pcr.go",
16+
"session.go",
17+
"signer.go",
18+
"template.go",
19+
],
20+
importpath = "github.com/google/go-tpm-tools/client",
21+
visibility = ["//visibility:public"],
22+
deps = [
23+
"//internal",
24+
"//proto/attest",
25+
"//proto/tpm",
26+
"@com_github_google_go_sev_guest//abi",
27+
"@com_github_google_go_sev_guest//client",
28+
"@com_github_google_go_tdx_guest//client",
29+
"@com_github_google_go_tdx_guest//client/linuxabi",
30+
"@com_github_google_go_tdx_guest//proto/tdx",
31+
"@com_github_google_go_tpm//legacy/tpm2",
32+
"@com_github_google_go_tpm//tpm2",
33+
"@com_github_google_go_tpm//tpm2/transport",
34+
"@com_github_google_go_tpm//tpmutil",
35+
],
36+
)
37+
38+
go_test(
39+
name = "client_test",
40+
srcs = [
41+
"attest_network_test.go",
42+
"attest_test.go",
43+
"example_test.go",
44+
"handles_test.go",
45+
"import_certify_test.go",
46+
"keys_test.go",
47+
"pcr_test.go",
48+
"quote_test.go",
49+
"seal_test.go",
50+
"signer_test.go",
51+
],
52+
embed = [":client"],
53+
deps = [
54+
"//internal",
55+
"//internal/test",
56+
"//proto/attest",
57+
"//proto/tpm",
58+
"//server",
59+
"//simulator",
60+
"@com_github_google_go_attestation//attest",
61+
"@com_github_google_go_sev_guest//testing",
62+
"@com_github_google_go_sev_guest//testing/client",
63+
"@com_github_google_go_tdx_guest//testing",
64+
"@com_github_google_go_tdx_guest//testing/client",
65+
"@com_github_google_go_tdx_guest//testing/testdata",
66+
"@com_github_google_go_tpm//legacy/tpm2",
67+
"@com_github_google_go_tpm//tpm2",
68+
"@com_github_google_go_tpm//tpm2/transport",
69+
"@com_github_google_go_tpm//tpmutil",
70+
"@org_golang_google_protobuf//proto",
71+
],
72+
)

cmd/BUILD.bazel

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
2+
3+
go_library(
4+
name = "cmd",
5+
srcs = [
6+
"attest.go",
7+
"attest_svsm.go",
8+
"fake_cloudlogging_server.go",
9+
"flags.go",
10+
"flush.go",
11+
"open.go",
12+
"open_other.go",
13+
"open_windows.go",
14+
"pubkey.go",
15+
"read.go",
16+
"register.go",
17+
"root.go",
18+
"seal.go",
19+
"token.go",
20+
"verify.go",
21+
"verify_sev.go",
22+
"verify_svsm.go",
23+
"verify_tdx.go",
24+
],
25+
importpath = "github.com/google/go-tpm-tools/cmd",
26+
visibility = ["//visibility:public"],
27+
deps = [
28+
"//client",
29+
"//internal",
30+
"//proto/attest",
31+
"//proto/tpm",
32+
"//server",
33+
"//verifier",
34+
"//verifier/models",
35+
"//verifier/util",
36+
"@com_github_golang_jwt_jwt_v4//:go_default_library",
37+
"@com_github_golang_protobuf//ptypes/timestamp",
38+
"@com_github_google_gce_tcb_verifier//extract:go_default_library",
39+
"@com_github_google_gce_tcb_verifier//proto/endorsement:go_default_library",
40+
"@com_github_google_gce_tcb_verifier//verify:go_default_library",
41+
"@com_github_google_gce_tcb_verifier_gcetcbendorsement//:go_default_library",
42+
"@com_github_google_go_configfs_tsm//configfs/configfsi",
43+
"@com_github_google_go_configfs_tsm//configfs/linuxtsm",
44+
"@com_github_google_go_configfs_tsm//report",
45+
"@com_github_google_go_sev_guest//abi",
46+
"@com_github_google_go_sev_guest//proto/sevsnp",
47+
"@com_github_google_go_sev_guest//validate",
48+
"@com_github_google_go_sev_guest//verify",
49+
"@com_github_google_go_sev_guest//verify/trust",
50+
"@com_github_google_go_tdx_guest//abi",
51+
"@com_github_google_go_tdx_guest//proto/tdx",
52+
"@com_github_google_go_tdx_guest//validate",
53+
"@com_github_google_go_tdx_guest//verify",
54+
"@com_github_google_go_tpm//legacy/tpm2",
55+
"@com_github_google_go_tpm//tpm2",
56+
"@com_github_google_go_tpm//tpm2/transport",
57+
"@com_github_google_go_tpm//tpmutil",
58+
"@com_github_spf13_cobra//:go_default_library",
59+
"@com_google_cloud_go_compute_metadata//:go_default_library",
60+
"@com_google_cloud_go_logging//:go_default_library",
61+
"@com_google_cloud_go_logging//apiv2/loggingpb:go_default_library",
62+
"@org_golang_google_api//option:go_default_library",
63+
"@org_golang_google_grpc//:grpc",
64+
"@org_golang_google_grpc//credentials/insecure",
65+
"@org_golang_google_protobuf//encoding/prototext",
66+
"@org_golang_google_protobuf//proto",
67+
],
68+
)
69+
70+
go_test(
71+
name = "cmd_test",
72+
srcs = [
73+
"attest_test.go",
74+
"flush_test.go",
75+
"seal_test.go",
76+
"svsm_test.go",
77+
"token_test.go",
78+
"verify_test.go",
79+
],
80+
embed = [":cmd"],
81+
deps = [
82+
"//client",
83+
"//internal/test",
84+
"//proto/attest",
85+
"//verifier/util",
86+
"@com_github_google_gce_tcb_verifier//proto/endorsement:go_default_library",
87+
"@com_github_google_go_configfs_tsm//configfs/configfsi",
88+
"@com_github_google_go_configfs_tsm//configfs/faketsm",
89+
"@com_github_google_go_sev_guest//abi",
90+
"@com_github_google_go_sev_guest//proto/sevsnp",
91+
"@com_github_google_go_sev_guest//testing",
92+
"@com_github_google_go_sev_guest//testing/client",
93+
"@com_github_google_go_sev_guest//validate",
94+
"@com_github_google_go_tdx_guest//testing",
95+
"@com_github_google_go_tdx_guest//testing/client",
96+
"@com_github_google_go_tdx_guest//testing/testdata",
97+
"@com_github_google_go_tpm//legacy/tpm2",
98+
"@com_github_google_go_tpm//tpmutil",
99+
"@org_golang_google_protobuf//encoding/prototext",
100+
"@org_golang_google_protobuf//proto",
101+
"@org_golang_x_oauth2//:go_default_library",
102+
"@org_golang_x_oauth2//google:go_default_library",
103+
],
104+
)

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ require (
1212
github.com/google/go-tdx-guest v0.3.2-0.20241009005452-097ee70d0843
1313
github.com/google/go-tpm v0.9.6
1414
github.com/google/logger v1.1.1
15-
google.golang.org/protobuf v1.35.1
15+
google.golang.org/protobuf v1.36.3
1616
)
1717

1818
require (

internal/BUILD.bazel

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
2+
3+
go_library(
4+
name = "internal",
5+
srcs = [
6+
"cert.go",
7+
"pcrs.go",
8+
"public.go",
9+
"quote.go",
10+
],
11+
importpath = "github.com/google/go-tpm-tools/internal",
12+
visibility = ["//:__subpackages__"],
13+
deps = [
14+
"//proto/tpm",
15+
"@com_github_google_go_tpm//legacy/tpm2",
16+
"@com_github_google_go_tpm//tpmutil",
17+
],
18+
)
19+
20+
go_test(
21+
name = "internal_test",
22+
srcs = [
23+
"cert_test.go",
24+
"pcrs_test.go",
25+
],
26+
embed = [":internal"],
27+
deps = [
28+
"//internal/test",
29+
"//proto/tpm",
30+
"@com_github_google_go_tpm//legacy/tpm2",
31+
],
32+
)

internal/test/BUILD.bazel

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
2+
3+
go_library(
4+
name = "test",
5+
srcs = [
6+
"load_random_external_key.go",
7+
"test_cert.go",
8+
"test_data.go",
9+
"test_other.go",
10+
"test_tpm.go",
11+
"test_windows.go",
12+
],
13+
embedsrcs = [
14+
"attestations/gce-cos-85-no-nonce.pb",
15+
"attestations/gce-cos-85-nonce9009.pb",
16+
"certificates/pca_tpm_ecc_enc_cert.pem",
17+
"certificates/pca_tpm_ecc_sign_cert.pem",
18+
"certificates/pca_tpm_rsa_enc_cert.pem",
19+
"certificates/pca_tpm_rsa_sign_cert.pem",
20+
"certificates/uca_tpm_ecc_enc_cert.pem",
21+
"certificates/uca_tpm_ecc_sign_cert.pem",
22+
"certificates/uca_tpm_rsa_enc_cert.pem",
23+
"certificates/uca_tpm_rsa_sign_cert.pem",
24+
"eventlogs/arch-linux-workstation.bin",
25+
"eventlogs/confidential-gke-debug-251000_eventlog.bin",
26+
"eventlogs/cos-101-amd-sev.bin",
27+
"eventlogs/cos-85-amd-sev.bin",
28+
"eventlogs/cos-93-amd-sev.bin",
29+
"eventlogs/debian-10.bin",
30+
"eventlogs/eventlogwithsp800155.bin",
31+
"eventlogs/gdc-host.bin",
32+
"eventlogs/glinux-alex.bin",
33+
"eventlogs/rhel8-uefi.bin",
34+
"eventlogs/ubuntu-1804-amd-sev.bin",
35+
"eventlogs/ubuntu-2104-no-dbx.bin",
36+
"eventlogs/ubuntu-2104-no-secure-boot.bin",
37+
"eventlogs/ubuntu-2404-amd-sevsnp.bin",
38+
"tdx_test_files/tdxReportData.bin",
39+
],
40+
importpath = "github.com/google/go-tpm-tools/internal/test",
41+
visibility = ["//:__subpackages__"],
42+
deps = [
43+
"//simulator",
44+
"@com_github_google_go_attestation//attest",
45+
"@com_github_google_go_tpm//legacy/tpm2",
46+
"@com_github_google_go_tpm//tpm2",
47+
"@com_github_google_go_tpm//tpmutil",
48+
],
49+
)
50+
51+
go_test(
52+
name = "test_test",
53+
srcs = ["simulate_test.go"],
54+
embed = [":test"],
55+
deps = [
56+
"//client",
57+
"//server",
58+
],
59+
)

0 commit comments

Comments
 (0)