From 201ad812a0fdbd43808b1717a66936a0348cf1b1 Mon Sep 17 00:00:00 2001 From: dignifiedquire Date: Wed, 13 Nov 2024 20:46:48 +0100 Subject: [PATCH 1/8] fix: handle tiny keys --- src/algorithms/pkcs1v15.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/algorithms/pkcs1v15.rs b/src/algorithms/pkcs1v15.rs index c1f0779a..e813de11 100644 --- a/src/algorithms/pkcs1v15.rs +++ b/src/algorithms/pkcs1v15.rs @@ -41,7 +41,7 @@ pub(crate) fn pkcs1v15_encrypt_pad( where R: CryptoRngCore + ?Sized, { - if msg.len() > k - 11 { + if msg.len() + 11 > k { return Err(Error::MessageTooLong); } @@ -195,4 +195,13 @@ mod tests { } } } + + #[test] + fn test_encrypt_tiny_no_crash() { + let mut rng = ChaCha8Rng::from_seed([42; 32]); + let k = 8; + let message = vec![1u8; 4]; + let res = pkcs1v15_encrypt_pad(&mut rng, &message, k); + assert_eq!(res, Err(Error::MessageTooLong)); + } } From 2edd47929f7298bddde8f682ded330dbaf9c43a6 Mon Sep 17 00:00:00 2001 From: dignifiedquire Date: Mon, 18 Nov 2024 09:56:12 +0100 Subject: [PATCH 2/8] fix: always validate keys in from_components Otherwise the inner precompute could fail --- src/key.rs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/key.rs b/src/key.rs index 5e6de22f..f1d73841 100644 --- a/src/key.rs +++ b/src/key.rs @@ -251,7 +251,6 @@ impl RsaPrivateKey { d: BigUint, mut primes: Vec, ) -> Result { - let mut should_validate = false; if primes.len() < 2 { if !primes.is_empty() { return Err(Error::NprimesTooSmall); @@ -261,7 +260,6 @@ impl RsaPrivateKey { let (p, q) = recover_primes(&n, &e, &d)?; primes.push(p); primes.push(q); - should_validate = true; } let mut k = RsaPrivateKey { @@ -271,10 +269,8 @@ impl RsaPrivateKey { precomputed: None, }; - // Validate the key if we had to recover the primes. - if should_validate { - k.validate()?; - } + // Alaways validate the key, to ensure precompute can't fail + k.validate()?; // precompute when possible, ignore error otherwise. let _ = k.precompute(); @@ -717,13 +713,13 @@ mod tests { Base64::decode_vec("CUWC+hRWOT421kwRllgVjy6FYv6jQUcgDNHeAiYZnf5HjS9iK2ki7v8G5dL/0f+Yf+NhE/4q8w4m8go51hACrVpP1p8GJDjiT09+RsOzITsHwl+ceEKoe56ZW6iDHBLlrNw5/MtcYhKpjNU9KJ2udm5J/c9iislcjgckrZG2IB8ADgXHMEByZ5DgaMl4AKZ1Gx8/q6KftTvmOT5rNTMLi76VN5KWQcDWK/DqXiOiZHM7Nr4dX4me3XeRgABJyNR8Fqxj3N1+HrYLe/zs7LOaK0++F9Ul3tLelhrhsvLxei3oCZkF9A/foD3on3luYA+1cRcxWpSY3h2J4/22+yo4+Q==").unwrap(), ]; - RsaPrivateKey::from_components( + let res = RsaPrivateKey::from_components( BigUint::from_bytes_be(&n), BigUint::from_bytes_be(&e), BigUint::from_bytes_be(&d), primes.iter().map(|p| BigUint::from_bytes_be(p)).collect(), - ) - .unwrap(); + ); + assert_eq!(res, Err(Error::InvalidModulus)); } #[test] From 551f6e5dcbefa89c030a4fda5534782e6fb8bdb4 Mon Sep 17 00:00:00 2001 From: dignifiedquire Date: Tue, 26 Nov 2024 13:26:04 +0100 Subject: [PATCH 3/8] release: v0.9.7 --- CHANGELOG.md | 5 +++++ Cargo.toml | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7ecd361f..4210925c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## 0.9.7 (2024-11-26) +### Fixed +- always validate keys in from_components +- do not crash when handling tiny keys in PKCS1v15 + ## 0.9.6 (2023-12-01) ### Added - expose a `pss::get_default_pss_signature_algo_id` helper ([#393]) diff --git a/Cargo.toml b/Cargo.toml index e4b22655..27fe4f30 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rsa" -version = "0.9.6" +version = "0.9.7" authors = ["RustCrypto Developers", "dignifiedquire "] edition = "2021" description = "Pure Rust RSA implementation" From bd3575b67f404408e9a05367ce1bdad33d8e9439 Mon Sep 17 00:00:00 2001 From: n4n5 <56606507+Its-Just-Nans@users.noreply.github.com> Date: Wed, 12 Mar 2025 17:57:06 +0100 Subject: [PATCH 4/8] Add comment to specify the rand version (#473) --- Cargo.lock | 2 +- README.md | 2 +- src/lib.rs | 8 ++++---- src/oaep.rs | 4 ++-- src/pkcs1v15/signature.rs | 6 +----- src/pss/signature.rs | 6 +----- 6 files changed, 10 insertions(+), 18 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c20e26fa..e1714eea 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -465,7 +465,7 @@ checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" [[package]] name = "rsa" -version = "0.9.6" +version = "0.9.7" dependencies = [ "base64ct", "const-oid", diff --git a/README.md b/README.md index 6f191df0..cba176a5 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ A portable RSA implementation in pure Rust. ```rust use rsa::{Pkcs1v15Encrypt, RsaPrivateKey, RsaPublicKey}; -let mut rng = rand::thread_rng(); +let mut rng = rand::thread_rng(); // rand@0.8 let bits = 2048; let priv_key = RsaPrivateKey::new(&mut rng, bits).expect("failed to generate a key"); let pub_key = RsaPublicKey::from(&priv_key); diff --git a/src/lib.rs b/src/lib.rs index 2232f37a..7b3943f3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -25,7 +25,7 @@ #![cfg_attr(not(feature = "sha2"), doc = "```ignore")] //! use rsa::{RsaPrivateKey, RsaPublicKey, Oaep, sha2::Sha256}; //! -//! let mut rng = rand::thread_rng(); +//! let mut rng = rand::thread_rng(); // rand@0.8 //! //! let bits = 2048; //! let private_key = RsaPrivateKey::new(&mut rng, bits).expect("failed to generate a key"); @@ -47,7 +47,7 @@ //! ``` //! use rsa::{RsaPrivateKey, RsaPublicKey, Pkcs1v15Encrypt}; //! -//! let mut rng = rand::thread_rng(); +//! let mut rng = rand::thread_rng(); // rand@0.8 //! //! let bits = 2048; //! let private_key = RsaPrivateKey::new(&mut rng, bits).expect("failed to generate a key"); @@ -74,7 +74,7 @@ //! use rsa::signature::{Keypair, RandomizedSigner, SignatureEncoding, Verifier}; //! use rsa::sha2::{Digest, Sha256}; //! -//! let mut rng = rand::thread_rng(); +//! let mut rng = rand::thread_rng(); // rand@0.8 //! //! let bits = 2048; //! let private_key = RsaPrivateKey::new(&mut rng, bits).expect("failed to generate a key"); @@ -101,7 +101,7 @@ //! use rsa::signature::{Keypair,RandomizedSigner, SignatureEncoding, Verifier}; //! use rsa::sha2::{Digest, Sha256}; //! -//! let mut rng = rand::thread_rng(); +//! let mut rng = rand::thread_rng(); // rand@0.8 //! //! let bits = 2048; //! let private_key = RsaPrivateKey::new(&mut rng, bits).expect("failed to generate a key"); diff --git a/src/oaep.rs b/src/oaep.rs index 0cbd1e3b..c2bfac64 100644 --- a/src/oaep.rs +++ b/src/oaep.rs @@ -61,7 +61,7 @@ impl Oaep { /// let n = Base64::decode_vec("ALHgDoZmBQIx+jTmgeeHW6KsPOrj11f6CvWsiRleJlQpW77AwSZhd21ZDmlTKfaIHBSUxRUsuYNh7E2SHx8rkFVCQA2/gXkZ5GK2IUbzSTio9qXA25MWHvVxjMfKSL8ZAxZyKbrG94FLLszFAFOaiLLY8ECs7g+dXOriYtBwLUJK+lppbd+El+8ZA/zH0bk7vbqph5pIoiWggxwdq3mEz4LnrUln7r6dagSQzYErKewY8GADVpXcq5mfHC1xF2DFBub7bFjMVM5fHq7RK+pG5xjNDiYITbhLYrbVv3X0z75OvN0dY49ITWjM7xyvMWJXVJS7sJlgmCCL6RwWgP8PhcE=").unwrap(); /// let e = Base64::decode_vec("AQAB").unwrap(); /// - /// let mut rng = rand::thread_rng(); + /// let mut rng = rand::thread_rng(); // rand@0.8 /// let key = RsaPublicKey::new(BigUint::from_bytes_be(&n), BigUint::from_bytes_be(&e)).unwrap(); /// let padding = Oaep::new::(); /// let encrypted_data = key.encrypt(&mut rng, padding, b"secret").unwrap(); @@ -98,7 +98,7 @@ impl Oaep { /// let n = Base64::decode_vec("ALHgDoZmBQIx+jTmgeeHW6KsPOrj11f6CvWsiRleJlQpW77AwSZhd21ZDmlTKfaIHBSUxRUsuYNh7E2SHx8rkFVCQA2/gXkZ5GK2IUbzSTio9qXA25MWHvVxjMfKSL8ZAxZyKbrG94FLLszFAFOaiLLY8ECs7g+dXOriYtBwLUJK+lppbd+El+8ZA/zH0bk7vbqph5pIoiWggxwdq3mEz4LnrUln7r6dagSQzYErKewY8GADVpXcq5mfHC1xF2DFBub7bFjMVM5fHq7RK+pG5xjNDiYITbhLYrbVv3X0z75OvN0dY49ITWjM7xyvMWJXVJS7sJlgmCCL6RwWgP8PhcE=").unwrap(); /// let e = Base64::decode_vec("AQAB").unwrap(); /// - /// let mut rng = rand::thread_rng(); + /// let mut rng = rand::thread_rng(); // rand@0.8 /// let key = RsaPublicKey::new(BigUint::from_bytes_be(&n), BigUint::from_bytes_be(&e)).unwrap(); /// let padding = Oaep::new_with_mgf_hash::(); /// let encrypted_data = key.encrypt(&mut rng, padding, b"secret").unwrap(); diff --git a/src/pkcs1v15/signature.rs b/src/pkcs1v15/signature.rs index a640da32..0ab49f51 100644 --- a/src/pkcs1v15/signature.rs +++ b/src/pkcs1v15/signature.rs @@ -1,8 +1,4 @@ -pub use ::signature::{ - hazmat::{PrehashSigner, PrehashVerifier}, - DigestSigner, DigestVerifier, Error, Keypair, RandomizedDigestSigner, RandomizedSigner, Result, - SignatureEncoding, Signer, Verifier, -}; +pub use ::signature::SignatureEncoding; use spki::{ der::{asn1::BitString, Result as DerResult}, SignatureBitStringEncoding, diff --git a/src/pss/signature.rs b/src/pss/signature.rs index fa47d6d9..fd8b88c4 100644 --- a/src/pss/signature.rs +++ b/src/pss/signature.rs @@ -1,8 +1,4 @@ -pub use ::signature::{ - hazmat::{PrehashSigner, PrehashVerifier}, - DigestSigner, DigestVerifier, Error, Keypair, RandomizedDigestSigner, RandomizedSigner, Result, - SignatureEncoding, Signer, Verifier, -}; +pub use ::signature::SignatureEncoding; use spki::{ der::{asn1::BitString, Result as DerResult}, SignatureBitStringEncoding, From 85f03b569b7771e6d9c270c0a938930ecc69e07c Mon Sep 17 00:00:00 2001 From: Artyom Pavlov Date: Wed, 12 Mar 2025 20:10:50 +0300 Subject: [PATCH 5/8] Release v0.9.8 (#495) --- CHANGELOG.md | 6 ++++++ Cargo.lock | 2 +- Cargo.toml | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4210925c..55905297 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## 0.9.8 (2025-03-12) +### Added +- Doc comments to specify the `rand` version ([#473]) + +[#473]: https://github.com/RustCrypto/RSA/pull/473 + ## 0.9.7 (2024-11-26) ### Fixed - always validate keys in from_components diff --git a/Cargo.lock b/Cargo.lock index e1714eea..2ac58661 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -465,7 +465,7 @@ checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" [[package]] name = "rsa" -version = "0.9.7" +version = "0.9.8" dependencies = [ "base64ct", "const-oid", diff --git a/Cargo.toml b/Cargo.toml index 27fe4f30..7d289626 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rsa" -version = "0.9.7" +version = "0.9.8" authors = ["RustCrypto Developers", "dignifiedquire "] edition = "2021" description = "Pure Rust RSA implementation" From c1f00a32c5ef97ca2bc121ee28b7ea907b6f936d Mon Sep 17 00:00:00 2001 From: Heiko Schaefer <59601023+hko-s@users.noreply.github.com> Date: Wed, 15 Oct 2025 23:32:57 +0200 Subject: [PATCH 6/8] Support for cryptographic operations with larger keys (#594) Currently, this crate allows instantiation of public keys larger than 4096 bit (via `RsaPublicKey::new_with_max_size`), but doing cryptographic operations with such public keys fails in `key::check_public`, which always checks the modulus size against the constant `RsaPublicKey::MAX_SIZE`. I think it would be nice to cap both public and private key sizes to 4096 bit by default, but to allow opt-in creation of larger keys (complete with working cryptographic operations). --- src/key.rs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/key.rs b/src/key.rs index f1d73841..c5982f32 100644 --- a/src/key.rs +++ b/src/key.rs @@ -184,7 +184,7 @@ impl RsaPublicKey { /// Create a new public key from its components. pub fn new_with_max_size(n: BigUint, e: BigUint, max_size: usize) -> Result { let k = Self { n, e }; - check_public_with_max_size(&k, max_size)?; + check_public_with_max_size(&k, Some(max_size))?; Ok(k) } @@ -269,7 +269,7 @@ impl RsaPrivateKey { precomputed: None, }; - // Alaways validate the key, to ensure precompute can't fail + // Always validate the key, to ensure precompute can't fail k.validate()?; // precompute when possible, ignore error otherwise. @@ -493,14 +493,19 @@ impl PrivateKeyParts for RsaPrivateKey { /// Check that the public key is well formed and has an exponent within acceptable bounds. #[inline] pub fn check_public(public_key: &impl PublicKeyParts) -> Result<()> { - check_public_with_max_size(public_key, RsaPublicKey::MAX_SIZE) + check_public_with_max_size(public_key, None) } /// Check that the public key is well formed and has an exponent within acceptable bounds. #[inline] -fn check_public_with_max_size(public_key: &impl PublicKeyParts, max_size: usize) -> Result<()> { - if public_key.n().bits() > max_size { - return Err(Error::ModulusTooLarge); +fn check_public_with_max_size( + public_key: &impl PublicKeyParts, + max_size: Option, +) -> Result<()> { + if let Some(max_size) = max_size { + if public_key.n().bits() > max_size { + return Err(Error::ModulusTooLarge); + } } let e = public_key From 488d2ad6090e54b5125dfeefeda53a1adb4b67c0 Mon Sep 17 00:00:00 2001 From: dignifiedquire Date: Thu, 13 Nov 2025 10:40:55 +0100 Subject: [PATCH 7/8] chore: release 0.9.9 --- CHANGELOG.md | 6 ++++++ Cargo.lock | 2 +- Cargo.toml | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 55905297..a34ab10a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## 0.9.9 (2025-11-13) +### Fixed +- Support for cryptographic operations with larger keys ([#594]) + +[#594]: https://github.com/RustCrypto/RSA/pull/594 + ## 0.9.8 (2025-03-12) ### Added - Doc comments to specify the `rand` version ([#473]) diff --git a/Cargo.lock b/Cargo.lock index 2ac58661..3b56b548 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -465,7 +465,7 @@ checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" [[package]] name = "rsa" -version = "0.9.8" +version = "0.9.9" dependencies = [ "base64ct", "const-oid", diff --git a/Cargo.toml b/Cargo.toml index 7d289626..41974491 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rsa" -version = "0.9.8" +version = "0.9.9" authors = ["RustCrypto Developers", "dignifiedquire "] edition = "2021" description = "Pure Rust RSA implementation" From 9eaecfd1a22c1f40661c4d4ab2fb60e147a00cf4 Mon Sep 17 00:00:00 2001 From: Victor Graf Date: Fri, 19 Dec 2025 16:36:42 -0800 Subject: [PATCH 8/8] update risc0-bigint2 to 1.4.11 and get cargo risczero guest test working (v0.9.6) --- Cargo.lock | 21 +++++++++++++++++---- Cargo.toml | 10 ++++++++-- src/algorithms/rsa.rs | 12 ++++++++++-- tests/proptests.rs | 10 ++++++++++ 4 files changed, 45 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e7e53f7b..223d752e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -300,9 +300,9 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.17" +version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ "autocfg", "libm", @@ -471,11 +471,13 @@ checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" [[package]] name = "risc0-bigint2" -version = "1.2.0-alpha.1" -source = "git+https://github.com/risc0/risc0?rev=8fc8437633f08a66e0fbacce947f41d01b074774#8fc8437633f08a66e0fbacce947f41d01b074774" +version = "1.4.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3bd8ae1058e6f5d4635dfd206a41bab7ad64067df70421a5f32e18b1a17979ac" dependencies = [ "include_bytes_aligned", "num-bigint-dig", + "stability", ] [[package]] @@ -485,6 +487,7 @@ dependencies = [ "base64ct", "const-oid", "digest", + "getrandom", "hex-literal", "num-bigint-dig", "num-integer", @@ -646,6 +649,16 @@ dependencies = [ "der", ] +[[package]] +name = "stability" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d904e7009df136af5297832a3ace3370cd14ff1546a232f4f185036c2736fcac" +dependencies = [ + "quote", + "syn", +] + [[package]] name = "subtle" version = "2.5.0" diff --git a/Cargo.toml b/Cargo.toml index 67ed6d2d..3103736e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,12 +32,12 @@ sha2 = { version = "0.10.6", optional = true, default-features = false, features serde = { version = "1.0.184", optional = true, default-features = false, features = ["derive"] } [target.'cfg(target_os = "zkvm")'.dependencies] -risc0-bigint2 = { git = "https://github.com/risc0/risc0", rev = "8fc8437633f08a66e0fbacce947f41d01b074774", default-features = false, features = ["num-bigint-dig"] } +getrandom = { version = "0.2", default-features = false, features = ["custom"] } +risc0-bigint2 = { version = "1.4.11", features = ["num-bigint-dig"] } [dev-dependencies] base64ct = { version = "1", features = ["alloc"] } hex-literal = "0.4.1" -proptest = "1" serde_test = "1.0.89" rand_xorshift = "0.3" rand_chacha = "0.3" @@ -47,6 +47,12 @@ sha1 = { version = "0.10.5", default-features = false, features = ["oid"] } sha2 = { version = "0.10.6", default-features = false, features = ["oid"] } sha3 = { version = "0.10.7", default-features = false, features = ["oid"] } +[target.'cfg(not(target_os = "zkvm"))'.dev-dependencies] +proptest = "1" + +[target.'cfg(target_os = "zkvm")'.dev-dependencies] +proptest = { version = "1", default-features = false, features = ["alloc"] } + [[bench]] name = "key" diff --git a/src/algorithms/rsa.rs b/src/algorithms/rsa.rs index e2305220..db5253be 100644 --- a/src/algorithms/rsa.rs +++ b/src/algorithms/rsa.rs @@ -6,6 +6,8 @@ use num_bigint::{BigInt, BigUint, IntoBigInt, IntoBigUint, ModInverse, RandBigIn use num_integer::{sqrt, Integer}; use num_traits::{FromPrimitive, One, Pow, Signed, Zero}; use rand_core::CryptoRngCore; +#[cfg(target_os = "zkvm")] +use risc0_bigint2::ToBigInt2Buffer; use zeroize::{Zeroize, Zeroizing}; use crate::errors::{Error, Result}; @@ -22,8 +24,14 @@ pub fn rsa_encrypt(key: &K, m: &BigUint) -> Result { #[cfg(target_os = "zkvm")] { // If we're in the RISC Zero zkVM, try to use an accelerated version. - if *key.e() == BigUint::new(vec![65537]) { - return Ok(risc0_bigint2::rsa::modpow_65537(m, key.n())); + if m.bits() <= 4096 && key.n().bits() <= 4096 && *key.e() == BigUint::new(vec![65537]) { + let mut result = [0u32; risc0_bigint2::field::FIELD_4096_WIDTH_WORDS]; + risc0_bigint2::rsa::modpow_65537( + &m.to_u32_array(), + &key.n().to_u32_array(), + &mut result, + ); + return Ok(BigUint::from_slice(&result)); } // Fall through when the exponent does not match the accelerator } diff --git a/tests/proptests.rs b/tests/proptests.rs index eaeeebea..f138c5eb 100644 --- a/tests/proptests.rs +++ b/tests/proptests.rs @@ -18,7 +18,17 @@ prop_compose! { } } +fn config() -> ProptestConfig { + if cfg!(all(target_os = "zkvm", target_arch = "riscv32")) { + ProptestConfig::with_cases(1) + } else { + ProptestConfig::default() + } +} + proptest! { + #![proptest_config(config())] + #[test] fn pkcs1v15_sign_roundtrip(private_key in private_key(), msg in any::>()) { let signing_key = pkcs1v15::SigningKey::::new(private_key);