Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
name: Check spelling
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Check spelling
uses: codespell-project/actions-codespell@v1
with:
Expand All @@ -19,15 +19,15 @@ jobs:
name: Check formatting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Check formatting
run: cargo fmt --all -- --check
# Check that it builds with the Minimum Supported Rust Version
msrv:
name: Check minimum supported rust version (MSRV)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Build the container
run: docker build -t ubuntucontainer tss-esapi/tests/ --file tss-esapi/tests/Dockerfile-ubuntu --target tpm2-tools
- name: Run the container
Expand All @@ -38,7 +38,7 @@ jobs:
name: Ubuntu tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Build the container
run: docker build -t ubuntucontainer tss-esapi/tests/ --file tss-esapi/tests/Dockerfile-ubuntu --target tpm2-tools
- name: Run the container
Expand All @@ -50,7 +50,7 @@ jobs:
name: Ubuntu tests on v4.x.y of tpm2-tss libraries found using pkg-config --target tpm2-tools
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Build the container
run: docker build -t ubuntucontainer tss-esapi/tests/ --build-arg TPM2_TSS_VERSION=4.1.3 --file tss-esapi/tests/Dockerfile-ubuntu --target tpm2-tools
- name: Run the container
Expand All @@ -60,7 +60,7 @@ jobs:
name: Ubuntu tests on v4.x.y of tpm2-tss libraries found using a path
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Build the container
run: docker build -t ubuntucontainer tss-esapi/tests/ --build-arg TPM2_TSS_VERSION=4.0.1 --file tss-esapi/tests/Dockerfile-ubuntu --target tpm2-tss-install-dir
- name: Run the container
Expand All @@ -71,7 +71,7 @@ jobs:
# We just build a container... GitHub doesn't like Fedora :(
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Build the container
run: docker build -t fedoracontainer tss-esapi/tests/ --file tss-esapi/tests/Dockerfile-fedora
- name: Run the tests
Expand All @@ -82,18 +82,17 @@ jobs:
# We just build a container... GitHub doesn't like Fedora :(
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Build the container
run: docker build -t fedoracontainer tss-esapi/tests/ --file tss-esapi/tests/Dockerfile-fedora-rawhide
- name: Run the tests
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

# SEE #558 : remove use of 1.82 once 1.84 rolls out;
tests-valgrind:
name: Valgrind test run
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Build the container
run: docker build -t ubuntucontainer tss-esapi/tests/ --file tss-esapi/tests/Dockerfile-ubuntu --target tpm2-tools
- name: Run the tests
Expand All @@ -104,7 +103,7 @@ jobs:
name: Check documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Build the container
run: docker build -t ubuntucontainer tss-esapi/tests/ --file tss-esapi/tests/Dockerfile-ubuntu --target tpm2-tools
- name: Check documentation
Expand All @@ -115,7 +114,7 @@ jobs:
name: Check Clippy lints
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Build the container
run: docker build -t ubuntucontainer tss-esapi/tests/ --file tss-esapi/tests/Dockerfile-ubuntu --target tpm2-tss
- name: Check Clippy lints MSRV
Expand Down
69 changes: 26 additions & 43 deletions tss-esapi-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub mod target {
/// Ensures that the `TARGET` is valid for cross compilation.
pub fn ensure_supported() {
let target = Triple::from_str(&std::env::var(TARGET_ENV_VAR_NAME).unwrap_or_else(|_| {
panic!("Missing environment variable `{}`.", TARGET_ENV_VAR_NAME);
panic!("Missing environment variable `{TARGET_ENV_VAR_NAME}`.");
}))
.expect("Failed to parse target triple.");
match (target.architecture, target.operating_system) {
Expand All @@ -37,10 +37,9 @@ pub mod target {
| (Architecture::X86_64, OperatingSystem::Linux) => {}
(arch, os) => {
panic!(
"Compilation target (architecture, OS) tuple ({}, {}) is not part of the \
"Compilation target (architecture, OS) tuple ({arch}, {os}) is not part of the \
supported tuples. Please compile with the \"generate-bindings\" feature or \
add support for your platform.",
arch, os
add support for your platform."
);
}
}
Expand Down Expand Up @@ -163,10 +162,7 @@ pub mod tpm2_tss {
std::env::var(PATH_ENV_VAR_NAME).map_or_else(
|e| match e {
std::env::VarError::NotUnicode(invalid_value) => {
panic!(
"Invalid `{}` env var: `{:?}`.",
PATH_ENV_VAR_NAME, invalid_value
);
panic!("Invalid `{PATH_ENV_VAR_NAME}` env var: `{invalid_value:?}`.");
}
std::env::VarError::NotPresent => None,
},
Expand Down Expand Up @@ -196,64 +192,53 @@ pub mod tpm2_tss {
let install_path = PathBuf::from(env_var);
if !install_path.is_dir() {
panic!(
"The tpm2-tss installation path `{}` specifies an existing directory (`{}`).",
PATH_ENV_VAR_NAME,
install_path.to_string_lossy(),
"The tpm2-tss installation path `{PATH_ENV_VAR_NAME}` specifies an existing directory (`{}`).",
install_path.to_string_lossy()
);
}
if !install_path.join("include").is_dir() {
panic!(
"The tpm2-tss installation path `{}` specifies a path `{}`, that does not \
"The tpm2-tss installation path `{PATH_ENV_VAR_NAME}` specifies a path `{}`, that does not \
contain an `include` directory",
PATH_ENV_VAR_NAME,
install_path.to_string_lossy(),
install_path.to_string_lossy()
);
}
if !install_path.join("lib").is_dir() {
panic!(
"The tpm2-tss installation path `{}` specifies a path `{}`, that does not \
"The tpm2-tss installation path `{PATH_ENV_VAR_NAME}` specifies a path `{}`, that does not \
contain an `lib` directory",
PATH_ENV_VAR_NAME,
install_path.to_string_lossy(),
install_path.to_string_lossy()
);
}
let version_str =
std::fs::read_to_string(install_path.join("VERSION")).unwrap_or_else(|e| {
panic!(
"The tpm2-tss installation path `{}` specifies a path `{}`, that does not \
contain a readable VERSION file: {}.",
PATH_ENV_VAR_NAME,
install_path.to_string_lossy(),
e,
"The tpm2-tss installation path `{PATH_ENV_VAR_NAME}` specifies a path `{}`, that does not \
contain a readable VERSION file: {e}.",
install_path.to_string_lossy()
);
});
let version = Version::parse(version_str.trim()).unwrap_or_else(|e| {
panic!(
"The tpm2-tss installation path `{}` specifies a path `{}`, contains a \
VERSION file that cannot be parsed: {}.",
PATH_ENV_VAR_NAME,
install_path.to_string_lossy(),
e
"The tpm2-tss installation path `{PATH_ENV_VAR_NAME}` specifies a path `{}`, contains a \
VERSION file that cannot be parsed: {e}.",
install_path.to_string_lossy()
);
});

let min_version_req_str = format!(">={}", MINIMUM_VERSION);
let min_version_req_str = format!(">={MINIMUM_VERSION}");
let min_version_req = VersionReq::parse(&min_version_req_str).unwrap_or_else(|e| {
panic!(
"[Internal Error]: Failed to parse minimum tpm2-tss library version \
requirement. Error: `{}`. Please report this.",
e
requirement. Error: `{e}`. Please report this."
);
});
if !min_version_req.matches(&version) {
panic!(
"The tpm2-tss installation path `{}` specifies a path `{}`, contains a \
VERSION file that specifies a version `{}` that does not meet the minimum \
version requirement `{}`.",
PATH_ENV_VAR_NAME,
install_path.to_string_lossy(),
version_str,
MINIMUM_VERSION,
"The tpm2-tss installation path `{PATH_ENV_VAR_NAME}` specifies a path `{}`, contains a \
VERSION file that specifies a version `{version_str}` that does not meet the minimum \
version requirement `{MINIMUM_VERSION}`.",
install_path.to_string_lossy()
);
}
println!(
Expand Down Expand Up @@ -296,8 +281,7 @@ pub mod tpm2_tss {
Self::probe_optional(lib_name, install_path, with_header_files).map_or_else(
|| {
panic!(
"Failed to find {} library of version {MINIMUM_VERSION} or greater.",
lib_name
"Failed to find {lib_name} library of version {MINIMUM_VERSION} or greater."
)
},
|lib| {
Expand Down Expand Up @@ -356,7 +340,7 @@ pub mod tpm2_tss {
self.name
);
},
|v| format!("-I{}", v),
|v| format!("-I{v}"),
)
}

Expand Down Expand Up @@ -436,7 +420,7 @@ pub mod tpm2_tss {
let lib_path = path.join("lib");
Self::lib_file(lib_name, &lib_path)?;
// If the lib file was found then the name is reported to Cargo.
println!("cargo:rustc-link-lib={}", lib_name);
println!("cargo:rustc-link-lib={lib_name}");

let include_path = path.join("include/tss2");
Some(Self {
Expand Down Expand Up @@ -481,8 +465,7 @@ pub mod tpm2_tss {
let mut associated_files = hit_iter.collect::<Vec<PathBuf>>();
associated_files.push(hit.clone());
panic!(
"More then one match found for library `{}`: {:?}",
lib_name, associated_files
"More then one match found for library `{lib_name}`: {associated_files:?}",
);
}
}
Expand Down
3 changes: 1 addition & 2 deletions tss-esapi/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ fn main() {

assert!(
supported_tss_version.matches(&tss_version),
"Unsupported TSS version {}",
tss_version
"Unsupported TSS version {tss_version}"
);

let hierarchy_is_esys_tr_req = VersionReq::parse(">=3.0.0").unwrap();
Expand Down
8 changes: 4 additions & 4 deletions tss-esapi/examples/certify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ fn main() {
// Alternately on the CLI you can view the certificate with:
// # tpm2_getekcertificate | openssl x509 -inform DER -noout -text

eprintln!("ek_pubcert der: {:x?}", ek_pubcert);
eprintln!("ek_pubcert der: {ek_pubcert:x?}");

// Retrieve the EK public template that allows us to access a handle to the EK
let ek_template = create_ek_public_from_default_template(ek_alg, None).unwrap();
Expand Down Expand Up @@ -495,8 +495,8 @@ fn main() {
.flush_context(SessionHandle::from(aik_auth_session).into())
.expect("Failed to clear policy_auth_session");

println!("attest: {:?}", attest);
println!("signature: {:?}", signature);
println!("attest: {attest:?}");
println!("signature: {signature:?}");

// ================================================================================
// Now back on our certifying authority, we want to assert that the attestation we
Expand Down Expand Up @@ -537,7 +537,7 @@ fn main() {
})
.expect("Failed to verify attestation");

println!("verification: {:?}", verified_ticket);
println!("verification: {verified_ticket:?}");
}

fn create_key(context: &mut Context) -> KeyHandle {
Expand Down
10 changes: 5 additions & 5 deletions tss-esapi/examples/duplication.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ fn main() {
)
})
.map_err(|err| {
eprintln!("⚠️ {}", err);
eprintln!("⚠️ {err}");
err
})
.unwrap();
Expand Down Expand Up @@ -269,7 +269,7 @@ fn main() {
ctx.create(loaded_storage_key, hmac_public, None, None, None, None)
})
.map_err(|err| {
eprintln!("⚠️ {}", err);
eprintln!("⚠️ {err}");
err
})
.unwrap();
Expand Down Expand Up @@ -371,7 +371,7 @@ fn main() {
result
})
.map_err(|err| {
eprintln!("⚠️ {}", err);
eprintln!("⚠️ {err}");
err
})
.unwrap();
Expand Down Expand Up @@ -434,8 +434,8 @@ fn main() {
})
.unwrap();

println!("hmac1 = {:?}", hmac1);
println!("hmac2 = {:?}", hmac2);
println!("hmac1 = {hmac1:?}");
println!("hmac2 = {hmac2:?}");
// They are the same!
assert_eq!(hmac1, hmac2);
}
Expand Down
10 changes: 5 additions & 5 deletions tss-esapi/examples/duplication_secret.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ fn main() {
)
})
.map_err(|err| {
eprintln!("⚠️ {}", err);
eprintln!("⚠️ {err}");
err
})
.unwrap();
Expand Down Expand Up @@ -268,7 +268,7 @@ fn main() {
ctx.create(loaded_storage_key, hmac_public, None, None, None, None)
})
.map_err(|err| {
eprintln!("⚠️ {}", err);
eprintln!("⚠️ {err}");
err
})
.unwrap();
Expand Down Expand Up @@ -364,7 +364,7 @@ fn main() {
result
})
.map_err(|err| {
eprintln!("⚠️ {}", err);
eprintln!("⚠️ {err}");
err
})
.unwrap();
Expand Down Expand Up @@ -428,8 +428,8 @@ fn main() {
})
.unwrap();

println!("hmac1 = {:?}", hmac1);
println!("hmac2 = {:?}", hmac2);
println!("hmac1 = {hmac1:?}");
println!("hmac2 = {hmac2:?}");
// They are the same!
assert_eq!(hmac1, hmac2);
}
Expand Down
4 changes: 2 additions & 2 deletions tss-esapi/examples/hmac.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ fn main() {
})
.unwrap();

println!("hmac1 = {:?}", hmac1);
println!("hmac2 = {:?}", hmac2);
println!("hmac1 = {hmac1:?}");
println!("hmac2 = {hmac2:?}");
// They are the same!
assert_eq!(hmac1, hmac2);
}
Loading