Skip to content

Instantly share code, notes, and snippets.

@ciastek
Created April 28, 2024 21:01
Show Gist options
  • Save ciastek/dab0af59a00aa1f9819f7038f57fdc90 to your computer and use it in GitHub Desktop.
Save ciastek/dab0af59a00aa1f9819f7038f57fdc90 to your computer and use it in GitHub Desktop.
Encryption Key Vault on USB drive for Synology's Full Volume Encryption
Synology DSM 7.2 introduced Full-Volume Encryption.
Encryption Key Vault can by stored locally or on a remote Synology NAS (KMIP server).
Local Encryption Key Vault is protected with a password, but it doesn't protect against
loss of an entire NAS device (by design, see [1]), because encrypted volumes are
automatically unlocked on boot. See [2] for a way to access an encrypted volume.
I don't know why Synology doesn't offer to store the Encryption Key Vault on USB drive
as it does with Key Manager/Key Store used by encrypted shared folders.
Anyway, DSM 7.2 does support Encryption Key Vault on USB drive, it's just not exposed
to the user. Maybe it's not yet ready for prime time?
The script creates an empty Encryption Key Vault on USB drive and enables it.
Then you can repair Encryption Key Vault via UI to put encryption keys of
unlocked encrypted volumes into it.
The script needs to be run a Synology NAS as a root (sudo).
[1]: https://kb.synology.com/en-global/WP/Synology_Volume_Encryption_White_Paper/4
[2]: https://forums.spacerex.co/t/bounty-first-person-to-share-how-to-break-into-dsm-7-2-encryption-keys-stored-on-box-gets-a-ds923/641/2
#!/bin/python
import sys, ctypes
lib = ctypes.cdll.LoadLibrary(r'/lib/libsynoencvolume.so')
lib.SYNOEncVolumeVaultCreateUSB.argtypes = [ctypes.c_char_p]
location = ctypes.create_string_buffer(b'/volumeUSB1/usbshare',size=69)
ret = lib.SYNOEncVolumeVaultCreateUSB(location)
sys.exit(ret)
@SorCelien
Copy link

SorCelien commented Jul 18, 2024

is there a way to specify a vault password for the external key vault? (when creating a normal key vault the user is asked to create a vault password for this key vault) Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment