Assuming that I want to encrypt/decrypt a hard drive corresponding to /dev/sdX, the following is the procedure I have for doing so:
Encryption:
Write the hard drive's data into a file (e.g.
./tmp), using the commanddd if=/dev/sdX of=./tmpEncrypt the
tmpfile using any secure file encryption algorithmWrite the encrypted
tmp.encinto the hard drive (dd if=./tmp.enc of=/dev/sdX)
Decryption:
Write the hard drive's data into a file (e.g.
./tmp), using the commanddd if=/dev/sdX of=./tmp.encDecrypt the
tmp.encfileWrite the decrypted
tmpinto the hard drive (dd if=./tmp of=/dev/sdX)
Does the following method necessarily work?
/dev/sdXwith plain dm-crypt and write./tmpto the crypt. I think the bigger concern here is what "backs"./. (And what the question is really about. Sounds like some sort of XYproblem or homework question tbh.)tmpfile. To encrypt, we can compress and then use the algorithm that only encrypts (and to decrypt, we use the algorithm that only decrypts and then decompress it), so we're dealing with something liketmp.gz.enc