File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -38,12 +38,14 @@ type CustomRetryPolicy = FilteredRetryPolicy<
38
38
Box < dyn Fn ( & VssError ) -> bool + ' static + Send + Sync > ,
39
39
> ;
40
40
41
+ const KEY_LENGTH : usize = 32 ;
42
+
41
43
/// A [`KVStore`] implementation that writes to and reads from a [VSS](https://github.com/lightningdevkit/vss-server/blob/main/README.md) backend.
42
44
pub struct VssStore {
43
45
client : VssClient < CustomRetryPolicy > ,
44
46
store_id : String ,
45
47
runtime : Arc < Runtime > ,
46
- data_encryption_key : [ u8 ; 32 ] ,
48
+ data_encryption_key : [ u8 ; KEY_LENGTH ] ,
47
49
key_obfuscator : KeyObfuscator ,
48
50
}
49
51
@@ -237,6 +239,12 @@ impl KVStore for VssStore {
237
239
}
238
240
}
239
241
242
+ impl Drop for VssStore {
243
+ fn drop ( & mut self ) {
244
+ self . data_encryption_key . copy_from_slice ( & [ 0u8 ; KEY_LENGTH ] ) ;
245
+ }
246
+ }
247
+
240
248
fn derive_data_encryption_and_obfuscation_keys ( vss_seed : & [ u8 ; 32 ] ) -> ( [ u8 ; 32 ] , [ u8 ; 32 ] ) {
241
249
let hkdf = |initial_key_material : & [ u8 ] , salt : & [ u8 ] | -> [ u8 ; 32 ] {
242
250
let mut engine = HmacEngine :: < sha256:: Hash > :: new ( salt) ;
You can’t perform that action at this time.
0 commit comments