@@ -190,4 +190,47 @@ impl Tcg {
190
190
let mut capability = BootServiceCapability :: default ( ) ;
191
191
unsafe { ( self . get_capability ) ( self , & mut capability) . into_with_val ( || capability) }
192
192
}
193
+
194
+ /// Get a bitmap of the active PCR banks. Each bank corresponds to a hash
195
+ /// algorithm.
196
+ pub fn get_active_pcr_banks ( & mut self ) -> Result < HashAlgorithm > {
197
+ let mut active_pcr_banks = HashAlgorithm :: empty ( ) ;
198
+
199
+ let status = unsafe { ( self . get_active_pcr_banks ) ( self , & mut active_pcr_banks) } ;
200
+
201
+ status. into_with_val ( || active_pcr_banks)
202
+ }
203
+
204
+ /// Set the active PCR banks. Each bank corresponds to a hash
205
+ /// algorithm. This change will not take effect until the system is
206
+ /// rebooted twice.
207
+ pub fn set_active_pcr_banks ( & mut self , active_pcr_banks : HashAlgorithm ) -> Result {
208
+ unsafe { ( self . set_active_pcr_banks ) ( self , active_pcr_banks) } . into ( )
209
+ }
210
+
211
+ /// Get the stored result of calling [`Tcg::set_active_pcr_banks`] in a
212
+ /// previous boot.
213
+ ///
214
+ /// If there was no attempt to set the active PCR banks in a previous boot,
215
+ /// this returns `None`. Otherwise, it returns a numeric response code:
216
+ /// * `0x00000000`: Success
217
+ /// * `0x00000001..=0x00000FFF`: TPM error code
218
+ /// * `0xfffffff0`: The operation was canceled by the user or timed out
219
+ /// * `0xfffffff1`: Firmware error
220
+ pub fn get_result_of_set_active_pcr_banks ( & mut self ) -> Result < Option < u32 > > {
221
+ let mut operation_present = 0 ;
222
+ let mut response = 0 ;
223
+
224
+ let status = unsafe {
225
+ ( self . get_result_of_set_active_pcr_banks ) ( self , & mut operation_present, & mut response)
226
+ } ;
227
+
228
+ status. into_with_val ( || {
229
+ if operation_present == 0 {
230
+ None
231
+ } else {
232
+ Some ( response)
233
+ }
234
+ } )
235
+ }
193
236
}
0 commit comments