diff --git a/src/asymmetric_crypto/curve25519.rs b/src/asymmetric_crypto/curve25519.rs index 0e03332..bc9d7f5 100644 --- a/src/asymmetric_crypto/curve25519.rs +++ b/src/asymmetric_crypto/curve25519.rs @@ -6,6 +6,11 @@ //! time of this implementation. use crate::{asymmetric_crypto::DhKeyPair, CryptoCoreError, KeyTrait}; +use core::{ + convert::TryFrom, + fmt::Display, + ops::{Add, Mul, Sub}, +}; use curve25519_dalek::{ constants, ristretto::{CompressedRistretto, RistrettoPoint}, @@ -13,11 +18,6 @@ use curve25519_dalek::{ }; use rand_core::{CryptoRng, RngCore}; use serde::{Deserialize, Serialize}; -use std::{ - convert::TryFrom, - fmt::Display, - ops::{Add, Mul, Sub}, -}; use zeroize::{Zeroize, ZeroizeOnDrop}; /// X25519 secret key length @@ -120,7 +120,7 @@ impl TryFrom<&str> for X25519PrivateKey { /// Display the hex encoded value of the key impl Display for X25519PrivateKey { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "{}", hex::encode(self.0.as_bytes())) } } @@ -308,7 +308,7 @@ impl TryFrom<&str> for X25519PublicKey { /// Display the hex encoded value of the key impl Display for X25519PublicKey { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "{}", hex::encode(self.0.compress().to_bytes())) } } diff --git a/src/symmetric_crypto/aes_256_gcm_pure/mod.rs b/src/symmetric_crypto/aes_256_gcm_pure/mod.rs index ca63938..92beb84 100644 --- a/src/symmetric_crypto/aes_256_gcm_pure/mod.rs +++ b/src/symmetric_crypto/aes_256_gcm_pure/mod.rs @@ -234,7 +234,7 @@ mod tests { fn test_encryption_decryption_detached() -> Result<(), CryptoCoreError> { let mut cs_rng = CsRng::new(); let key = Key::::new(&mut cs_rng); - let bytes = cs_rng.generate_random_bytes::<8192>(); + let bytes = cs_rng.generate_random_bytes::<1024>(); let iv = Nonce::::new(&mut cs_rng); // no additional data let mut data = bytes; diff --git a/src/symmetric_crypto/key.rs b/src/symmetric_crypto/key.rs index dbd3275..011477f 100644 --- a/src/symmetric_crypto/key.rs +++ b/src/symmetric_crypto/key.rs @@ -1,8 +1,8 @@ //! Define a symmetric key object of variable size. use crate::{symmetric_crypto::SymKey, CryptoCoreError, KeyTrait}; +use core::{convert::TryFrom, fmt::Display, hash::Hash, ops::Deref}; use rand_core::{CryptoRng, RngCore}; -use std::{convert::TryFrom, fmt::Display, hash::Hash, ops::Deref}; use zeroize::{Zeroize, ZeroizeOnDrop}; /// Symmetric key of a given size. @@ -70,7 +70,7 @@ impl<'a, const KEY_LENGTH: usize> TryFrom<&'a [u8]> for Key { } impl Display for Key { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "{}", hex::encode(self.as_bytes())) } } @@ -108,7 +108,7 @@ impl Deref for Key { mod tests { use crate::{entropy::CsRng, symmetric_crypto::key::Key}; - use std::ops::Deref; + use core::ops::Deref; const KEY_LENGTH: usize = 32; diff --git a/src/symmetric_crypto/metadata.rs b/src/symmetric_crypto/metadata.rs index 44117c1..9e1bf2d 100644 --- a/src/symmetric_crypto/metadata.rs +++ b/src/symmetric_crypto/metadata.rs @@ -1,6 +1,6 @@ use crate::CryptoCoreError; +use core::convert::TryInto; use serde::{Deserialize, Serialize}; -use std::convert::TryInto; /// Attempts to get the length of this slice as an `u32` in 4 endian bytes and /// returns an error if it overflows diff --git a/src/symmetric_crypto/mod.rs b/src/symmetric_crypto/mod.rs index 55ef7d4..9fc006c 100644 --- a/src/symmetric_crypto/mod.rs +++ b/src/symmetric_crypto/mod.rs @@ -12,9 +12,9 @@ pub use metadata::BytesScanner; pub use metadata::Metadata; use crate::{CryptoCoreError, KeyTrait}; +use core::hash::Hash; use nonce::NonceTrait; use rand_core::{CryptoRng, RngCore}; -use std::hash::Hash; use std::vec::Vec; /// Defines a symmetric encryption key.