Skip to content

Commit 002341a

Browse files
committed
Include policy digest in the host data for confidential UVM
When the policy digest is included in the host data field of the UVM config, the SNP hardware is able to directly access that and include that in the attestation report. Signed-off-by: Amit Barve <ambarve@microsoft.com>
1 parent 9cb9546 commit 002341a

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

internal/uvm/create_wcow.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ package uvm
44

55
import (
66
"context"
7+
"encoding/base64"
78
"fmt"
89
"maps"
910
"os"
@@ -27,6 +28,7 @@ import (
2728
"github.com/Microsoft/hcsshim/internal/uvm/scsi"
2829
"github.com/Microsoft/hcsshim/internal/wclayer"
2930
"github.com/Microsoft/hcsshim/osversion"
31+
"github.com/Microsoft/hcsshim/pkg/securitypolicy"
3032
)
3133

3234
type ConfidentialWCOWOptions struct {
@@ -335,12 +337,23 @@ func prepareSecurityConfigDoc(ctx context.Context, uvm *UtilityVM, opts *Options
335337
}
336338
}
337339

340+
policyDigest, err := securitypolicy.NewSecurityPolicyDigest(opts.SecurityPolicy)
341+
if err != nil {
342+
return nil, err
343+
}
344+
345+
// HCS API expect a base64 encoded string as LaunchData. Internally it
346+
// decodes it to bytes. SEV later returns the decoded byte blob as HostData
347+
// field of the report.
348+
hostData := base64.StdEncoding.EncodeToString(policyDigest)
349+
338350
enableHCL := true
339351
doc.VirtualMachine.SecuritySettings = &hcsschema.SecuritySettings{
340352
EnableTpm: false,
341353
Isolation: &hcsschema.IsolationSettings{
342354
IsolationType: "SecureNestedPaging",
343355
HclEnabled: &enableHCL,
356+
LaunchData: hostData,
344357
},
345358
}
346359

0 commit comments

Comments
 (0)