Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adds a signature::Signer interface #537

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
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
30 changes: 24 additions & 6 deletions tss-esapi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ required-features = ["abstraction"]
[dependencies]
bitfield = "0.17.0"
serde = { version = "1.0.115", features = [
"alloc",
"derive",
], optional = true, default-features = false }
malloced = "1.3.1"
Expand All @@ -33,9 +34,22 @@ hostname-validator = "1.1.0"
regex = "1.3.9"
zeroize = { version = "1.5.7", features = ["zeroize_derive"] }
tss-esapi-sys = { path = "../tss-esapi-sys", version = "0.5.0" }
oid = { version = "0.2.1", optional = true }
picky-asn1 = { version = "0.9.0", optional = true }
picky-asn1-x509 = { version = "0.13.0", optional = true }
x509-cert = { version = "0.2.0", optional = true }
ecdsa = { version = "0.16.9", features = ["der", "hazmat", "arithmetic", "verifying"], optional = true }
elliptic-curve = { version = "0.13.8", optional = true, features = ["alloc", "pkcs8"] }
p192 = { version = "0.13.0", optional = true }
p224 = { version = "0.13.2", optional = true }
p256 = { version = "0.13.2", optional = true }
p384 = { version = "0.13.0", optional = true }
p521 = { version = "0.13.3", optional = true }
rsa = { version = "0.9", optional = true }
sha1 = { version = "0.10.6", optional = true }
sha2 = { version = "0.10.8", optional = true }
sha3 = { version = "0.10.8", optional = true }
sm2 = { version = "0.13.3", optional = true }
sm3 = { version = "0.4.2", optional = true }
digest = "0.10.7"
signature = { version = "2.2.0", features = ["std"], optional = true}
cfg-if = "1.0.0"
strum = { version = "0.26.3", optional = true }
strum_macros = { version = "0.26.4", optional = true }
Expand All @@ -44,20 +58,24 @@ getrandom = "0.2.11"

[dev-dependencies]
env_logger = "0.11.5"
sha2 = "0.10.1"
serde_json = "^1.0.108"
sha2 = { version = "0.10.8", features = ["oid"] }
tss-esapi = { path = ".", features = [
"integration-tests",
"serde",
"abstraction",
"rustcrypto-full",
] }

x509-cert = { version = "0.2.0", features = ["builder"] }

[build-dependencies]
semver = "1.0.7"

[features]
default = ["abstraction"]
generate-bindings = ["tss-esapi-sys/generate-bindings"]
abstraction = ["oid", "picky-asn1", "picky-asn1-x509"]
abstraction = ["rustcrypto"]
integration-tests = ["strum", "strum_macros"]

rustcrypto = ["ecdsa", "elliptic-curve", "signature", "x509-cert"]
rustcrypto-full = ["rustcrypto", "p192", "p224", "p256", "p384", "p521", "rsa", "sha1", "sha2", "sha3", "sm2", "sm3"]
50 changes: 50 additions & 0 deletions tss-esapi/src/abstraction/hashing.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// Copyright 2024 Contributors to the Parsec project.
// SPDX-License-Identifier: Apache-2.0

use crate::interface_types::algorithm::HashingAlgorithm;

/// Provides the value of the digest used in this crate for the digest.
pub trait AssociatedHashingAlgorithm {
/// Value of the digest when interacting with the TPM.
const TPM_DIGEST: HashingAlgorithm;
}

#[cfg(all(feature = "rustcrypto", feature = "sha1"))]
impl AssociatedHashingAlgorithm for sha1::Sha1 {
const TPM_DIGEST: HashingAlgorithm = HashingAlgorithm::Sha1;
}

#[cfg(all(feature = "rustcrypto", feature = "sha2"))]
impl AssociatedHashingAlgorithm for sha2::Sha256 {
const TPM_DIGEST: HashingAlgorithm = HashingAlgorithm::Sha256;
}

#[cfg(all(feature = "rustcrypto", feature = "sha2"))]
impl AssociatedHashingAlgorithm for sha2::Sha384 {
const TPM_DIGEST: HashingAlgorithm = HashingAlgorithm::Sha384;
}

#[cfg(all(feature = "rustcrypto", feature = "sha2"))]
impl AssociatedHashingAlgorithm for sha2::Sha512 {
const TPM_DIGEST: HashingAlgorithm = HashingAlgorithm::Sha512;
}

#[cfg(all(feature = "rustcrypto", feature = "sm3"))]
impl AssociatedHashingAlgorithm for sm3::Sm3 {
const TPM_DIGEST: HashingAlgorithm = HashingAlgorithm::Sm3_256;
}

#[cfg(all(feature = "rustcrypto", feature = "sha3"))]
impl AssociatedHashingAlgorithm for sha3::Sha3_256 {
const TPM_DIGEST: HashingAlgorithm = HashingAlgorithm::Sha3_256;
}

#[cfg(all(feature = "rustcrypto", feature = "sha3"))]
impl AssociatedHashingAlgorithm for sha3::Sha3_384 {
const TPM_DIGEST: HashingAlgorithm = HashingAlgorithm::Sha3_384;
}

#[cfg(all(feature = "rustcrypto", feature = "sha3"))]
impl AssociatedHashingAlgorithm for sha3::Sha3_512 {
const TPM_DIGEST: HashingAlgorithm = HashingAlgorithm::Sha3_512;
}
4 changes: 4 additions & 0 deletions tss-esapi/src/abstraction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ pub mod pcr;
pub mod public;
pub mod transient;

mod hashing;
mod signatures;
pub use hashing::AssociatedHashingAlgorithm;

use std::convert::TryFrom;

use crate::{
Expand Down
Loading