Skip to content

Commit 2ea74dc

Browse files
authored
Merge pull request #124 from alicefr/register-ak
Add attestation key registration service
2 parents c0b8261 + 16db127 commit 2ea74dc

29 files changed

+1081
-59
lines changed

Cargo.lock

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# SPDX-License-Identifier: CC0-1.0
55

66
[workspace]
7-
members = ["compute-pcrs", "lib", "operator", "register-server", "test_utils", "tests"]
7+
members = ["attestation-key-register", "compute-pcrs", "lib", "operator", "register-server", "test_utils", "tests"]
88
resolver = "3"
99

1010
[workspace.package]
@@ -27,3 +27,4 @@ serde_json = "1.0.148"
2727
serde_yaml = "0.9"
2828
tokio = { version = "1.49.0", features = ["macros", "rt-multi-thread"] }
2929
uuid = { version = "1.19", features = ["v4", "serde"] }
30+
warp = "0.3"

Makefile

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ PUSH_FLAGS ?=
2626
OPERATOR_IMAGE=$(REGISTRY)/trusted-cluster-operator:$(TAG)
2727
COMPUTE_PCRS_IMAGE=$(REGISTRY)/compute-pcrs:$(TAG)
2828
REG_SERVER_IMAGE=$(REGISTRY)/registration-server:$(TAG)
29-
# TODO add support for TPM AK verification, then move to a KBS with implemented verifier
30-
TRUSTEE_IMAGE ?= quay.io/trusted-execution-clusters/key-broker-service:tpm-verifier-built-in-as-20250711
29+
ATTESTATION_KEY_REGISTER_IMAGE=$(REGISTRY)/attestation-key-register:$(TAG)
30+
TRUSTEE_IMAGE ?= quay.io/trusted-execution-clusters/key-broker-service:20260106
3131
# tagged as 42.20250705.3.0
32-
APPROVED_IMAGE ?= quay.io/trusted-execution-clusters/fedora-coreos@sha256:e71dad00aa0e3d70540e726a0c66407e3004d96e045ab6c253186e327a2419e5
32+
APPROVED_IMAGE ?= quay.io/fedora/fedora-coreos@sha256:8f11c87187dfe83145001e9571948f9ab466e9f4a8b1e092a4798e5db1030dc3
3333

3434
BUILD_TYPE ?= release
3535

36-
all: build trusted-cluster-gen reg-server
36+
all: build trusted-cluster-gen reg-server attestation-key-register
3737

3838
build: crds-rs
3939
cargo build -p compute-pcrs
@@ -42,6 +42,9 @@ build: crds-rs
4242
reg-server: crds-rs
4343
cargo build -p register-server
4444

45+
attestation-key-register: crds-rs
46+
cargo build -p attestation-key-register
47+
4548
CRD_YAML_PATH = config/crd
4649
RBAC_YAML_PATH = config/rbac/base
4750
API_PATH = api/v1alpha1
@@ -75,6 +78,7 @@ manifests: trusted-cluster-gen generate
7578
-trustee-image $(TRUSTEE_IMAGE) \
7679
-pcrs-compute-image $(COMPUTE_PCRS_IMAGE) \
7780
-register-server-image $(REG_SERVER_IMAGE) \
81+
-attestation-key-register-image $(ATTESTATION_KEY_REGISTER_IMAGE) \
7882
-approved-image $(APPROVED_IMAGE)
7983

8084
cluster-up:
@@ -96,11 +100,13 @@ image:
96100
$(CONTAINER_CLI) build --build-arg build_type=$(BUILD_TYPE) -t $(OPERATOR_IMAGE) -f Containerfile .
97101
$(CONTAINER_CLI) build --build-arg build_type=$(BUILD_TYPE) -t $(COMPUTE_PCRS_IMAGE) -f compute-pcrs/Containerfile .
98102
$(CONTAINER_CLI) build --build-arg build_type=$(BUILD_TYPE) -t $(REG_SERVER_IMAGE) -f register-server/Containerfile .
103+
$(CONTAINER_CLI) build --build-arg build_type=$(BUILD_TYPE) -t $(ATTESTATION_KEY_REGISTER_IMAGE) -f attestation-key-register/Containerfile .
99104

100105
push: image
101106
$(CONTAINER_CLI) push $(OPERATOR_IMAGE) $(PUSH_FLAGS)
102107
$(CONTAINER_CLI) push $(COMPUTE_PCRS_IMAGE) $(PUSH_FLAGS)
103108
$(CONTAINER_CLI) push $(REG_SERVER_IMAGE) $(PUSH_FLAGS)
109+
$(CONTAINER_CLI) push $(ATTESTATION_KEY_REGISTER_IMAGE) $(PUSH_FLAGS)
104110

105111
release-tarball: manifests
106112
tar -cf trusted-execution-operator-$(TAG).tar config
@@ -134,7 +140,7 @@ install: $(YQ)
134140
ifndef TRUSTEE_ADDR
135141
$(error TRUSTEE_ADDR is undefined)
136142
endif
137-
scripts/clean-cluster-kind.sh $(OPERATOR_IMAGE) $(COMPUTE_PCRS_IMAGE) $(REG_SERVER_IMAGE)
143+
scripts/clean-cluster-kind.sh $(OPERATOR_IMAGE) $(COMPUTE_PCRS_IMAGE) $(REG_SERVER_IMAGE) $(ATTESTATION_KEY_REGISTER_IMAGE)
138144
$(YQ) '.spec.publicTrusteeAddr = "$(TRUSTEE_ADDR):8080"' \
139145
-i $(DEPLOY_PATH)/trusted_execution_cluster_cr.yaml
140146
$(YQ) '.namespace = "$(NAMESPACE)"' -i config/rbac/base/kustomization.yaml

api/trusted-cluster-gen.go

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,14 @@ import (
2222
)
2323

2424
type Args struct {
25-
outputDir string
26-
image string
27-
namespace string
28-
trusteeImage string
29-
pcrsComputeImage string
30-
registerServerImage string
31-
approvedImage string
25+
outputDir string
26+
image string
27+
namespace string
28+
trusteeImage string
29+
pcrsComputeImage string
30+
registerServerImage string
31+
attestationKeyRegisterImage string
32+
approvedImage string
3233
}
3334

3435
func main() {
@@ -39,6 +40,7 @@ func main() {
3940
flag.StringVar(&args.trusteeImage, "trustee-image", "operators", "Container image with all-in-one Trustee")
4041
flag.StringVar(&args.pcrsComputeImage, "pcrs-compute-image", "quay.io/trusted-execution-clusters/compute-pcrs:latest", "Container image with the Trusted Execution Clusters compute-pcrs binary")
4142
flag.StringVar(&args.registerServerImage, "register-server-image", "quay.io/trusted-execution-clusters/register-server:latest", "Register server image to use in the deployment")
43+
flag.StringVar(&args.attestationKeyRegisterImage, "attestation-key-register-image", "quay.io/trusted-execution-clusters/attestation-key-register:latest", "Attestation key register image to use in the deployment")
4244
flag.StringVar(&args.approvedImage, "approved-image", "", "When set, defines an initial approved image. Must be a bootable container image with SHA reference.")
4345
flag.Parse()
4446

@@ -138,12 +140,14 @@ func generateTrustedExecutionClusterCR(args *Args) error {
138140
Namespace: args.namespace,
139141
},
140142
Spec: v1alpha1.TrustedExecutionClusterSpec{
141-
TrusteeImage: args.trusteeImage,
142-
PcrsComputeImage: args.pcrsComputeImage,
143-
RegisterServerImage: args.registerServerImage,
144-
PublicTrusteeAddr: nil,
145-
TrusteeKbsPort: 0,
146-
RegisterServerPort: 0,
143+
TrusteeImage: args.trusteeImage,
144+
PcrsComputeImage: args.pcrsComputeImage,
145+
RegisterServerImage: args.registerServerImage,
146+
AttestationKeyRegisterImage: &args.attestationKeyRegisterImage,
147+
PublicTrusteeAddr: nil,
148+
TrusteeKbsPort: 0,
149+
RegisterServerPort: 0,
150+
AttestationKeyRegisterPort: 0,
147151
},
148152
}
149153

api/v1alpha1/conditions.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,9 @@ const (
2020
NotCommittedReasonComputing string = "Computing"
2121
NotCommittedReasonNoDigest string = "NoDigestGiven"
2222
NotCommittedReasonFailed string = "ComputationFailed"
23+
24+
// Conditions for the AttestationKey
25+
AttestationKeyApprovedCondition string = "Approved"
26+
AttestationKeyRegistrationReason string = "Registration"
27+
AttestationKeyMachineApprovedReason string = "MachineCreated"
2328
)

api/v1alpha1/crds.go

Lines changed: 59 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ var (
2828
// +kubebuilder:rbac:groups="",resources=configmaps;services;secrets,verbs=create;get;list;watch
2929
// +kubebuilder:rbac:groups=apps,resources=deployments,verbs=create;delete;get;list;patch;update;watch
3030
// +kubebuilder:rbac:groups=batch,resources=jobs,verbs=create;delete;get;list;patch;update;watch
31-
// +kubebuilder:rbac:groups=trusted-execution-clusters.io,resources=trustedexecutionclusters;machines;approvedimages,verbs=create;delete;get;list;patch;update;watch
31+
// +kubebuilder:rbac:groups=trusted-execution-clusters.io,resources=trustedexecutionclusters;machines;approvedimages;attestationkeys,verbs=create;delete;get;list;patch;update;watch
3232
// +kubebuilder:rbac:groups=trusted-execution-clusters.io,resources=trustedexecutionclusters/finalizers,verbs=update
3333
// +kubebuilder:rbac:groups=trusted-execution-clusters.io,resources=machines/finalizers,verbs=update
34-
// +kubebuilder:rbac:groups=trusted-execution-clusters.io,resources=trustedexecutionclusters/status;machines/status;approvedimages/status,verbs=get;patch;update
34+
// +kubebuilder:rbac:groups=trusted-execution-clusters.io,resources=trustedexecutionclusters/status;machines/status;approvedimages/status;attestationkeys/status,verbs=get;patch;update
3535

3636
// TrustedExecutionClusterSpec defines the desired state of TrustedExecutionCluster
3737
// +kubebuilder:validation:XValidation:rule="!has(oldSelf.publicTrusteeAddr) || has(self.publicTrusteeAddr)", message="Value is required once set"
@@ -48,6 +48,10 @@ type TrustedExecutionClusterSpec struct {
4848
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Value is immutable"
4949
RegisterServerImage string `json:"registerServerImage"`
5050

51+
// Image reference to trusted-cluster-operator's attestation-key-register image
52+
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Value is immutable"
53+
AttestationKeyRegisterImage *string `json:"attestationKeyRegisterImage"`
54+
5155
// Address where attester can connect to Trustee
5256
// +optional
5357
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Value is immutable"
@@ -62,6 +66,11 @@ type TrustedExecutionClusterSpec struct {
6266
// +optional
6367
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Value is immutable"
6468
RegisterServerPort int32 `json:"registerServerPort,omitempty"`
69+
70+
// Port that trusted-cluster-operator's attestation-key-register serves on
71+
// +optional
72+
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Value is immutable"
73+
AttestationKeyRegisterPort int32 `json:"attestationKeyRegisterPort,omitempty"`
6574
}
6675

6776
// TrustedExecutionClusterStatus defines the observed state of TrustedExecutionCluster.
@@ -192,3 +201,51 @@ type ApprovedImageList struct {
192201
metav1.ListMeta `json:"metadata,omitempty"`
193202
Items []ApprovedImage `json:"items"`
194203
}
204+
205+
// AttestationKeySpec
206+
type AttestationKeySpec struct {
207+
// PublicKey defines the attestation public key to be registered as trusted key.
208+
// +required
209+
PublicKey string `json:"publicKey"`
210+
211+
// Address defines the address of the machine associated to the attestation key.
212+
// +optional
213+
Address *string `json:"address,omitempty"`
214+
}
215+
216+
// AttestationKeyStatus defines the observed state of AttestationKey.
217+
type AttestationKeyStatus struct {
218+
// +listType=map
219+
// +listMapKey=type
220+
// +optional
221+
Conditions []metav1.Condition `json:"conditions,omitempty"`
222+
}
223+
224+
// +kubebuilder:object:root=true
225+
// +kubebuilder:subresource:status
226+
227+
// AttestationKey represents the Attestation Key to be added as to the trusted key for trustee.
228+
type AttestationKey struct {
229+
metav1.TypeMeta `json:",inline"`
230+
231+
// metadata is a standard object metadata
232+
// +optional
233+
metav1.ObjectMeta `json:"metadata,omitempty,omitzero"`
234+
235+
// spec defines the desired state of AttestationKey
236+
// +required
237+
Spec AttestationKeySpec `json:"spec"`
238+
239+
// status defines the observed state of AttestationKey
240+
// +optional
241+
Status AttestationKeyStatus `json:"status,omitempty,omitzero"`
242+
}
243+
244+
// +kubebuilder:object:root=true
245+
246+
// AttestationKeyList contains a list of AttestationKey
247+
type AttestationKeyList struct {
248+
metav1.TypeMeta `json:",inline"`
249+
metav1.ListMeta `json:"metadata,omitempty"`
250+
Items []AttestationKey `json:"items"`
251+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# SPDX-FileCopyrightText: Alice Frosi <[email protected]>
2+
#
3+
# SPDX-License-Identifier: CC0-1.0
4+
5+
[package]
6+
name = "attestation-key-register"
7+
version = "0.1.0"
8+
edition = "2021"
9+
rust-version.workspace = true
10+
11+
[dependencies]
12+
anyhow.workspace = true
13+
clap.workspace = true
14+
trusted-cluster-operator-lib = { path = "../lib" }
15+
env_logger.workspace = true
16+
k8s-openapi.workspace = true
17+
kube.workspace = true
18+
log.workspace = true
19+
serde.workspace = true
20+
serde_json.workspace = true
21+
tokio.workspace = true
22+
uuid = { version = "1.0", features = ["v4"] }
23+
warp.workspace = true
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# SPDX-FileCopyrightText: Alice Frosi <[email protected]>
2+
#
3+
# SPDX-License-Identifier: CC0-1.0
4+
5+
ARG build_type
6+
FROM ghcr.io/trusted-execution-clusters/buildroot AS builder
7+
ARG build_type
8+
WORKDIR /build
9+
10+
COPY Makefile .
11+
RUN make build-tools
12+
13+
COPY Cargo.toml Cargo.lock go.mod go.sum .
14+
COPY api api
15+
COPY lib lib
16+
RUN make crds-rs
17+
18+
COPY attestation-key-register/Cargo.toml attestation-key-register/
19+
COPY attestation-key-register/src/lib.rs attestation-key-register/src/
20+
21+
# Set only required crates as members to minimize rebuilds upon changes.
22+
# In debug builds, build dependencies to avoid full rebuild.
23+
RUN sed -i 's/members =.*/members = ["lib", "attestation-key-register"]/' Cargo.toml && \
24+
if [ "$build_type" = debug ]; then cargo build -p attestation-key-register; fi
25+
26+
COPY attestation-key-register/src attestation-key-register/src
27+
RUN cargo build -p attestation-key-register $(if [ "$build_type" = release ]; then echo --release; fi)
28+
29+
FROM quay.io/fedora/fedora:42
30+
ARG build_type
31+
COPY --from=builder "/build/target/$build_type/attestation-key-register" /usr/bin
32+
EXPOSE 8001
33+
ENTRYPOINT ["/usr/bin/attestation-key-register"]
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// SPDX-FileCopyrightText: Alice Frosi <[email protected]>
2+
//
3+
// SPDX-License-Identifier: MIT
4+
5+
// This pseudo-library exists to build dependencies in a lower
6+
// container image layer, which speeds up development.

0 commit comments

Comments
 (0)