Skip to content

Commit

Permalink
Migrate to 2021 edition
Browse files Browse the repository at this point in the history
Also avoid suppressing some lints

Signed-off-by: Travis Finkenauer <[email protected]>
  • Loading branch information
tmfink committed Aug 9, 2024
1 parent aa0e1ea commit f24fa79
Show file tree
Hide file tree
Showing 13 changed files with 31 additions and 33 deletions.
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
[workspace]
members = ["tss-esapi", "tss-esapi-sys"]
resolver = "2"
members = ["tss-esapi", "tss-esapi-sys"]
2 changes: 1 addition & 1 deletion tss-esapi-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "tss-esapi-sys"
version = "0.5.0"
authors = ["Parsec Project Contributors"]
edition = "2018"
edition = "2021"
description = "FFI wrapper around TSS 2.0 Enhanced System API"
readme = "README.md"
keywords = ["tpm", "tss", "esys", "esapi"]
Expand Down
2 changes: 1 addition & 1 deletion tss-esapi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "tss-esapi"
version = "8.0.0-alpha"
authors = ["Parsec Project Contributors"]
edition = "2018" # TODO Update edition to 2021 - Remove the disabled lints that are due to using old edition.
edition = "2021"
description = "Rust-native wrapper around TSS 2.0 Enhanced System API"
readme = "README.md"
keywords = ["tpm", "tss", "esys", "esapi"]
Expand Down
1 change: 0 additions & 1 deletion tss-esapi/src/abstraction/transient/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ pub struct ObjectWrapper {
///
/// This abstraction makes public key cryptography more accessible, focusing on asymmetric
/// encryption and signatures in particular, by allowing users to offload object and session management.
#[allow(clippy::module_name_repetitions)]
#[derive(Debug)]
pub struct TransientKeyContext {
context: Context,
Expand Down
4 changes: 0 additions & 4 deletions tss-esapi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@
missing_copy_implementations,
rustdoc::broken_intra_doc_links,
)]
// This comes from Zeroize they changed version of Syn used
// when zeroize_derive was updated to Rust Edition 2021.
// TODO: Remove this when updating Rust Edition.
#![allow(clippy::multiple_crate_versions)]
//! # TSS 2.0 Rust Wrapper over Enhanced System API
//! This crate exposes the functionality of the TCG Software Stack Enhanced System API to
//! Rust developers, both directly through FFI bindings and through more Rust-tailored interfaces
Expand Down
3 changes: 1 addition & 2 deletions tss-esapi/src/structures/buffers/public.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ use zeroize::{Zeroize, ZeroizeOnDrop};
pub struct PublicBuffer(Vec<u8>);

impl PublicBuffer {
#[allow(unused_qualifications)]
pub const MAX_SIZE: usize = std::mem::size_of::<TPMT_PUBLIC>();
pub const MAX_SIZE: usize = size_of::<TPMT_PUBLIC>();

pub fn value(&self) -> &[u8] {
&self.0
Expand Down
3 changes: 1 addition & 2 deletions tss-esapi/src/structures/buffers/sensitive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ use zeroize::{Zeroize, ZeroizeOnDrop};
pub struct SensitiveBuffer(Vec<u8>);

impl SensitiveBuffer {
#[allow(unused_qualifications)]
pub const MAX_SIZE: usize = std::mem::size_of::<TPMT_SENSITIVE>();
pub const MAX_SIZE: usize = size_of::<TPMT_SENSITIVE>();

pub fn value(&self) -> &[u8] {
&self.0
Expand Down
3 changes: 1 addition & 2 deletions tss-esapi/src/structures/buffers/sensitive_create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ use zeroize::{Zeroize, ZeroizeOnDrop};
pub struct SensitiveCreateBuffer(Vec<u8>);

impl SensitiveCreateBuffer {
#[allow(unused_qualifications)]
pub const MAX_SIZE: usize = std::mem::size_of::<TPMS_SENSITIVE_CREATE>();
pub const MAX_SIZE: usize = size_of::<TPMS_SENSITIVE_CREATE>();
pub const MIN_SIZE: usize = 4;

/// Returns the content of the buffer.
Expand Down
6 changes: 1 addition & 5 deletions tss-esapi/src/structures/ecc/point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,7 @@ impl From<EccPoint> for TPMS_ECC_POINT {

impl From<EccPoint> for TPM2B_ECC_POINT {
fn from(ecc_point: EccPoint) -> Self {
#[allow(unused_qualifications)]
let size = std::mem::size_of::<u16>()
+ ecc_point.x().len()
+ std::mem::size_of::<u16>()
+ ecc_point.y().len();
let size = size_of::<u16>() + ecc_point.x().len() + size_of::<u16>() + ecc_point.y().len();
TPM2B_ECC_POINT {
size: size as u16,
point: ecc_point.into(),
Expand Down
3 changes: 1 addition & 2 deletions tss-esapi/src/structures/nv/storage/public.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ pub struct NvPublic {
}

impl NvPublic {
#[allow(unused_qualifications)]
const MAX_SIZE: usize = std::mem::size_of::<TPMS_NV_PUBLIC>();
const MAX_SIZE: usize = size_of::<TPMS_NV_PUBLIC>();

pub fn nv_index(&self) -> NvIndexTpmHandle {
self.nv_index
Expand Down
22 changes: 22 additions & 0 deletions tss-esapi/test_all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash

set -eux

CARGO="${CARGO:-cargo}"
export TPM2_TSS_PATH="${TPM2_TSS_PATH:-$HOME/tpm2-tss-3.2.2}"

NUM=1
t() {
echo "TEST ${NUM}"
${CARGO} t --no-run --no-default-features --features 'generate-bindings integration-tests serde'
NUM=$((NUM + 1))
}

DEFAULT=('' '--no-default-features')

for X in "${DEFAULT[@]}" ; do
t $X --features 'generate-bindings'
t $X --features 'generate-bindings integration-tests'
t $X --features 'generate-bindings integration-tests serde'
t $X --features 'generate-bindings integration-tests serde abstraction'
done
11 changes: 0 additions & 11 deletions tss-esapi/tests/integration_tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,13 @@ pub use tpml_types_equality_checks::*;
pub use tpms_types_equality_checks::*;
pub use tpmt_types_equality_checks::*;

#[allow(dead_code)]
pub const HASH: [u8; 64] = [
0x69, 0x3E, 0xDB, 0x1B, 0x22, 0x79, 0x03, 0xF4, 0xC0, 0xBF, 0xD6, 0x91, 0x76, 0x37, 0x84, 0x69,
0x3E, 0xDB, 0x1B, 0x22, 0x79, 0x03, 0xF4, 0xC0, 0xBF, 0xD6, 0x91, 0x76, 0x37, 0x84, 0xA2, 0x94,
0x8E, 0x92, 0x50, 0x35, 0xC2, 0x8C, 0x5C, 0x3C, 0xCA, 0xFE, 0x18, 0xE8, 0x81, 0xA2, 0x94, 0x8E,
0x92, 0x50, 0x35, 0xC2, 0x8C, 0x5C, 0x3C, 0xCA, 0xFE, 0x18, 0xE8, 0x81, 0x37, 0x78, 0x37, 0x78,
];

#[allow(dead_code)]
pub const KEY: [u8; 256] = [
231, 97, 201, 180, 0, 1, 185, 150, 85, 90, 174, 188, 105, 133, 188, 3, 206, 5, 222, 71, 185, 1,
209, 243, 36, 130, 250, 116, 17, 0, 24, 4, 25, 225, 250, 198, 245, 210, 140, 23, 139, 169, 15,
Expand Down Expand Up @@ -178,14 +176,12 @@ pub fn sensitives() -> [Sensitive; 4] {
}

static LOG_INIT: Once = Once::new();
#[allow(dead_code)]
pub fn setup_logging() {
LOG_INIT.call_once(|| {
env_logger::init();
});
}

#[allow(dead_code)]
pub fn create_tcti() -> TctiNameConf {
setup_logging();

Expand All @@ -195,13 +191,11 @@ pub fn create_tcti() -> TctiNameConf {
}
}

#[allow(dead_code)]
pub fn create_ctx_without_session() -> Context {
let tcti = create_tcti();
Context::new(tcti).unwrap()
}

#[allow(dead_code)]
pub fn create_ctx_with_session() -> Context {
let mut ctx = create_ctx_without_session();
let session = ctx
Expand Down Expand Up @@ -229,7 +223,6 @@ pub fn create_ctx_with_session() -> Context {
ctx
}

#[allow(dead_code)]
pub fn decryption_key_pub() -> Public {
utils::create_restricted_decryption_rsa_public(
Cipher::aes_256_cfb()
Expand All @@ -241,7 +234,6 @@ pub fn decryption_key_pub() -> Public {
.expect("Failed to create a restricted decryption rsa public structure")
}

#[allow(dead_code)]
pub fn encryption_decryption_key_pub() -> Public {
utils::create_unrestricted_encryption_decryption_rsa_public(
RsaKeyBits::Rsa2048,
Expand All @@ -250,7 +242,6 @@ pub fn encryption_decryption_key_pub() -> Public {
.expect("Failed to create an unrestricted encryption decryption rsa public structure")
}

#[allow(dead_code)]
pub fn signing_key_pub() -> Public {
utils::create_unrestricted_signing_rsa_public(
RsaScheme::create(RsaSchemeAlgorithm::RsaSsa, Some(HashingAlgorithm::Sha256))
Expand All @@ -261,7 +252,6 @@ pub fn signing_key_pub() -> Public {
.expect("Failed to create an unrestricted signing rsa public structure")
}

#[allow(dead_code)]
pub fn get_pcr_policy_digest(
context: &mut Context,
mangle: bool,
Expand Down Expand Up @@ -415,7 +405,6 @@ pub fn get_pcr_policy_digest(
}
}

#[allow(dead_code)]
pub fn create_public_sealed_object() -> Public {
let object_attributes = ObjectAttributesBuilder::new()
.with_fixed_tpm(true)
Expand Down
1 change: 0 additions & 1 deletion tss-esapi/tests/integration_tests/tcti_ldr_tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use std::env;
use std::str::FromStr;
use tss_esapi::tcti_ldr::TctiNameConf;

#[allow(dead_code)]
pub fn name_conf() -> TctiNameConf {
match env::var("TEST_TCTI") {
Err(_) => TctiNameConf::Mssim(Default::default()),
Expand Down

0 comments on commit f24fa79

Please sign in to comment.