Skip to content

Commit

Permalink
Merge pull request parallaxsecond#98 from egrimley-arm/main
Browse files Browse the repository at this point in the history
Update from rsa 0.3.0 to 0.5.0.
  • Loading branch information
ionut-arm authored Jan 6, 2022
2 parents 6b44204 + ca21b3e commit 905e650
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
with:
profile: minimal
override: true
toolchain: 1.46.0
toolchain: 1.52.0
- name: Set up Python
uses: actions/setup-python@v2
with:
Expand Down
4 changes: 2 additions & 2 deletions psa-crypto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ serde = { version = "1.0.115", features = ["derive"] }
zeroize = { version = "<=1.3.0", features = ["zeroize_derive"] }

[dev-dependencies]
rsa = "0.3.0"
rand = "0.7.3"
rsa = { version = "0.5.0", features = ["alloc"] }
rand = "0.8.4"
base64 = "0.12.3"

[features]
Expand Down
8 changes: 5 additions & 3 deletions psa-crypto/src/operations/asym_encryption.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,9 @@ pub fn encrypt(
/// # use psa_crypto::operations::asym_encryption::decrypt;
/// # use psa_crypto::types::key::{Attributes, Type, Lifetime, Policy, UsageFlags};
/// # use psa_crypto::types::algorithm::{AsymmetricEncryption, Hash};
/// # use rsa::{RSAPublicKey, PaddingScheme, PublicKey};
/// # use rsa::{RsaPublicKey, PaddingScheme, PublicKey};
/// # use rand::rngs::OsRng;
/// # use rsa::pkcs1::FromRsaPublicKey;
/// # let mut usage_flags: UsageFlags = Default::default();
/// # usage_flags.set_decrypt();
/// # let mut attributes = Attributes {
Expand All @@ -115,8 +116,9 @@ pub fn encrypt(
///
/// let key_id = generate(attributes, None).unwrap();
/// let mut pub_key = vec![0; attributes.export_public_key_output_size().unwrap()];
/// let _pub_key_length = export_public(key_id.clone(), &mut pub_key);
/// let rsa_pub_key = RSAPublicKey::from_pkcs1(&pub_key).unwrap();
/// let pub_key_length = export_public(key_id.clone(), &mut pub_key).unwrap();
/// pub_key.truncate(pub_key_length);
/// let rsa_pub_key = RsaPublicKey::from_pkcs1_der(&pub_key).unwrap();
/// let ciphertext = rsa_pub_key.encrypt(&mut OsRng, PaddingScheme::new_pkcs1v15_encrypt(), &MESSAGE).unwrap();
///
/// let alg = AsymmetricEncryption::RsaPkcs1v15Crypt;
Expand Down
22 changes: 9 additions & 13 deletions psa-crypto/src/types/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,9 +246,7 @@ impl Attributes {
match self.key_type {
Type::RawData => false,
Type::Hmac => alg.is_hmac(),
Type::Derive => {
matches!(alg, Algorithm::KeyDerivation(_))
}
Type::Derive => matches!(alg, Algorithm::KeyDerivation(_)),
Type::Aes | Type::Camellia => {
if let Algorithm::Mac(mac_alg) = alg {
mac_alg.is_block_cipher_needed()
Expand Down Expand Up @@ -295,16 +293,14 @@ impl Attributes {
Algorithm::AsymmetricSignature(sign_alg) => sign_alg.is_ecc_alg(),
_ => false,
},
Type::DhKeyPair { .. } | Type::DhPublicKey { .. } => {
matches!(
alg,
Algorithm::KeyAgreement(KeyAgreement::Raw(RawKeyAgreement::Ffdh))
| Algorithm::KeyAgreement(KeyAgreement::WithKeyDerivation {
ka_alg: RawKeyAgreement::Ffdh,
..
})
)
}
Type::DhKeyPair { .. } | Type::DhPublicKey { .. } => matches!(
alg,
Algorithm::KeyAgreement(KeyAgreement::Raw(RawKeyAgreement::Ffdh))
| Algorithm::KeyAgreement(KeyAgreement::WithKeyDerivation {
ka_alg: RawKeyAgreement::Ffdh,
..
})
),
}
}

Expand Down

0 comments on commit 905e650

Please sign in to comment.