Skip to content

Commit 03c2edb

Browse files
authored
underhill_attestation: allow fallback from GspKey to GspById (#2055)
When strict encryption policy is not enabled, allow the HCL to GspById if GspKey is not available.
1 parent 4ca292e commit 03c2edb

File tree

3 files changed

+24
-21
lines changed

3 files changed

+24
-21
lines changed

openhcl/underhill_attestation/src/lib.rs

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -678,10 +678,10 @@ async fn get_derived_keys(
678678

679679
let requires_gsp = is_gsp
680680
|| response.extended_status_flags.requires_rpc_server()
681-
|| matches!(
681+
|| (matches!(
682682
guest_state_encryption_policy,
683683
GuestStateEncryptionPolicy::GspKey
684-
);
684+
) && strict_encryption_policy);
685685

686686
// If the VMGS is encrypted, but no key protection data is found,
687687
// assume GspById encryption is enabled, but no ID file was written.
@@ -889,18 +889,21 @@ async fn get_derived_keys(
889889
if no_kek && no_gsp {
890890
if matches!(
891891
guest_state_encryption_policy,
892-
GuestStateEncryptionPolicy::None
892+
GuestStateEncryptionPolicy::GspById | GuestStateEncryptionPolicy::Auto
893893
) {
894+
tracing::info!(CVM_ALLOWED, "Using GspById");
895+
} else {
894896
// Log a warning here to indicate that the VMGS state is out of
895897
// sync with the VM's configuration.
896898
//
897-
// This should only happen if the VM is configured to
898-
// have no encryption, but it already has GspById encryption
899-
// and strict encryption policy is disabled.
899+
// This should only happen if strict encryption policy is
900+
// disabled and one of the following is true:
901+
// - The VM is configured to have no encryption, but it already
902+
// has GspById encryption.
903+
// - The VM is configured to use GspKey, but GspKey is not
904+
// available and GspById is.
900905
tracing::warn!(CVM_ALLOWED, "Allowing GspById");
901-
} else {
902-
tracing::info!(CVM_ALLOWED, "Using GspById");
903-
}
906+
};
904907

905908
// Not required for Id protection
906909
key_protector_settings.should_write_kp = false;
@@ -968,7 +971,7 @@ async fn get_derived_keys(
968971
derived_keys.ingress = ingress_key;
969972
}
970973
} else {
971-
tracing::info!(CVM_ALLOWED, "Using GSP.");
974+
tracing::info!(CVM_ALLOWED, "Using existing GSP.");
972975

973976
ingress_seed = Some(
974977
gsp_response.decrypted_gsp[ingress_idx].buffer
@@ -1034,17 +1037,17 @@ async fn get_derived_keys(
10341037

10351038
if matches!(
10361039
guest_state_encryption_policy,
1037-
GuestStateEncryptionPolicy::None | GuestStateEncryptionPolicy::GspById
1040+
GuestStateEncryptionPolicy::GspKey | GuestStateEncryptionPolicy::Auto
10381041
) {
1042+
tracing::info!(CVM_ALLOWED, "Using Gsp");
1043+
} else {
10391044
// Log a warning here to indicate that the VMGS state is out of
10401045
// sync with the VM's configuration.
10411046
//
10421047
// This should only happen if the VM is configured to have no
10431048
// encryption or GspById encryption, but it already has GspKey
10441049
// encryption and strict encryption policy is disabled.
10451050
tracing::warn!(CVM_ALLOWED, "Allowing Gsp");
1046-
} else {
1047-
tracing::info!(CVM_ALLOWED, "Using Gsp");
10481051
}
10491052

10501053
Ok(DerivedKeyResult {

vm/devices/get/get_protocol/src/dps_json.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,11 @@ pub enum GuestStateEncryptionPolicy {
123123
/// strict encryption policy is enabled. Fails if the data cannot be
124124
/// encrypted.
125125
GspById,
126-
/// Require GspKey.
126+
/// Prefer (or require, if strict) GspKey.
127127
///
128-
/// VMs will be created as or migrated to GspKey. Fails if GspKey is
129-
/// not available. Strict encryption policy has no effect here since
130-
/// GspKey is currently the most secure policy.
128+
/// VMs will be created as or migrated to GspKey. GspById encryption will
129+
/// be used if GspKey is unavailable unless strict encryption policy is
130+
/// enabled. Fails if the data cannot be encrypted.
131131
GspKey,
132132
/// Use hardware sealing
133133
// TODO: update this doc comment once hardware sealing is implemented

vm/vmgs/vmgs_resources/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,11 @@ pub enum GuestStateEncryptionPolicy {
9292
/// strict encryption policy is enabled. Fails if the data cannot be
9393
/// encrypted.
9494
GspById(bool),
95-
/// Require GspKey.
95+
/// Prefer (or require, if strict) GspKey.
9696
///
97-
/// VMs will be created as or migrated to GspKey. Fails if GspKey is
98-
/// not available. Strict encryption policy has no effect here since
99-
/// GspKey is currently the most secure policy.
97+
/// VMs will be created as or migrated to GspKey. GspById encryption will
98+
/// be used if GspKey is unavailable unless strict encryption policy is
99+
/// enabled. Fails if the data cannot be encrypted.
100100
GspKey(bool),
101101
}
102102

0 commit comments

Comments
 (0)