Skip to content

Commit a0d2405

Browse files
authored
Merge pull request #238 from hug-dev/remove-psa-crypto
chore: remove dependency on psa-crypto
2 parents b0afb3e + 9f86633 commit a0d2405

File tree

4 files changed

+0
-149
lines changed

4 files changed

+0
-149
lines changed

Cargo.lock

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

cryptoki/Cargo.toml

-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ rust-version = "1.66.0"
1616
bitflags = "1.3"
1717
libloading = "0.7.0"
1818
log = "0.4.14"
19-
psa-crypto = { version = "0.12.0", default-features = false, optional = true }
2019
cryptoki-sys = { path = "../cryptoki-sys", version = "0.2.0" }
2120
paste = "1.0.6"
2221
secrecy = "0.8.0"
@@ -28,6 +27,5 @@ serial_test = "0.5.1"
2827
testresult = "0.4.1"
2928

3029
[features]
31-
psa-crypto-conversions = ["psa-crypto"]
3230
generate-bindings = ["cryptoki-sys/generate-bindings"]
3331
serde = ["secrecy/serde"]

cryptoki/src/mechanism/mod.rs

-44
Original file line numberDiff line numberDiff line change
@@ -1140,47 +1140,3 @@ fn make_mechanism<T>(mechanism: CK_MECHANISM_TYPE, param: &T) -> CK_MECHANISM {
11401140
.expect("usize can not fit in CK_ULONG"),
11411141
}
11421142
}
1143-
1144-
#[cfg(feature = "psa-crypto-conversions")]
1145-
#[allow(deprecated)]
1146-
impl TryFrom<psa_crypto::types::algorithm::Algorithm> for Mechanism<'_> {
1147-
type Error = Error;
1148-
1149-
fn try_from(alg: psa_crypto::types::algorithm::Algorithm) -> Result<Self, Self::Error> {
1150-
use psa_crypto::types::algorithm::{
1151-
Algorithm, AsymmetricEncryption, AsymmetricSignature, Hash, SignHash,
1152-
};
1153-
1154-
match alg {
1155-
Algorithm::Hash(Hash::Sha1) => Ok(Mechanism::Sha1),
1156-
Algorithm::Hash(Hash::Sha256) => Ok(Mechanism::Sha256),
1157-
Algorithm::Hash(Hash::Sha384) => Ok(Mechanism::Sha384),
1158-
Algorithm::Hash(Hash::Sha512) => Ok(Mechanism::Sha512),
1159-
Algorithm::AsymmetricSignature(AsymmetricSignature::RsaPkcs1v15Sign { .. })
1160-
| Algorithm::AsymmetricEncryption(AsymmetricEncryption::RsaPkcs1v15Crypt { .. }) => {
1161-
Ok(Mechanism::RsaPkcs)
1162-
}
1163-
Algorithm::AsymmetricSignature(AsymmetricSignature::RsaPss {
1164-
hash_alg: SignHash::Specific(hash_alg),
1165-
}) => Ok(Mechanism::RsaPkcsPss(rsa::PkcsPssParams {
1166-
hash_alg: Mechanism::try_from(Algorithm::from(hash_alg))?.mechanism_type(),
1167-
mgf: rsa::PkcsMgfType::from_psa_crypto_hash(hash_alg)?,
1168-
s_len: hash_alg.hash_length().try_into()?,
1169-
})),
1170-
Algorithm::AsymmetricSignature(AsymmetricSignature::Ecdsa { .. }) => {
1171-
Ok(Mechanism::Ecdsa)
1172-
}
1173-
Algorithm::AsymmetricEncryption(AsymmetricEncryption::RsaOaep { hash_alg }) => {
1174-
Ok(Mechanism::RsaPkcsOaep(PkcsOaepParams::new(
1175-
Mechanism::try_from(Algorithm::from(hash_alg))?.mechanism_type(),
1176-
rsa::PkcsMgfType::from_psa_crypto_hash(hash_alg)?,
1177-
rsa::PkcsOaepSource::empty(),
1178-
)))
1179-
}
1180-
alg => {
1181-
error!("{:?} is not a supported algorithm", alg);
1182-
Err(Error::NotSupported)
1183-
}
1184-
}
1185-
}
1186-
}

cryptoki/src/mechanism/rsa.rs

-21
Original file line numberDiff line numberDiff line change
@@ -185,24 +185,3 @@ impl<'a> From<PkcsOaepParams<'a>> for Mechanism<'a> {
185185
Mechanism::RsaPkcsOaep(pkcs_oaep_params)
186186
}
187187
}
188-
189-
#[cfg(feature = "psa-crypto-conversions")]
190-
#[allow(deprecated)]
191-
impl PkcsMgfType {
192-
/// Convert a PSA Crypto Hash algorithm to a MGF type
193-
pub fn from_psa_crypto_hash(alg: psa_crypto::types::algorithm::Hash) -> Result<Self> {
194-
use psa_crypto::types::algorithm::Hash;
195-
196-
match alg {
197-
Hash::Sha1 => Ok(PkcsMgfType::MGF1_SHA1),
198-
Hash::Sha224 => Ok(PkcsMgfType::MGF1_SHA224),
199-
Hash::Sha256 => Ok(PkcsMgfType::MGF1_SHA256),
200-
Hash::Sha384 => Ok(PkcsMgfType::MGF1_SHA384),
201-
Hash::Sha512 => Ok(PkcsMgfType::MGF1_SHA512),
202-
alg => {
203-
error!("{:?} is not a supported MGF1 algorithm", alg);
204-
Err(Error::NotSupported)
205-
}
206-
}
207-
}
208-
}

0 commit comments

Comments
 (0)