--key-source hsm: The DEK is wrapped (encrypted) by a Key Encryption Key (KEK) stored in the HSM.--key-source kms: The DEK is sent to a KMS (e.g., Vault Transit) for external wrapping.unique_ptr with a custom deleter).SafeHandle classes.Drop trait.For the most current information, always refer to the official Microsoft CNG documentation and the headers ncrypt.h and winerror.h .