1
$\begingroup$

I have a requirement where an encrypted file is read in random order of 32k chunks and decrypted and final content hash is computed. This hash should match the original content of file.

I need this as while I am reading file from source I want decryption and hash computation to happen, else I will have to write all the contents and then decrypt and compute hash, which will require two pass/(read/write) of file.

I believe AES stream mode would help in random order decryption, I have to try this though, but I am not sure about which hash function would help here, if its possible to compute any hash reading data in random chunks.

Any pointers would be of great help. Thanks for time.

$\endgroup$
5
  • 1
    $\begingroup$ Hash functions are sequential, however you may be able to build a custom hash function with some kind of block based function followed by finite field multiplication and a finalization step $\endgroup$ Dec 23, 2016 at 5:13
  • 4
    $\begingroup$ Look up Merkle Trees $\endgroup$ Dec 23, 2016 at 9:22
  • $\begingroup$ Just curious. Is your use of the hash anything other then ensuring integraty of data? I mean if you do not require it for deduplication purposes then why not store the hash of the cypher text $\endgroup$
    – dave.zap
    Dec 23, 2016 at 14:04
  • 1
    $\begingroup$ @RichieFrame Right, but it might be expensive to do so; more information here. For an unsuspecting visitor, Merkle Trees are definitely more practical. $\endgroup$
    – Maarten Bodewes
    Dec 24, 2016 at 1:01
  • $\begingroup$ Thanks all for suggestions, I'll look at Merkle Trees and give it a shot. $\endgroup$ Dec 26, 2016 at 4:53

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.