@@ -7,8 +7,8 @@ use std::borrow::Borrow;
77use std:: io;
88use std:: io:: { Error , ErrorKind } ;
99
10- /// [`StorableBuilder`] is a helper utility to build and deconstruct [`Storable`] objects.
11- /// It provides client-side ` Encrypt-then-MAC` using ChaCha20-Poly1305.
10+ /// [`StorableBuilder`] is a utility to build and deconstruct [`Storable`] objects.
11+ /// It provides client-side Encrypt-then-MAC using ChaCha20-Poly1305.
1212pub struct StorableBuilder {
1313 data_encryption_key : [ u8 ; 32 ] ,
1414}
@@ -18,22 +18,20 @@ const CHACHA20_CIPHER_NAME: &'static str = "ChaCha20Poly1305";
1818impl StorableBuilder {
1919 /// Creates a [`Storable`] that can be serialized and stored as `value` in [`PutObjectRequest`].
2020 ///
21- /// Uses ChaCha20 for encrypting the `input` and Poly1305 for generating mac/tag.
21+ /// Uses ChaCha20 for encrypting `input` and Poly1305 for generating a mac/tag.
2222 ///
2323 /// Refer to docs on [`Storable`] for more information.
2424 ///
2525 /// [`PutObjectRequest`]: crate::types::PutObjectRequest
2626 pub fn build ( & self , input : Vec < u8 > , version : i64 ) -> Storable {
2727 let mut rng = ThreadRng :: default ( ) ;
28- let mut nonce = Vec :: with_capacity ( 12 ) ;
29- nonce. resize ( 12 , 0u8 ) ;
28+ let mut nonce = vec ! [ 0u8 ; 12 ] ;
3029 rng. fill_bytes ( & mut nonce[ 4 ..] ) ;
3130
3231 let mut data_blob = PlaintextBlob { value : input, version } . encode_to_vec ( ) ;
3332
3433 let mut cipher = ChaCha20Poly1305 :: new ( & self . data_encryption_key , & nonce, & [ ] ) ;
35- let mut tag = Vec :: with_capacity ( 16 ) ;
36- tag. resize ( 16 , 0u8 ) ;
34+ let mut tag = vec ! [ 0u8 ; 16 ] ;
3735 cipher. encrypt_inplace ( & mut data_blob, & mut tag) ;
3836 Storable {
3937 data : data_blob,
0 commit comments