So I need to encrypt a file server-side for transport from server to client and storage on client-side. I'm quite confused as to what I have to watch out for, as it seems like it's insanely easy to screw up really bad.
The files I need to encrypt
- Are binary
- Sometimes contain big areas of null bytes.
- Are of medium size, usually < 1gb.
- Usually start with the same or similar header, so plaintext will often be the same.
- Dont need to be encrypted often, but decrypted often, as they will not be stored decrypted.
- Should remain very secure for a long time.
What I thought I could do is to use AES-256 in OCB3 mode, as it seems to provide both authentication and encryption.
I'm however not very sure about how I would go about generating a suitable key from a password. Is using a simple hash function like SHA-256 secure?
I'm assuming I'll have to store the IV along with the file. Is that correct?
Would AES-256 in OCB3 mode be suitable for this sort of task or is there a better way of doing this?
By the way, I am aware that it's quite easy to read the decrypted file from memory when it's decrypted at client-side, but I'm afraid there's not much I can do about it.
Edit: Both server and client programs are written in c++. I also want to be able to encrypt and decrypt the files just in memory at runtime, so a lot of file encryption tools don't really fit the task.