Skip to content

Commit c806f3f

Browse files
hug-devionut-arm
andcommitted
Add a TPM provider
This provider uses the tss-esapi crate to interface with a TSS 2.0 Enhanced System library. Adds new configuration entries to select the TPM provider and which TCTI device to use. The TPM provider currently only supports RSA key, signing and verifying operations. Co-authored-by: Ionut Mihalcea <[email protected]> Signed-off-by: Hugues de Valon <[email protected]>
1 parent b7312dc commit c806f3f

File tree

8 files changed

+664
-193
lines changed

8 files changed

+664
-193
lines changed

Cargo.lock

+142-184
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+5-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ name = "parsec"
1111
path = "src/bin/main.rs"
1212

1313
[dependencies]
14-
parsec-interface = { git = "https://github.com/parallaxsecond/parsec-interface-rs", tag = "0.3.0" }
14+
parsec-interface = { git = "https://github.com/parallaxsecond/parsec-interface-rs", tag = "0.4.0" }
1515
rand = "0.7.2"
1616
base64 = "0.10.1"
1717
uuid = "0.7.4"
@@ -26,12 +26,12 @@ log = { version = "0.4.8", features = ["serde"] }
2626
pkcs11 = { version = "0.4.0", optional = true }
2727
# Using a fork of the serde_asn1_der crate to have big integer support. Check https://github.com/KizzyCode/serde_asn1_der/issues/1
2828
serde_asn1_der = { git = "https://github.com/Devolutions/serde_asn1_der", rev = "ec1035879034ac9f09f1242fb49ed04c9aecdcae", optional = true, features = ["extra_types"] }
29-
der-parser = "3.0.2"
30-
nom = "5.0.1"
3129
num-bigint-dig = "0.5"
30+
tss-esapi = { git = "https://github.com/parallaxsecond/rust-tss-esapi", tag = "0.4.0", optional = true }
31+
bincode = "1.1.4"
3232

3333
[dev-dependencies]
34-
parsec-client-test = { git = "https://github.com/parallaxsecond/parsec-client-test", tag = "0.1.7" }
34+
parsec-client-test = { git = "https://github.com/parallaxsecond/parsec-client-test", tag = "0.1.8" }
3535
num_cpus = "1.10.1"
3636

3737
[build-dependencies]
@@ -47,3 +47,4 @@ mbed-crypto-version = "mbedcrypto-2.0.0"
4747
default = ["mbed-crypto-provider", "pkcs11-provider"]
4848
mbed-crypto-provider = []
4949
pkcs11-provider = ["pkcs11", "serde_asn1_der"]
50+
tpm-provider = ["tss-esapi", "serde_asn1_der"]

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ This project uses the following third party crates:
9999
* pkcs11 (Apache-2.0)
100100
* a fork of serde\_asn1\_der at `https://github.com/Devolutions/serde_asn1_der` (BSD-3-Clause and MIT)
101101
* num-bigint-dig (MIT and Apache-2.0)
102+
* bincode (MIT)
102103

103104
This project uses the following third party libraries:
104105
* [Mbed Crypto](https://github.com/ARMmbed/mbed-crypto) (Apache-2.0)

config.toml

+10
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,13 @@ key_id_manager = "on-disk-manager"
5959
# (Optional) User pin for authentication with the specific slot. If not set, no authentication will
6060
# be used.
6161
#user_pin = "123456"
62+
63+
# Example of a TPM provider configuration
64+
#[[provider]]
65+
#provider_type = "TpmProvider"
66+
#key_id_manager = "on-disk-manager"
67+
# (Required) TPM TCTI device to use with this provider. Options are:
68+
# - "device": uses the TPM device on /dev/tpm0
69+
# - "mssim": uses the simulation TPM with the socket
70+
# - "tabrmd": uses the TPM2 Access Broker & Resource Management Daemon
71+
#tcti = "mssim"

src/providers/mod.rs

+6
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,22 @@ pub mod pkcs11_provider;
2323
#[cfg(feature = "mbed-crypto-provider")]
2424
pub mod mbed_provider;
2525

26+
#[cfg(feature = "tpm-provider")]
27+
pub mod tpm_provider;
28+
2629
#[derive(Deserialize, Debug)]
2730
pub enum ProviderType {
2831
MbedProvider,
2932
Pkcs11Provider,
33+
TpmProvider,
3034
}
3135

3236
impl ProviderType {
3337
pub fn to_provider_id(&self) -> ProviderID {
3438
match self {
3539
ProviderType::MbedProvider => ProviderID::MbedProvider,
3640
ProviderType::Pkcs11Provider => ProviderID::Pkcs11Provider,
41+
ProviderType::TpmProvider => ProviderID::TpmProvider,
3742
}
3843
}
3944
}
@@ -45,6 +50,7 @@ pub struct ProviderConfig {
4550
pub library_path: Option<String>,
4651
pub slot_number: Option<usize>,
4752
pub user_pin: Option<String>,
53+
pub tcti: Option<String>,
4854
}
4955

5056
use crate::authenticators::ApplicationName;

0 commit comments

Comments
 (0)