I'm developing a pretty standard program which lets users save their work in a custom file format and reopen it later. Now I'd like to add the capability to encrypt the file using a user-defined password and I wonder what steps to take and what technologies to use.
From what I've read on the subject I think I need some way to derive an encryption key from the password, as well as some sort symmetric encryption algorithm which will be used to encrypt the relevant file content. There needs to be some unencrypted data in the file out of necessity (magic/version number, encryption parameters/salts/IVs) as well as some way to verify that those unencrypted parameters have not been tampered with. Finally, on decrypting the file we need some way to verify that the entered password was indeed correct, without introducing a potential attack vector.
So what steps should I take to achieve this?
Which technologies should I use?
What should be the general design of the file format?
The result should be secure enough by today's standards for a target audience of private users and small companies.