Encrypt a file for random access but only after an initial read of the whole file I'm symmetrically encrypting a file (using a random salt and a user supplied password with PKCS5S2, i.e., nothing special) and I need to be able to access it randomly. Therefore I'm using a stream cipher. This works well, but it allows the attacker to verify a wrong password when reading only a tiny part of the file (garbled data are easy to recognize).

IIRC there's an encryption schema making it impossible to read any part of the data in isolation, you must read it all (I forgot how it's called). This seems to conflict with my random access requirement, however I always need to read the whole file first and then I need the random access.

Is there an encryption schema allowing this, i.e.,


to obtain any information, all data must be decrypted first
afterwards, any portion of the data can be decrypted in isolation
Yes, you can do that.  Start by generating a random key and encrypting the data under that key.  Now, you in turn encrypt that key with your password-derived key.  The twist is that you include the already encrypted file in your PBKDF.  So you generate a random key $k$ and then encapsulate it as $\mathcal{E}_{k'}(k)$, where $k' = H(PBKDF(\text{password}) \| \mathcal{E}_k(\text{file})$.  That way, to decrypt you have to read and hash the entire encrypted file to obtain the wrapper key, which gives you the key to decrypt the file itself.  Once you have that key you can do random access, but for each password attempt you have to read and hash the whole file again.