MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / dek_roundtrip

Function dek_roundtrip

nodedb/src/control/security/encryption.rs:319–339  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

317
318 #[test]
319 fn dek_roundtrip() {
320 use std::os::unix::fs::PermissionsExt as _;
321 let dir = tempfile::tempdir().unwrap();
322 let key_path = dir.path().join("master.key");
323 let mut key_data = [0u8; 32];
324 getrandom::fill(&mut key_data).unwrap();
325 std::fs::write(&key_path, key_data).unwrap();
326 std::fs::set_permissions(&key_path, std::fs::Permissions::from_mode(0o600)).unwrap();
327
328 let mut enc = VolumeEncryption::new(VolumeEncryptionConfig {
329 master_key_path: Some(key_path),
330 enabled: true,
331 algorithm: EncryptionAlgorithm::Aes256Gcm,
332 });
333 enc.load_master_key().unwrap();
334 assert!(enc.is_active());
335
336 let (dek, encrypted) = enc.generate_dek().unwrap();
337 let decrypted = enc.decrypt_dek(&encrypted).unwrap();
338 assert_eq!(dek, decrypted);
339 }
340
341 #[test]
342 fn key_rotation() {

Callers

nothing calls this directly

Calls 6

joinMethod · 0.80
load_master_keyMethod · 0.80
generate_dekMethod · 0.80
decrypt_dekMethod · 0.80
writeFunction · 0.50
pathMethod · 0.45

Tested by

no test coverage detected