Skip to content

Commit

Permalink
Simplify use of alloc
Browse files Browse the repository at this point in the history
  • Loading branch information
jschneider-bensch committed Jan 15, 2025
1 parent b55be22 commit 3fc1be5
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 16 deletions.
3 changes: 3 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ extern crate std;
#[cfg(not(feature = "std"))]
extern crate alloc;

#[cfg(not(feature = "std"))]
use alloc as std;

mod tls13formats;
mod tls13handshake;
mod tls13record;
Expand Down
6 changes: 1 addition & 5 deletions src/test_utils.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
use crate::std::vec::Vec;
use rand::{CryptoRng, RngCore};
#[cfg(feature = "std")]
use std::vec::Vec;

#[cfg(not(feature = "std"))]
use alloc::vec::Vec;

pub struct TestRng {
bytes: Vec<u8>,
Expand Down
8 changes: 2 additions & 6 deletions src/tls13crypto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,9 @@ use libcrux::{
use libcrux_kem::{Ct, PrivateKey, PublicKey};
use rand::{CryptoRng, RngCore};

#[cfg(feature = "std")]
use std::{format, vec::Vec};
use crate::std::{format, vec::Vec};

#[cfg(not(feature = "std"))]
use alloc::{format, vec::Vec};

use std::fmt::Display;
use crate::std::fmt::Display;

use crate::tls13utils::{
check_mem, eq, length_u16_encoded, tlserr, Bytes, Error, TLSError, CRYPTO_ERROR,
Expand Down
6 changes: 1 addition & 5 deletions src/tls13utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@ use core::ops::Range;
#[cfg(feature = "hax-fstar")]
use hax_lib_macros::{attributes, requires};

#[cfg(feature = "std")]
use std::{format, string::String, vec, vec::Vec};

#[cfg(not(feature = "std"))]
use alloc::{format, string::String, vec, vec::Vec};
use crate::std::{format, string::String, vec, vec::Vec};

// FIXME: NOT HACSPEC | ONLY FOR DEBUGGING
pub(crate) fn parse_failed() -> TLSError {
Expand Down

0 comments on commit 3fc1be5

Please sign in to comment.