|
@@ -34,6 +34,12 @@ impl HasResponseCode for Tss2ResponseCode {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+impl HasResponseCode for TSS2_RC {
|
|
|
+ fn response_code(&self) -> TSS2_RC {
|
|
|
+ self.clone()
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
trait Tss2Expect<T> {
|
|
|
/// Provides an enhanced error message for types which contain TSS2 response codes.
|
|
|
fn tss2_expect(self, err_msg: &str) -> T;
|
|
@@ -60,12 +66,13 @@ impl<T> Tss2Expect<T> for tss_esapi::Result<T> {
|
|
|
#[cfg(test)]
|
|
|
mod test {
|
|
|
use super::*;
|
|
|
+ use core::str::FromStr;
|
|
|
use tss_esapi::{
|
|
|
Context,
|
|
|
constants::{
|
|
|
session_type::{SessionType},
|
|
|
},
|
|
|
- tcti_ldr::{TabrmdConfig},
|
|
|
+ tcti_ldr::{DeviceConfig, NetworkTPMConfig, TctiNameConf, TabrmdConfig},
|
|
|
interface_types::{
|
|
|
resource_handles::{Hierarchy},
|
|
|
algorithm::{HashingAlgorithm},
|
|
@@ -87,6 +94,13 @@ mod test {
|
|
|
},
|
|
|
};
|
|
|
|
|
|
+ //#[test]
|
|
|
+ fn decode_return_code() {
|
|
|
+ const RC: TSS2_RC = 0x00000101;
|
|
|
+ let text = tss2_rc_decode(RC);
|
|
|
+ panic!("{}", text);
|
|
|
+ }
|
|
|
+
|
|
|
#[test]
|
|
|
fn create_context() {
|
|
|
let config = TabrmdConfig::default();
|
|
@@ -96,9 +110,9 @@ mod test {
|
|
|
|
|
|
#[test]
|
|
|
fn create_primary_key() {
|
|
|
- let config = TabrmdConfig::default();
|
|
|
- let mut context = Context::new_with_tabrmd(config)
|
|
|
- .expect("Failed to connect to tabrmd. Ensure that tpm2-abrmd is running");
|
|
|
+ let config = TctiNameConf::Device(DeviceConfig::from_str("/dev/vtpm0").unwrap());
|
|
|
+ let mut context = Context::new(config)
|
|
|
+ .tss2_expect("Failed to create context");
|
|
|
|
|
|
let public = {
|
|
|
let object_attributes = ObjectAttributes::builder()
|
|
@@ -137,7 +151,7 @@ mod test {
|
|
|
SymmetricDefinition::AES_256_CFB,
|
|
|
HashingAlgorithm::Sha256,
|
|
|
)
|
|
|
- .expect("Failed to create session")
|
|
|
+ .tss2_expect("Failed to create session")
|
|
|
.expect("Received invalid handle");
|
|
|
|
|
|
context.execute_with_session(Some(session), |ctx| {
|