111111//! [`C_MAX`]: chacha20poly1305::C_MAX
112112
113113pub use crate :: hazardous:: stream:: chacha20:: { Nonce , SecretKey } ;
114+ use crate :: ZeroizeWrap ;
114115use crate :: {
115116 errors:: UnknownCryptoError ,
116117 hazardous:: {
@@ -120,7 +121,6 @@ use crate::{
120121 util,
121122} ;
122123use core:: convert:: TryInto ;
123- use zeroize:: Zeroizing ;
124124
125125/// The initial counter used for encryption and decryption.
126126pub ( crate ) const ENC_CTR : u32 = 1 ;
@@ -140,7 +140,7 @@ pub const A_MAX: u64 = u64::MAX;
140140/// Poly1305 key generation using IETF ChaCha20.
141141pub ( crate ) fn poly1305_key_gen (
142142 ctx : & mut ChaCha20 ,
143- tmp_buffer : & mut Zeroizing < [ u8 ; CHACHA_BLOCKSIZE ] > ,
143+ tmp_buffer : & mut ZeroizeWrap < [ u8 ; CHACHA_BLOCKSIZE ] > ,
144144) -> OneTimeKey {
145145 ctx. keystream_block ( AUTH_CTR , tmp_buffer. as_mut ( ) ) ;
146146 OneTimeKey :: from_slice ( & tmp_buffer[ ..POLY1305_KEYSIZE ] ) . unwrap ( )
@@ -196,7 +196,7 @@ pub fn seal(
196196
197197 let mut stream =
198198 ChaCha20 :: new ( secret_key. unprotected_as_bytes ( ) , nonce. as_ref ( ) , true ) . unwrap ( ) ;
199- let mut tmp = Zeroizing :: new ( [ 0u8 ; CHACHA_BLOCKSIZE ] ) ;
199+ let mut tmp = zeroize_wrap ! ( [ 0u8 ; CHACHA_BLOCKSIZE ] ) ;
200200
201201 let mut auth_ctx = Poly1305 :: new ( & poly1305_key_gen ( & mut stream, & mut tmp) ) ;
202202 let ad_len = ad. len ( ) ;
@@ -285,7 +285,7 @@ pub fn open(
285285
286286 let mut dec_ctx =
287287 ChaCha20 :: new ( secret_key. unprotected_as_bytes ( ) , nonce. as_ref ( ) , true ) . unwrap ( ) ;
288- let mut tmp = Zeroizing :: new ( [ 0u8 ; CHACHA_BLOCKSIZE ] ) ;
288+ let mut tmp = zeroize_wrap ! ( [ 0u8 ; CHACHA_BLOCKSIZE ] ) ;
289289 let mut auth_ctx = Poly1305 :: new ( & poly1305_key_gen ( & mut dec_ctx, & mut tmp) ) ;
290290
291291 let ciphertext_len = ciphertext_with_tag. len ( ) - POLY1305_OUTSIZE ;
@@ -355,7 +355,7 @@ mod test_vectors {
355355
356356 let mut chacha20_ctx =
357357 ChaCha20 :: new ( key. unprotected_as_bytes ( ) , nonce. as_ref ( ) , true ) . unwrap ( ) ;
358- let mut tmp_block = Zeroizing :: new ( [ 0u8 ; CHACHA_BLOCKSIZE ] ) ;
358+ let mut tmp_block = zeroize_wrap ! ( [ 0u8 ; CHACHA_BLOCKSIZE ] ) ;
359359
360360 assert_eq ! (
361361 poly1305_key_gen( & mut chacha20_ctx, & mut tmp_block) . unprotected_as_bytes( ) ,
@@ -383,7 +383,7 @@ mod test_vectors {
383383
384384 let mut chacha20_ctx =
385385 ChaCha20 :: new ( key. unprotected_as_bytes ( ) , nonce. as_ref ( ) , true ) . unwrap ( ) ;
386- let mut tmp_block = Zeroizing :: new ( [ 0u8 ; CHACHA_BLOCKSIZE ] ) ;
386+ let mut tmp_block = zeroize_wrap ! ( [ 0u8 ; CHACHA_BLOCKSIZE ] ) ;
387387
388388 assert_eq ! (
389389 poly1305_key_gen( & mut chacha20_ctx, & mut tmp_block) . unprotected_as_bytes( ) ,
@@ -411,7 +411,7 @@ mod test_vectors {
411411
412412 let mut chacha20_ctx =
413413 ChaCha20 :: new ( key. unprotected_as_bytes ( ) , nonce. as_ref ( ) , true ) . unwrap ( ) ;
414- let mut tmp_block = Zeroizing :: new ( [ 0u8 ; CHACHA_BLOCKSIZE ] ) ;
414+ let mut tmp_block = zeroize_wrap ! ( [ 0u8 ; CHACHA_BLOCKSIZE ] ) ;
415415
416416 assert_eq ! (
417417 poly1305_key_gen( & mut chacha20_ctx, & mut tmp_block) . unprotected_as_bytes( ) ,
0 commit comments