Skip to content

Commit a0d39dd

Browse files
authored
Merge pull request #387 from ionut-arm/v4
Allow use with v4 of tpm2-tss
2 parents 5657f7c + 767c685 commit a0d39dd

File tree

17 files changed

+52
-27
lines changed

17 files changed

+52
-27
lines changed

.github/workflows/ci.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
- name: Build the container
3333
run: docker build -t ubuntucontainer tss-esapi/tests/ --file tss-esapi/tests/Dockerfile-ubuntu
3434
- name: Run the container
35-
run: docker run -v $(pwd):/tmp/rust-tss-esapi -w /tmp/rust-tss-esapi/tss-esapi --env RUST_TOOLCHAIN_VERSION=1.53.0 ubuntucontainer /tmp/rust-tss-esapi/tss-esapi/tests/all-ubuntu.sh
35+
run: docker run -v $(pwd):/tmp/rust-tss-esapi -w /tmp/rust-tss-esapi/tss-esapi --env RUST_TOOLCHAIN_VERSION=1.56.0 ubuntucontainer /tmp/rust-tss-esapi/tss-esapi/tests/all-ubuntu.sh
3636
# All in one job as I think it is a big overhead to build and run the Docker
3737
# container?
3838
tests-ubuntu:
@@ -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

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ At the moment we test (via CI) and support the following Rust compiler versions:
99

1010
* On Ubuntu we test with:
1111
- The latest stable compiler version, as accessible through `rustup`.
12-
- The 1.53 compiler version.
12+
- The 1.56 compiler version.
1313
* On Fedora we test with the compiler version included with the Fedora 35 release.
1414

1515
If you need support for other versions of the compiler, get in touch with us to see what we can do!

tss-esapi-sys/build.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ fn main() {
5757
}
5858
}
5959

60+
#[allow(clippy::uninlined_format_args)]
6061
#[cfg(feature = "generate-bindings")]
6162
pub fn generate_from_system(esapi_out: PathBuf) {
6263
pkg_config::Config::new()

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/constants/response_code.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ bitfield! {
1616
}
1717

1818
bitfield! {
19-
#[derive(PartialEq, Copy, Clone)]
19+
#[derive(PartialEq, Eq, Copy, Clone)]
2020
pub struct FormatZeroResponseCode(TSS2_RC);
2121
impl Debug;
2222
error_number, _: 6, 0;
@@ -36,7 +36,7 @@ impl std::fmt::Display for FormatZeroResponseCode {
3636
impl std::error::Error for FormatZeroResponseCode {}
3737

3838
bitfield! {
39-
#[derive(PartialEq, Copy, Clone)]
39+
#[derive(PartialEq, Eq, Copy, Clone)]
4040
pub struct FormatOneResponseCode(TSS2_RC);
4141
impl Debug;
4242
error_number, _: 5, 0;
@@ -56,7 +56,7 @@ impl std::error::Error for FormatOneResponseCode {}
5656

5757
/// Rust native representation of the TSS2 response codes as defined in the spec.
5858
#[allow(clippy::module_name_repetitions)]
59-
#[derive(Copy, Clone, PartialEq, Debug)]
59+
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
6060
pub enum Tss2ResponseCode {
6161
Success,
6262
FormatZero(FormatZeroResponseCode),
@@ -234,7 +234,7 @@ impl Tss2ResponseCode {
234234
}
235235

236236
/// Rust enum representation of TSS 2 error codes.
237-
#[derive(PartialEq, Copy, Clone, Debug)]
237+
#[derive(PartialEq, Eq, Copy, Clone, Debug)]
238238
pub enum Tss2ResponseCodeKind {
239239
// FormatZero errors
240240
Success,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ impl Context {
430430
self.optional_session_3(),
431431
&object_name.into(),
432432
&new_parent_name.into(),
433-
if include_object { 1 } else { 0 },
433+
u8::from(include_object),
434434
)
435435
};
436436
let ret = Error::from_tss_rc(ret);

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/error.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use crate::tss2_esys::TSS2_RC;
77
/// layer.
88
pub type Result<T> = std::result::Result<T, Error>;
99

10-
#[derive(Copy, Clone, PartialEq, Debug)]
10+
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
1111
pub enum Error {
1212
WrapperError(WrapperErrorKind),
1313
Tss2Error(Tss2ResponseCode),
@@ -51,7 +51,7 @@ impl std::error::Error for Error {
5151
}
5252

5353
/// List of error types that might occur in the wrapper.
54-
#[derive(Copy, Clone, PartialEq, Debug)]
54+
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
5555
pub enum WrapperErrorKind {
5656
/// Returned when a size or length-defined parameter does not conform with the size
5757
/// restrictions for it.

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,

0 commit comments

Comments
 (0)