Skip to content

Commit

Permalink
Remove std when core can be used
Browse files Browse the repository at this point in the history
  • Loading branch information
tbrezot committed Sep 6, 2022
1 parent 27694f9 commit e71d586
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
14 changes: 7 additions & 7 deletions src/asymmetric_crypto/curve25519.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@
//! 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},
scalar::Scalar,
};
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
Expand Down Expand Up @@ -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()))
}
}
Expand Down Expand Up @@ -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()))
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/symmetric_crypto/aes_256_gcm_pure/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ mod tests {
fn test_encryption_decryption_detached() -> Result<(), CryptoCoreError> {
let mut cs_rng = CsRng::new();
let key = Key::<KEY_LENGTH>::new(&mut cs_rng);
let bytes = cs_rng.generate_random_bytes::<8192>();
let bytes = cs_rng.generate_random_bytes::<1024>();
let iv = Nonce::<NONCE_LENGTH>::new(&mut cs_rng);
// no additional data
let mut data = bytes;
Expand Down
6 changes: 3 additions & 3 deletions src/symmetric_crypto/key.rs
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -70,7 +70,7 @@ impl<'a, const KEY_LENGTH: usize> TryFrom<&'a [u8]> for Key<KEY_LENGTH> {
}

impl<const KEY_LENGTH: usize> Display for Key<KEY_LENGTH> {
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()))
}
}
Expand Down Expand Up @@ -108,7 +108,7 @@ impl<const KEY_LENGTH: usize> Deref for Key<KEY_LENGTH> {
mod tests {

use crate::{entropy::CsRng, symmetric_crypto::key::Key};
use std::ops::Deref;
use core::ops::Deref;

const KEY_LENGTH: usize = 32;

Expand Down
2 changes: 1 addition & 1 deletion src/symmetric_crypto/metadata.rs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/symmetric_crypto/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit e71d586

Please sign in to comment.