@@ -21,12 +21,12 @@ impl StorableBuilder {
21
21
22
22
let mut data_blob = PlaintextBlob { value : input, version } . encode_to_vec ( ) ;
23
23
24
- let mut cipher = ChaCha20Poly1305 :: new ( & self . data_encryption_key , & nonce, & vec ! [ ] ) ;
24
+ let mut cipher = ChaCha20Poly1305 :: new ( & self . data_encryption_key , & nonce, & [ ] ) ;
25
25
let mut tag = [ 0u8 ; 16 ] ;
26
26
cipher. encrypt_inplace ( & mut data_blob, & mut tag) ;
27
27
Storable {
28
28
data : data_blob,
29
- encryption_metadata : Option :: from ( EncryptionMetadata {
29
+ encryption_metadata : Some ( EncryptionMetadata {
30
30
nonce : nonce. to_vec ( ) ,
31
31
tag : tag. to_vec ( ) ,
32
32
cipher_format : CHACHA20_CIPHER_NAME . to_string ( ) ,
@@ -36,11 +36,11 @@ impl StorableBuilder {
36
36
37
37
pub fn deconstruct ( & self , mut storable : Storable ) -> io:: Result < ( Vec < u8 > , i64 ) > {
38
38
let encryption_metadata = storable. encryption_metadata . unwrap ( ) ;
39
- let mut cipher = ChaCha20Poly1305 :: new ( & self . data_encryption_key , & encryption_metadata. nonce , & vec ! [ ] ) ;
39
+ let mut cipher = ChaCha20Poly1305 :: new ( & self . data_encryption_key , & encryption_metadata. nonce , & [ ] ) ;
40
40
let input_output = storable. data . as_mut ( ) ;
41
41
42
42
if cipher. decrypt_inplace ( input_output, encryption_metadata. tag . borrow ( ) ) {
43
- let data_blob = PlaintextBlob :: decode ( & * input_output) . map_err ( |e| Error :: new ( ErrorKind :: InvalidData , e) ) ?;
43
+ let data_blob = PlaintextBlob :: decode ( & input_output[ .. ] ) . map_err ( |e| Error :: new ( ErrorKind :: InvalidData , e) ) ?;
44
44
Ok ( ( data_blob. value , data_blob. version ) )
45
45
} else {
46
46
Err ( Error :: new ( ErrorKind :: InvalidData , "Invalid Tag" ) )
0 commit comments