Do you need to set an encryption key before using nvme-cli cryptographic erase or cryptographic sanitize?

nvme-cli has both a format and sanitize command that can be used to securely erase an NVMe SSD. Both of these commands offer a cryptographic approach, where the drive’s encryption key is changed/deleted, making the data inaccessible.

Sanitize device /dev/nvme0n1 using Crypto Erase sanitize operation

nvme sanitize /dev/nvme0n1 -a 4

Securely erase /dev/nvme0n1 via Cryptigraphic erase

nvme format /dev/nvme0n1 -s 2

Questions:

  1. Do you need to explicitly set a password/encryption key prior to issuing either of these commands. If so, how?

  2. How to verify the encryption key has been set prior to issuing the command, and verify it’s been successfully removed, after the command has completed?