Skip to content

Commit 45d5166

Browse files
committed
Allow use with v4 of tpm2-tss
Also adding a test job for Fedora rawhide, which uses tpm2-tss v4.0.0 (for now). Signed-off-by: Ionut Mihalcea <[email protected]>
1 parent 5657f7c commit 45d5166

File tree

10 files changed

+34
-11
lines changed

10 files changed

+34
-11
lines changed

.github/workflows/ci.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,17 @@ jobs:
7070
- name: Run the tests
7171
run: docker run -v $(pwd):/tmp/rust-tss-esapi -w /tmp/rust-tss-esapi/tss-esapi fedoracontainer dbus-run-session -- /tmp/rust-tss-esapi/tss-esapi/tests/all-fedora.sh
7272

73+
tests-fedora-rawhide:
74+
name: Fedora rawhide tests
75+
# We just build a container... GitHub doesn't like Fedora :(
76+
runs-on: ubuntu-latest
77+
steps:
78+
- uses: actions/checkout@v2
79+
- name: Build the container
80+
run: docker build -t fedoracontainer tss-esapi/tests/ --file tss-esapi/tests/Dockerfile-fedora-rawhide
81+
- name: Run the tests
82+
run: docker run -v $(pwd):/tmp/rust-tss-esapi -w /tmp/rust-tss-esapi/tss-esapi --security-opt seccomp=unconfined fedoracontainer dbus-run-session -- /tmp/rust-tss-esapi/tss-esapi/tests/all-fedora.sh
83+
7384
tests-valgrind:
7485
name: Valgrind test run
7586
runs-on: ubuntu-latest

tss-esapi/build.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ fn main() {
66
match tss2_esys_version.chars().next().unwrap() {
77
'2' => println!("cargo:rustc-cfg=tpm2_tss_version=\"2\""),
88
'3' => println!("cargo:rustc-cfg=tpm2_tss_version=\"3\""),
9+
'4' => println!("cargo:rustc-cfg=tpm2_tss_version=\"4\""),
910
major => panic!("Unsupported TSS version: {}", major),
1011
}
1112
}

tss-esapi/src/context/tpm_commands/object_commands.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,10 @@ impl Context {
153153
self.optional_session_3(),
154154
&private.try_into()?,
155155
&public.try_into()?,
156-
if cfg!(tpm2_tss_version = "3") {
157-
ObjectHandle::from(hierarchy).into()
158-
} else {
156+
if cfg!(tpm2_tss_version = "2") {
159157
TpmHandle::from(hierarchy).into()
158+
} else {
159+
ObjectHandle::from(hierarchy).into()
160160
},
161161
&mut object_handle,
162162
)
@@ -190,10 +190,10 @@ impl Context {
190190
self.optional_session_3(),
191191
null(),
192192
&public.try_into()?,
193-
if cfg!(tpm2_tss_version = "3") {
194-
ObjectHandle::from(hierarchy).into()
195-
} else {
193+
if cfg!(tpm2_tss_version = "2") {
196194
TpmHandle::from(hierarchy).into()
195+
} else {
196+
ObjectHandle::from(hierarchy).into()
197197
},
198198
&mut object_handle,
199199
)

tss-esapi/src/context/tpm_commands/symmetric_primitives.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,10 +279,10 @@ impl Context {
279279
self.optional_session_3(),
280280
&data.into(),
281281
hashing_algorithm.into(),
282-
if cfg!(tpm2_tss_version = "3") {
283-
ObjectHandle::from(hierarchy).into()
284-
} else {
282+
if cfg!(tpm2_tss_version = "2") {
285283
TpmHandle::from(hierarchy).into()
284+
} else {
285+
ObjectHandle::from(hierarchy).into()
286286
},
287287
&mut out_hash_ptr,
288288
&mut validation_ptr,

tss-esapi/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// SPDX-License-Identifier: Apache-2.0
33
#![deny(
44
nonstandard_style,
5-
const_err,
65
dead_code,
76
improper_ctypes,
87
non_shorthand_field_patterns,

tss-esapi/src/tcti_ldr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ impl TryFrom<TctiNameConf> for CString {
206206
if tcti_conf.is_empty() {
207207
CString::new(tcti_name).or(Err(Error::WrapperError(WrapperErrorKind::InvalidParam)))
208208
} else {
209-
CString::new(format!("{}:{}", tcti_name, tcti_conf))
209+
CString::new(format!("{tcti_name}:{tcti_conf}"))
210210
.or(Err(Error::WrapperError(WrapperErrorKind::InvalidParam)))
211211
}
212212
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FROM fedora:rawhide
2+
3+
RUN dnf install -y \
4+
tpm2-tss-devel tpm2-abrmd tpm2-tools \
5+
swtpm swtpm-tools \
6+
rust clippy cargo \
7+
llvm llvm-devel clang pkg-config \
8+
dbus-daemon

tss-esapi/tests/integration_tests/abstraction_tests/ek_tests.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use tss_esapi::{
1010

1111
use crate::common::create_ctx_without_session;
1212

13+
#[cfg_attr(tpm2_tss_version = "4", ignore = "issues with tpm2-tss")]
1314
#[test]
1415
fn test_retrieve_ek_pubcert() {
1516
let mut context = create_ctx_without_session();

tss-esapi/tests/integration_tests/abstraction_tests/nv_tests.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ fn write_nv_index(context: &mut Context, nv_index: NvIndexTpmHandle) -> NvIndexH
6060
owner_nv_index_handle
6161
}
6262

63+
#[cfg_attr(tpm2_tss_version = "4", ignore = "issues with tpm2-tss")]
6364
#[test]
6465
fn list() {
6566
let mut context = create_ctx_with_session();
@@ -85,6 +86,7 @@ fn list() {
8586
.expect("Call to nv_undefine_space failed");
8687
}
8788

89+
#[cfg_attr(tpm2_tss_version = "4", ignore = "issues with tpm2-tss")]
8890
#[test]
8991
fn read_full() {
9092
let mut context = create_ctx_with_session();

tss-esapi/tests/integration_tests/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Copyright 2021 Contributors to the Parsec project.
22
// SPDX-License-Identifier: Apache-2.0
3+
#![allow(clippy::uninlined_format_args)]
34
#[path = "common/mod.rs"]
45
mod common;
56

0 commit comments

Comments
 (0)