Skip to content

Commit c84a30a

Browse files
author
Roy Kaufman
committed
working version of the demo on GCP
1 parent a56f7c5 commit c84a30a

17 files changed

+73
-56
lines changed

trustee-on-GCP/trustee/trustee.bu renamed to configs/trustee-gcp.bu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ storage:
4242
- path: /var/kbs/config/kbs-config.toml
4343
mode: 0644
4444
contents:
45-
local: config/kbs-config.toml
45+
local: kbs-config.toml
4646
- path: /etc/containers/systemd/kbs.container
4747
mode: 0644
4848
contents:

trustee-on-GCP/trustee/containers/kbc.container renamed to configs/trustee-gcp/containers/kbc.container

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ After=key-generation.container
44

55
[Container]
66
ContainerName=kbs-client
7-
Image=quay.io/rkaufman/kbs-tpm-snp:latest
7+
Image=quay.io/rkaufman/kbs-tpm-snp:v1
88
Network=host
99
Volume=user-keys:/opt/confidential-containers/kbs/user-keys
1010
Exec=tail -f /dev/null

trustee-on-GCP/trustee/containers/kbs.container renamed to configs/trustee-gcp/containers/kbs.container

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ After=key-generation.container
44

55
[Container]
66
ContainerName=kbs
7-
Image=quay.io/rkaufman/kbs-tpm-snp:latest
7+
Image=quay.io/rkaufman/kbs-tpm-snp:v1
88
Network=host
99
Entrypoint=/usr/local/bin/kbs
1010
PublishPort=8080:8080

trustee-on-GCP/trustee/populate_kbs.sh renamed to configs/trustee-gcp/populate_kbs.sh

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,22 @@
22

33
set -xe
44

5-
KBS=kbs:8080
65
SECRET_PATH=${SECRET_PATH:=default/machine/root}
76
KEY=${KEY:=/opt/confidential-containers/kbs/user-keys/private.key}
87

98

109
## set reference values for TPM
11-
podman exec -ti kbs-client \
12-
kbs-client --url http://${KBS} config \
13-
--auth-private-key ${KEY} \
14-
set-sample-reference-value tpm_svn "1"
1510
for i in {7,14}; do
1611
value=$(sudo tpm2_pcrread sha256:${i} | awk -F: '/0x/ {sub(/.*0x/, "", $2); gsub(/[^0-9A-Fa-f]/, "", $2); print tolower($2)}')
1712
podman exec -ti kbs-client \
18-
kbs-client --url http://${KBS} config \
13+
kbs-client config \
1914
--auth-private-key ${KEY} \
2015
set-sample-reference-value tpm_pcr${i} "${value}"
2116
done
2217

2318
# Check reference values
2419
podman exec -ti kbs-client \
25-
kbs-client --url http://${KBS} config \
20+
kbs-client config \
2621
--auth-private-key ${KEY} \
2722
get-reference-values
2823

@@ -41,30 +36,29 @@ default configuration := 2
4136
##### TPM
4237
4338
hardware := 2 if {
44-
input.tpm.svn in data.reference.tpm_svn
45-
input.tpm.pcrs[7] in data.reference.tpm_pcr7
46-
input.tpm.pcrs[14] in data.reference.tpm_pcr14
39+
input.tpm.pcr07 in data.reference.tpm_pcr7
40+
input.tpm.pcr14 in data.reference.tpm_pcr14
4741
}
4842
4943
hardware := 2 if {
50-
input.snp.reported_tcb_snp == 25
44+
input.snp.reported_tcb_snp == 27
5145
}
5246
5347
5448
##### Final decision
55-
allow if {
56-
hardware == 2
57-
executables == 3
58-
configuration == 2
49+
result := {
50+
"executables": executables,
51+
"hardware": hardware,
52+
"configuration": configuration
5953
}
6054
EOF
6155

6256
podman cp A_policy.rego kbs-client:/A_policy.rego
6357
podman exec -ti kbs-client \
64-
kbs-client --url http://${KBS} config \
58+
kbs-client config \
6559
--auth-private-key ${KEY} \
6660
set-attestation-policy \
67-
--policy-file A_policy.rego \
61+
--policy-file /A_policy.rego \
6862
--type rego --id default_cpu
6963

7064
# Upload resource
@@ -73,7 +67,7 @@ cat > secret << EOF
7367
EOF
7468
podman cp secret kbs-client:/secret
7569
podman exec -ti kbs-client \
76-
kbs-client --url http://${KBS} config \
70+
kbs-client config \
7771
--auth-private-key ${KEY} \
7872
set-resource --resource-file /secret \
7973
--path ${SECRET_PATH}
@@ -98,7 +92,7 @@ EOF
9892

9993
podman cp R_policy.rego kbs-client:/R_policy.rego
10094
podman exec -ti kbs-client \
101-
kbs-client --url http://${KBS} config \
95+
kbs-client config \
10296
--auth-private-key ${KEY} \
10397
set-resource-policy \
104-
--policy-file R_policy.rego \
98+
--policy-file /R_policy.rego \

coreos/justfile

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ osbuild:
3434
SELINUX_STATUS=$(getenforce)
3535

3636
if [ "$SELINUX_STATUS" = "Enforcing" ]; then
37-
sudo setenforce 0
37+
echo "WARNING: SELinux is in Enforcing mode. Temporarily disabling for osbuild operation..."
3838
fi
3939

4040
TMPDIR=$(mktemp -d)
@@ -46,6 +46,3 @@ osbuild:
4646
rm -rf "$TMPDIR"
4747
sudo chown $USER:$USER {{os}}-{{platform}}.x86_64.*
4848

49-
if [ "$SELINUX_STATUS" = "Enforcing" ]; then
50-
sudo setenforce 1
51-
fi

pin-trustee.bu

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
variant: fcos
2+
version: 1.6.0
3+
storage:
4+
luks:
5+
- name: root
6+
label: luks-root
7+
device: /dev/disk/by-partlabel/root
8+
uuid: "8ec9cda3-6b77-45d7-bb56-a95cd9e83234"
9+
clevis:
10+
custom:
11+
needs_network: true
12+
pin: trustee
13+
config: '{"servers":[{"url":"http://demo-trustee:8080","cert":""}],"path":"default/machine/root"}'
14+
wipe_volume: true
15+
filesystems:
16+
- device: /dev/mapper/root
17+
format: ext4
18+
wipe_filesystem: true
19+
label: root
20+
uuid: "910678ff-f77e-4a7d-8d53-86f2ac47a823"
21+
options: [ "-O", "verity"]

run.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
gcloud compute instances create roy-vm \
2+
--image-family "rhel-9" \
3+
--image-project "rhel-cloud" \
4+
--metadata "ssh-keys=rkaufman:$(cat ~/.ssh/google_compute_engine.pub)" \
5+
--boot-disk-size "100GB" \
6+
--confidential-compute-type "SEV_SNP" \
7+
--machine-type "n2d-standard-2" \
8+
--maintenance-policy terminate \
9+
--zone "us-central1-a" \
10+
--subnet "roy-subnet-us-central1" \
11+
--shielded-vtpm \
12+
--shielded-integrity-monitoring \
13+
--shielded-secure-boot

0 commit comments

Comments
 (0)