File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -26,19 +26,21 @@ impl StorableBuilder {
26
26
/// [`PutObjectRequest`]: crate::types::PutObjectRequest
27
27
pub fn build ( & self , input : Vec < u8 > , version : i64 ) -> Storable {
28
28
let mut rng = ThreadRng :: default ( ) ;
29
- let mut nonce = [ 0u8 ; 12 ] ;
29
+ let mut nonce = Vec :: with_capacity ( 12 ) ;
30
+ nonce. resize ( 12 , 0u8 ) ;
30
31
rng. fill_bytes ( & mut nonce[ 4 ..] ) ;
31
32
32
33
let mut data_blob = PlaintextBlob { value : input, version } . encode_to_vec ( ) ;
33
34
34
35
let mut cipher = ChaCha20Poly1305 :: new ( & self . data_encryption_key , & nonce, & [ ] ) ;
35
- let mut tag = [ 0u8 ; 16 ] ;
36
+ let mut tag = Vec :: with_capacity ( 16 ) ;
37
+ tag. resize ( 16 , 0u8 ) ;
36
38
cipher. encrypt_inplace ( & mut data_blob, & mut tag) ;
37
39
Storable {
38
40
data : data_blob,
39
41
encryption_metadata : Some ( EncryptionMetadata {
40
- nonce : Vec :: from ( nonce ) ,
41
- tag : Vec :: from ( tag ) ,
42
+ nonce,
43
+ tag,
42
44
cipher_format : CHACHA20_CIPHER_NAME . to_string ( ) ,
43
45
} ) ,
44
46
}
You can’t perform that action at this time.
0 commit comments