I am designing a procedure and file format for the encryption application. I came to a point when I need to make a decision regarding the method/workflow of the encryption. I can't make up my mind on pros vs cons of using one approach over another.
Below is an overview of the format structure:
------------------------------------------ | File signature || fixed | plain | |----------------||----------|-----------| | Algorithm info || fixed | plain | |----------------||----------|-----------| | Seed || fixed | encrypted | |----------------||----------|-----------| | Data || variable | encrypted | |----------------||----------|-----------| | CRC || fixed | encrypted | ------------------------------------------
Initially, I am going to use SHA-256 for a Hash function and AES-256 for an Encryption algorithm, but later it will be configurable, as the format suggests.
Proposed procedure for creating encrypted container:
- Hash(Password) => Key-Pass
- Generate random Seed
- Key-Pass XOR Seed => Key-Seeded
- Encrypt Seed with Key-Pass and store encrypted Seed
- Encrypt Data with Key-Seeded and store encrypted Data
- Encrypt CRC with Key-Seeded and store encrypted CRC
Questions
A. Do I gain anything from storing encrypted Seed and CRC? Would it be less secure if I store them not encrypted?
B. Is it more or less or no difference in security of using [ Hash(Password + Seed) ] for key generation rather than prosed [ Hash(Password) XOR Seed ] for the final key?
C. A concluding question from two questions above. Would it be better or worse to use the alternative procedure for creating encrypted container:
- Hash(Password + Seed) => Key
- Store unencrypted Seed
- Encrypt Data with Key and store encrypted Data
- Store unencrypted CRC (or encrypted)
I guess I would have to store unencrypted Seed in order to regenerate Key on reading back the encrypted content. CRC can be either encrypted or unencrypted.