Skip to content

Commit aeef543

Browse files
committed
Re-exported the 'json' crate from this crate, because it is used in the public interface.
1 parent f66d1a1 commit aeef543

File tree

7 files changed

+98
-143
lines changed

7 files changed

+98
-143
lines changed

.github/workflows/cargo-workflow.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ jobs:
109109
packages: libtss2-dev uuid-dev libjson-c-dev libcurl4-openssl-dev
110110
- run: |
111111
make docker.swtpm DETACH=1
112-
make tests RUST_LOG=info TSS2_LOG=all+none FAPI_RS_TEST_PROF=${{ matrix.profile }}
112+
make tests FAPI_RS_TEST_PROF=${{ matrix.profile }}
113113
make docker.down
114114
115115
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](http://keepachangelog.com/).
66

7+
## [0.8.1] - 2026-01-15
8+
9+
### Added
10+
11+
- Re-exported the `json` crate from this crate, because it is used in the public interface.
12+
13+
### Changed
14+
15+
- Simplified some public data types by using `#[non_exhaustive]` attribute where applicable.
16+
- Various improvements to the validation of "flag" parameters.
17+
718
## [0.8.0] - 2026-01-15
819

920
### Added

Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ fixup: check
1717
cargo clippy --all-features --all-targets
1818

1919
tests:
20-
CARGO_PROFILE_RELEASE_DEBUG=true \
21-
RUST_BACKTRACE=1 \
20+
CARGO_PROFILE_RELEASE_DEBUG=true RUST_BACKTRACE=1 RUST_LOG=info TSS2_LOG="all+none" \
2221
cargo test --release --tests --locked -- --test-threads=1
2322

2423
build:

src/context.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use crate::{
2121
self, FAPI_CONTEXT, TPM2_RC, TSS2_RC,
2222
constants::{self, TSS2_RC_SUCCESS},
2323
},
24-
flags::flags_to_string,
24+
flags::Flags,
2525
json::{self, JsonValue},
2626
locking::LockGuard,
2727
marshal::u64_from_be,
@@ -276,7 +276,7 @@ impl FapiContext {
276276
fail_if_opt_empty!(key_type);
277277

278278
let cstr_path = CStringHolder::try_from(key_path)?;
279-
let cstr_type = CStringHolder::try_from(flags_to_string(key_type)?)?;
279+
let cstr_type = CStringHolder::try_from(Flags::as_string(key_type)?)?;
280280
let cstr_poli = CStringHolder::try_from(pol_path)?;
281281
let cstr_auth = CStringHolder::try_from(auth_val)?;
282282

@@ -394,7 +394,7 @@ impl FapiContext {
394394
fail_if_opt_empty!(nvi_type);
395395

396396
let cstr_path = CStringHolder::try_from(nv_path)?;
397-
let cstr_type = CStringHolder::try_from(flags_to_string(nvi_type)?)?;
397+
let cstr_type = CStringHolder::try_from(Flags::as_string(nvi_type)?)?;
398398
let cstr_poli = CStringHolder::try_from(pol_path)?;
399399
let cstr_auth = CStringHolder::try_from(auth_val)?;
400400

@@ -541,7 +541,7 @@ impl FapiContext {
541541
fail_if_opt_empty!(quote_type, qualifying_data);
542542

543543
let cstr_path = CStringHolder::try_from(key_path)?;
544-
let cstr_type = CStringHolder::try_from(flags_to_string(quote_type)?)?;
544+
let cstr_type = CStringHolder::try_from(Flags::as_string(quote_type)?)?;
545545

546546
let mut quote_info: *mut c_char = ptr::null_mut();
547547
let mut signature_data: *mut u8 = ptr::null_mut();
@@ -672,7 +672,7 @@ impl FapiContext {
672672
fail_if_empty!(digest);
673673

674674
let cstr_path = CStringHolder::try_from(key_path)?;
675-
let cstr_algo = CStringHolder::try_from(flags_to_string(pad_algo)?)?;
675+
let cstr_algo = CStringHolder::try_from(Flags::as_string(pad_algo)?)?;
676676

677677
let mut signature_data: *mut u8 = ptr::null_mut();
678678
let mut signature_size: usize = 0;
@@ -739,7 +739,7 @@ impl FapiContext {
739739
fail_if_opt_empty!(data);
740740

741741
let cstr_path = CStringHolder::try_from(path)?;
742-
let cstr_type = CStringHolder::try_from(flags_to_string(seal_type)?)?;
742+
let cstr_type = CStringHolder::try_from(Flags::as_string(seal_type)?)?;
743743
let cstr_poli = CStringHolder::try_from(pol_path)?;
744744
let cstr_auth = CStringHolder::try_from(auth_val)?;
745745

src/error.rs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ use crate::fapi_sys::{TSS2_RC, constants};
99
const LAYER_BIT_MASK: u32 = 0x0000FFFF;
1010

1111
/// The error type for FAPI operations, used by the [`FapiContext`](crate::FapiContext) struct.
12-
#[derive(Debug, PartialEq)]
12+
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
13+
#[non_exhaustive]
1314
pub enum ErrorCode {
1415
TpmError(Tpm2ErrorCode),
1516
FapiError(BaseErrorCode),
@@ -24,7 +25,8 @@ pub enum ErrorCode {
2425
}
2526

2627
/// Generic TSS2 error codes.
27-
#[derive(Debug, PartialEq)]
28+
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
29+
#[non_exhaustive]
2830
pub enum BaseErrorCode {
2931
GeneralFailure,
3032
NotImplemented,
@@ -84,7 +86,8 @@ pub enum BaseErrorCode {
8486
}
8587

8688
/// TPM 2.0 response code wrapper.
87-
#[derive(Debug, PartialEq)]
89+
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
90+
#[non_exhaustive]
8891
pub enum Tpm2ErrorCode {
8992
Tpm2ErrFmt0(Tpm2ErrFmt0),
9093
Tpm2ErrFmt1(Tpm2ErrFmt1),
@@ -93,7 +96,8 @@ pub enum Tpm2ErrorCode {
9396
}
9497

9598
/// TPM 2.0 "format zero" response codes.
96-
#[derive(Debug, PartialEq)]
99+
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
100+
#[non_exhaustive]
97101
pub enum Tpm2ErrFmt0 {
98102
Initialize,
99103
Failure,
@@ -133,7 +137,8 @@ pub enum Tpm2ErrFmt0 {
133137
}
134138

135139
/// TPM 2.0 "format one" response codes.
136-
#[derive(Debug, PartialEq)]
140+
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
141+
#[non_exhaustive]
137142
pub enum Tpm2ErrFmt1 {
138143
Asymmetric,
139144
Attributes,
@@ -172,7 +177,8 @@ pub enum Tpm2ErrFmt1 {
172177
}
173178

174179
/// TPM 2.0 "warning" response codes.
175-
#[derive(Debug, PartialEq)]
180+
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
181+
#[non_exhaustive]
176182
pub enum Tpm2Warning {
177183
ContextGap,
178184
ObjectMemory,
@@ -206,7 +212,8 @@ pub enum Tpm2Warning {
206212
}
207213

208214
/// Internal error codes.
209-
#[derive(Debug, PartialEq)]
215+
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
216+
#[non_exhaustive]
210217
pub enum InternalError {
211218
NoResultData,
212219
InvalidArguments,

0 commit comments

Comments
 (0)