From 26ed97877bdbee0b9b67db52ff0d53b706361e08 Mon Sep 17 00:00:00 2001 From: Nick Johnson Date: Wed, 30 Oct 2024 20:48:21 -0700 Subject: [PATCH] Add no_std flag to the chacha20-poly1205 crate --- chacha20_poly1305/src/chacha20.rs | 1 + chacha20_poly1305/src/lib.rs | 7 +++++++ chacha20_poly1305/src/poly1305.rs | 1 + 3 files changed, 9 insertions(+) diff --git a/chacha20_poly1305/src/chacha20.rs b/chacha20_poly1305/src/chacha20.rs index 8f53e60c7..20b4ac605 100644 --- a/chacha20_poly1305/src/chacha20.rs +++ b/chacha20_poly1305/src/chacha20.rs @@ -326,6 +326,7 @@ fn keystream_at_slice(key: Key, nonce: Nonce, count: u32, seek: usize) -> [u8; 6 #[cfg(test)] #[cfg(feature = "alloc")] mod tests { + use alloc::vec::Vec; use hex::prelude::*; use super::*; diff --git a/chacha20_poly1305/src/lib.rs b/chacha20_poly1305/src/lib.rs index b8aaba5cc..7f60209f7 100644 --- a/chacha20_poly1305/src/lib.rs +++ b/chacha20_poly1305/src/lib.rs @@ -2,6 +2,12 @@ //! Combine the ChaCha20 stream cipher with the Poly1305 message authentication code //! to form an authenticated encryption with additional data (AEAD) algorithm. +#![no_std] + +#[cfg(feature = "alloc")] +extern crate alloc; +#[cfg(feature = "std")] +extern crate std; pub mod chacha20; pub mod poly1305; @@ -143,6 +149,7 @@ fn encode_lengths(aad_len: u64, content_len: u64) -> [u8; 16] { #[cfg(test)] #[cfg(feature = "alloc")] mod tests { + use alloc::vec::Vec; use hex::prelude::*; use super::*; diff --git a/chacha20_poly1305/src/poly1305.rs b/chacha20_poly1305/src/poly1305.rs index 72a16e45a..50d0e0a22 100644 --- a/chacha20_poly1305/src/poly1305.rs +++ b/chacha20_poly1305/src/poly1305.rs @@ -223,6 +223,7 @@ fn _print_acc(num: &[u32; 5]) { #[cfg(test)] #[cfg(feature = "alloc")] mod tests { + use alloc::vec::Vec; use hex::prelude::*; use super::*;