@@ -139,9 +139,7 @@ func generateDigestMap(hashAlgos []crypto.Hash, event Content) (map[crypto.Hash]
139139 return digestsMap , nil
140140}
141141
142- // AppendEventRTMR appends a new RTMR record to the CEL. rtmrIndex indicates the RTMR to extend.
143- // The index showing up in the record will be rtmrIndex + 1.
144- func (c * CEL ) AppendEventRTMR (client configfsi.Client , rtmrIndex int , event Content ) error {
142+ func (c * CEL ) appendEventRTMR (rtmrIndex int , event Content , extendFunc func ([]byte ) error ) error {
145143 digestsMap , err := generateDigestMap ([]crypto.Hash {crypto .SHA384 }, event )
146144 if err != nil {
147145 return err
@@ -152,8 +150,7 @@ func (c *CEL) AppendEventRTMR(client configfsi.Client, rtmrIndex int, event Cont
152150 return err
153151 }
154152
155- err = rtmr .ExtendDigestClient (client , rtmrIndex , digestsMap [crypto .SHA384 ])
156- if err != nil {
153+ if err := extendFunc (digestsMap [crypto .SHA384 ]); err != nil {
157154 return err
158155 }
159156
@@ -169,9 +166,28 @@ func (c *CEL) AppendEventRTMR(client configfsi.Client, rtmrIndex int, event Cont
169166 return nil
170167}
171168
169+ // AppendEventRTMRSysfs appends a new RTMR record to the CEL. rtmrIndex indicates the RTMR to extend.
170+ // The index showing up in the record will be rtmrIndex + 1.
171+ // This function uses thesysfs interface to extend the RTMR.
172+ func (c * CEL ) AppendEventRTMRSysfs (rtmrIndex int , event Content ) error {
173+ return c .appendEventRTMR (rtmrIndex , event , func (digest []byte ) error {
174+ return rtmr .ExtendDigestSysfs (rtmrIndex , digest )
175+ })
176+ }
177+
178+ // AppendEventRTMR appends a new RTMR record to the CEL. rtmrIndex indicates the RTMR to extend.
179+ // The index showing up in the record will be rtmrIndex + 1.
180+ // This function uses the configfs interface to extend the RTMR.
181+ // Use AppendEventRTMRSysfs as the sysfs interface is available in later kernels.
182+ func (c * CEL ) AppendEventRTMR (client configfsi.Client , rtmrIndex int , event Content ) error {
183+ return c .appendEventRTMR (rtmrIndex , event , func (digest []byte ) error {
184+ return rtmr .ExtendDigestClient (client , rtmrIndex , digest )
185+ })
186+ }
187+
172188// AppendEvent appends a new PCR record to the CEL.
173189//
174- // Deprecated: Use AppendEventPCR or AppendEventRTMR directly.
190+ // Deprecated: Use AppendEventPCR or AppendEventRTMRSysfs/ AppendEventRTMR directly.
175191func (c * CEL ) AppendEvent (tpm io.ReadWriteCloser , pcr int , event Content ) error {
176192 return c .AppendEventPCR (tpm , pcr , event )
177193}
0 commit comments