I have recently read a bit about Lamport signatures (especially the approach using hash ladders to save disk space) and I found it very interesting that it entirely depends on a hash function.
So I asked myself the following question:
When you have a plaintext $p$ and hash it and concatenate it with its hash again and so on: plain -> $H(p) + H(H(p)) + H(H(H(p))) + ...$ ($n$-times)
is this a good source for randomness? Why not?
Does the attacker having a look at this output have any advantages in guessing the plaintext for large $n$?
You have some file you want to encrypt. Hash the file with a good hash function (e.g. Keccak). Then concatenate this hash with a password you choose. From this you derive a hash concatenation like above until it is as long as the file you want to encrypt; lets call it "hashchain". Then XOR your file with the hashchain and when you are finished you write the hash of the original file to the beginning of your encrypted file. Destroy original file and hashchain.
When you want to decrypt, take your password and the hash of the original file (which we have written to the beginning of the encrypted file), concatenate and hash this until you have a file which has the size of the original file. XOR both again and you get back your file from the beginning.
Note: Using password and hash of the original file as the beginning for the hash chain makes us able to use the same password for encryption of different files.
- Is there a reason why this is not secure?
I have no only superficial knowledge about cryptography, please keep this in mind when answering.