@@ -35,6 +35,7 @@ type Support struct {
35
35
InternalDice bool
36
36
IsCA bool
37
37
RetainParentContext bool
38
+ CdiExport bool
38
39
}
39
40
40
41
// profileCommandCodes holds command codes for a specific revision of the
@@ -125,6 +126,9 @@ const (
125
126
// ContextHandle is a DPE context handle
126
127
type ContextHandle [16 ]byte
127
128
129
+ // ExportedCdi is a handle to an exported CDI
130
+ type ExportedCdi [32 ]byte
131
+
128
132
// DestroyCtxCmd is input parameters to DestroyContext
129
133
type DestroyCtxCmd struct {
130
134
handle ContextHandle
@@ -218,6 +222,8 @@ const (
218
222
InputAllowCA DeriveContextFlags = 1 << 26
219
223
InputAllowX509 DeriveContextFlags = 1 << 25
220
224
Recursive DeriveContextFlags = 1 << 24
225
+ CdiExport DeriveContextFlags = 1 << 23
226
+ CreateCertificate DeriveContextFlags = 1 << 22
221
227
)
222
228
223
229
// DeriveContextReq is the input request to DeriveContext
@@ -233,16 +239,14 @@ type DeriveContextReq[Digest DigestAlgorithm] struct {
233
239
type DeriveContextResp struct {
234
240
NewContextHandle ContextHandle
235
241
ParentContextHandle ContextHandle
242
+ ExportedCdi ExportedCdi
243
+ CertificateSize uint32
244
+ NewCertificate []byte
236
245
}
237
246
238
247
// SignFlags is the input flags to Sign
239
248
type SignFlags uint32
240
249
241
- // Supported Sign flags
242
- const (
243
- IsSymmetric SignFlags = 1 << 30
244
- )
245
-
246
250
// SignReq is the input request to Sign
247
251
type SignReq [Digest DigestAlgorithm ] struct {
248
252
ContextHandle ContextHandle
@@ -512,15 +516,43 @@ func (c *DPEABI[_, _, _]) GetCertificateChainABI() (*GetCertificateChainResp, er
512
516
}
513
517
514
518
// DeriveContextABI calls DPE DeriveContext command.
515
- func (c * DPEABI [_ , Digest , _ ]) DeriveContextABI (cmd * DeriveContextReq [Digest ]) (* DeriveContextResp , error ) {
516
- var respStruct DeriveContextResp
519
+ func (c * DPEABI [_ , Digest , DPECertificate ]) DeriveContextABI (cmd * DeriveContextReq [Digest ]) (* DeriveContextResp , error ) {
520
+ // Define an anonymous struct for the response, because the shape changes if exportCdi is set.
521
+ if cmd .Flags & CdiExport == CdiExport {
522
+ respStruct := struct {
523
+ NewContextHandle [16 ]byte
524
+ ParentContextHandle [16 ]byte
525
+ ExportedCdi [32 ]byte
526
+ CertificateSize uint32
527
+ Certificate DPECertificate
528
+ }{}
529
+ _ , err := execCommand (c .transport , c .constants .Codes .DeriveContext , c .Profile , cmd , & respStruct )
530
+ if err != nil {
531
+ return nil , err
532
+ }
517
533
518
- _ , err := execCommand (c .transport , c .constants .Codes .DeriveContext , c .Profile , cmd , & respStruct )
519
- if err != nil {
520
- return nil , err
521
- }
534
+ return & DeriveContextResp {
535
+ NewContextHandle : respStruct .NewContextHandle ,
536
+ ParentContextHandle : respStruct .ParentContextHandle ,
537
+ ExportedCdi : respStruct .ExportedCdi ,
538
+ CertificateSize : respStruct .CertificateSize ,
539
+ NewCertificate : respStruct .Certificate .Bytes ()[:respStruct .CertificateSize ],
540
+ }, nil
541
+ } else {
542
+ respStruct := struct {
543
+ NewContextHandle [16 ]byte
544
+ ParentContextHandle [16 ]byte
545
+ }{}
546
+ _ , err := execCommand (c .transport , c .constants .Codes .DeriveContext , c .Profile , cmd , & respStruct )
547
+ if err != nil {
548
+ return nil , err
549
+ }
522
550
523
- return & respStruct , err
551
+ return & DeriveContextResp {
552
+ NewContextHandle : respStruct .NewContextHandle ,
553
+ ParentContextHandle : respStruct .ParentContextHandle ,
554
+ }, nil
555
+ }
524
556
}
525
557
526
558
// RotateContextHandleABI calls DPE RotateContextHandle command.
@@ -733,5 +765,8 @@ func (s *Support) ToFlags() uint32 {
733
765
if s .RetainParentContext {
734
766
flags |= (1 << 19 )
735
767
}
768
+ if s .CdiExport {
769
+ flags |= (1 << 18 )
770
+ }
736
771
return flags
737
772
}
0 commit comments