diff --git a/Cargo.lock b/Cargo.lock index bebda61..8affd6f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -52,12 +52,6 @@ version = "2.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" -[[package]] -name = "cc" -version = "1.0.86" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f9fa1897e4325be0d68d48df6aa1a71ac2ed4d27723887e7754192705350730" - [[package]] name = "cexpr" version = "0.6.0" @@ -84,15 +78,6 @@ dependencies = [ "libloading 0.8.1", ] -[[package]] -name = "cmake" -version = "0.1.50" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a31c789563b815f77f4250caee12365734369f942439b7defd71e18a48197130" -dependencies = [ - "cc", -] - [[package]] name = "cryptoki" version = "0.8.0" @@ -104,7 +89,6 @@ dependencies = [ "log", "num-traits", "paste", - "psa-crypto", "secrecy", "serial_test", "testresult", @@ -320,30 +304,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "psa-crypto" -version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89c2256e525b9a45ec3bbb3382a43dd8809240279e0aab8ea7ee220e9295445b" -dependencies = [ - "log", - "psa-crypto-sys", - "serde", - "zeroize", -] - -[[package]] -name = "psa-crypto-sys" -version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f170cac3a328e1678916b276067ec170a5a51db1b9b8b4c00b44c2839819a963" -dependencies = [ - "cc", - "cmake", - "regex", - "walkdir", -] - [[package]] name = "quote" version = "1.0.35" @@ -410,15 +370,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "same-file" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" -dependencies = [ - "winapi-util", -] - [[package]] name = "scopeguard" version = "1.2.0" @@ -523,16 +474,6 @@ version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" -[[package]] -name = "walkdir" -version = "2.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d71d857dc86794ca4c280d616f7da00d2dbfd8cd788846559a6813e6aa4b54ee" -dependencies = [ - "same-file", - "winapi-util", -] - [[package]] name = "which" version = "4.4.2" @@ -561,15 +502,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" -[[package]] -name = "winapi-util" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" -dependencies = [ - "winapi", -] - [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" @@ -713,17 +645,3 @@ name = "zeroize" version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" -dependencies = [ - "zeroize_derive", -] - -[[package]] -name = "zeroize_derive" -version = "1.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.50", -] diff --git a/cryptoki/Cargo.toml b/cryptoki/Cargo.toml index 20adf9b..1821710 100644 --- a/cryptoki/Cargo.toml +++ b/cryptoki/Cargo.toml @@ -16,7 +16,6 @@ rust-version = "1.66.0" bitflags = "1.3" libloading = "0.7.0" log = "0.4.14" -psa-crypto = { version = "0.12.0", default-features = false, optional = true } cryptoki-sys = { path = "../cryptoki-sys", version = "0.2.0" } paste = "1.0.6" secrecy = "0.8.0" @@ -28,6 +27,5 @@ serial_test = "0.5.1" testresult = "0.4.1" [features] -psa-crypto-conversions = ["psa-crypto"] generate-bindings = ["cryptoki-sys/generate-bindings"] serde = ["secrecy/serde"] diff --git a/cryptoki/src/mechanism/mod.rs b/cryptoki/src/mechanism/mod.rs index 88b4a7e..52a7852 100644 --- a/cryptoki/src/mechanism/mod.rs +++ b/cryptoki/src/mechanism/mod.rs @@ -1140,47 +1140,3 @@ fn make_mechanism(mechanism: CK_MECHANISM_TYPE, param: &T) -> CK_MECHANISM { .expect("usize can not fit in CK_ULONG"), } } - -#[cfg(feature = "psa-crypto-conversions")] -#[allow(deprecated)] -impl TryFrom for Mechanism<'_> { - type Error = Error; - - fn try_from(alg: psa_crypto::types::algorithm::Algorithm) -> Result { - use psa_crypto::types::algorithm::{ - Algorithm, AsymmetricEncryption, AsymmetricSignature, Hash, SignHash, - }; - - match alg { - Algorithm::Hash(Hash::Sha1) => Ok(Mechanism::Sha1), - Algorithm::Hash(Hash::Sha256) => Ok(Mechanism::Sha256), - Algorithm::Hash(Hash::Sha384) => Ok(Mechanism::Sha384), - Algorithm::Hash(Hash::Sha512) => Ok(Mechanism::Sha512), - Algorithm::AsymmetricSignature(AsymmetricSignature::RsaPkcs1v15Sign { .. }) - | Algorithm::AsymmetricEncryption(AsymmetricEncryption::RsaPkcs1v15Crypt { .. }) => { - Ok(Mechanism::RsaPkcs) - } - Algorithm::AsymmetricSignature(AsymmetricSignature::RsaPss { - hash_alg: SignHash::Specific(hash_alg), - }) => Ok(Mechanism::RsaPkcsPss(rsa::PkcsPssParams { - hash_alg: Mechanism::try_from(Algorithm::from(hash_alg))?.mechanism_type(), - mgf: rsa::PkcsMgfType::from_psa_crypto_hash(hash_alg)?, - s_len: hash_alg.hash_length().try_into()?, - })), - Algorithm::AsymmetricSignature(AsymmetricSignature::Ecdsa { .. }) => { - Ok(Mechanism::Ecdsa) - } - Algorithm::AsymmetricEncryption(AsymmetricEncryption::RsaOaep { hash_alg }) => { - Ok(Mechanism::RsaPkcsOaep(PkcsOaepParams::new( - Mechanism::try_from(Algorithm::from(hash_alg))?.mechanism_type(), - rsa::PkcsMgfType::from_psa_crypto_hash(hash_alg)?, - rsa::PkcsOaepSource::empty(), - ))) - } - alg => { - error!("{:?} is not a supported algorithm", alg); - Err(Error::NotSupported) - } - } - } -} diff --git a/cryptoki/src/mechanism/rsa.rs b/cryptoki/src/mechanism/rsa.rs index bd10dd6..22a07f7 100644 --- a/cryptoki/src/mechanism/rsa.rs +++ b/cryptoki/src/mechanism/rsa.rs @@ -185,24 +185,3 @@ impl<'a> From> for Mechanism<'a> { Mechanism::RsaPkcsOaep(pkcs_oaep_params) } } - -#[cfg(feature = "psa-crypto-conversions")] -#[allow(deprecated)] -impl PkcsMgfType { - /// Convert a PSA Crypto Hash algorithm to a MGF type - pub fn from_psa_crypto_hash(alg: psa_crypto::types::algorithm::Hash) -> Result { - use psa_crypto::types::algorithm::Hash; - - match alg { - Hash::Sha1 => Ok(PkcsMgfType::MGF1_SHA1), - Hash::Sha224 => Ok(PkcsMgfType::MGF1_SHA224), - Hash::Sha256 => Ok(PkcsMgfType::MGF1_SHA256), - Hash::Sha384 => Ok(PkcsMgfType::MGF1_SHA384), - Hash::Sha512 => Ok(PkcsMgfType::MGF1_SHA512), - alg => { - error!("{:?} is not a supported MGF1 algorithm", alg); - Err(Error::NotSupported) - } - } - } -}