diff --git a/src/algorithms/reduction.rs b/src/algorithms/reduction.rs index ad143f9c..9f670cba 100644 --- a/src/algorithms/reduction.rs +++ b/src/algorithms/reduction.rs @@ -38,6 +38,7 @@ pub(crate) fn to_monty(x: &BoxedUint, p: &BoxedMontyParams) -> BoxedMontyForm { #[cfg(test)] mod tests { use super::*; + use alloc::vec::Vec; use crypto_bigint::Odd; #[test] diff --git a/src/algorithms/rsa.rs b/src/algorithms/rsa.rs index 43671eac..2d61f732 100644 --- a/src/algorithms/rsa.rs +++ b/src/algorithms/rsa.rs @@ -424,6 +424,7 @@ pub(crate) fn compute_private_exponent_carmicheal( #[cfg(test)] mod tests { use super::*; + use core::mem; #[test] fn recover_primes_works() { @@ -482,7 +483,7 @@ mod tests { let (mut p1, mut q1) = recover_primes(&NonZero::new(n).unwrap(), &e, &d).unwrap(); if p1 < q1 { - std::mem::swap(&mut p1, &mut q1); + mem::swap(&mut p1, &mut q1); } assert_eq!(p, p1); assert_eq!(q, q1); diff --git a/src/lib.rs b/src/lib.rs index 1d823281..17683393 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,4 @@ -#![cfg_attr(not(test), no_std)] +#![no_std] #![cfg_attr(docsrs, feature(doc_cfg))] #![cfg_attr(feature = "getrandom", doc = include_str!("../README.md"))] // example needs `getrandom` #![doc(html_logo_url = "https://raw.githubusercontent.com/RustCrypto/meta/master/logo_small.png")] @@ -174,10 +174,9 @@ //! //! ### Example //! -//! ``` -//! # fn main() -> Result<(), Box> { -//! # #[cfg(all(feature = "encoding", feature = "std"))] -//! # { +#![cfg_attr(feature = "encoding", doc = "```")] +#![cfg_attr(not(feature = "encoding"), doc = "```ignore")] +//! # fn main() -> Result<(), rsa::Error> { //! use rsa::{PublicKey, pkcs1::DecodeRsaPublicKey}; //! //! let pem = "-----BEGIN RSA PUBLIC KEY----- @@ -190,7 +189,6 @@ //! -----END RSA PUBLIC KEY-----"; //! //! let public_key = PublicKey::from_pkcs1_pem(pem)?; -//! # } //! # Ok(()) //! # } //! ``` @@ -218,10 +216,9 @@ //! //! ### Example //! -//! ``` -//! # fn main() -> Result<(), Box> { -//! # #[cfg(all(feature = "encoding", feature = "std"))] -//! # { +#![cfg_attr(feature = "encoding", doc = "```")] +#![cfg_attr(not(feature = "encoding"), doc = "```ignore")] +//! # fn main() -> Result<(), rsa::pkcs8::Error> { //! use rsa::{PublicKey, pkcs8::DecodePublicKey}; //! //! let pem = "-----BEGIN PUBLIC KEY----- @@ -235,7 +232,6 @@ //! -----END PUBLIC KEY-----"; //! //! let public_key = PublicKey::from_public_key_pem(pem)?; -//! # } //! # Ok(()) //! # } //! ``` diff --git a/src/oaep.rs b/src/oaep.rs index cfd97fa4..a1444ece 100644 --- a/src/oaep.rs +++ b/src/oaep.rs @@ -406,6 +406,7 @@ mod tests { use crate::traits::{Decryptor, RandomizedDecryptor, RandomizedEncryptor}; use crate::{PrivateKey, PublicKey}; + use alloc::boxed::Box; use crypto_bigint::BoxedUint; use digest::{Digest, FixedOutputReset}; use rand::rngs::ChaCha8Rng; diff --git a/src/pss.rs b/src/pss.rs index aa8e860c..7ac5393c 100644 --- a/src/pss.rs +++ b/src/pss.rs @@ -699,8 +699,7 @@ tAboUGBxTDq3ZroNism3DaMIbKPyYrAqhKov1h5V fn test_sign_and_verify_2049bit_key() { let plaintext = "Hello\n"; let mut rng = ChaCha8Rng::from_seed([42; 32]); - for i in 0..10 { - println!("round {i}"); + for _ in 0..10 { let priv_key = PrivateKey::new(&mut rng, 2049).unwrap(); let digest = Sha1::digest(plaintext.as_bytes()).to_vec();