Take the 2-minute tour ×
Cryptography Stack Exchange is a question and answer site for software developers, mathematicians and others interested in cryptography. It's 100% free, no registration required.

We are having a requirement to store large files (~1GB) encrypted and decrypt them when reading. We are looking to use AES-CTR or AES-GCM mode to encrypt the data. There are scenarios where we want to divide the files into chunks/blocks and then decrypt these chunks in parallel. So my question is that is it possible to do it with these algorithms? If yes, what are considerable points while doing it. If no, how best to achieve it (the main requirement is to achieve parallelism).

share|improve this question
    
You can do that, but you'll have to create individual MAC fingerprints for each chunk (or authenticate everything before) because unauthenticated data is worthless. Depending on the number of chunks, this may or may not be viable. –  Thomas Jan 30 '13 at 11:10

1 Answer 1

With AES-CTR, it is trivial; it's actually one of the advantages of using the scheme. In AES-CTR, there is a counter which is incremented for each block, encrypted, and then XOR'ed to the ciphertext in order to obtain the plaintext. To parallelize the decryption of, e.g., 100 blocks, you simply encrypt the counter for the 1st-50th blocks in one thread and the counter of the 50th-100th blocks in another (simply add 50 to the initial counter value and start from there).

AES-GCM is more or less the same, since it also uses something like CTR internally for encryption. You will have to also check the authenticity, but this can also be done in parallel. (Some people are not confortable with starting decryption before checking the authenticity, but that's another discussion...)

share|improve this answer
    
Yeah, that's right however I am troubled getting that how best we can have a single file with multiple encrypted blocks & when we submit this file for decryption how we can split them right to decrypt? –  Deepesh M Feb 1 '13 at 3:59
    
Sorry, I'm not sure what is you question. Read the initial counter value. Determine the number of blocks, divide by the number of (e.g.) cores, and decrypt each chunk of blocks in each core. –  Conrado PLG Feb 1 '13 at 10:20
    
Ok, let me be more clear. Say I have 1GB file (file.txt) and I want to encrypt this file by encrypting 128MB chunks of this file. The resulting file should be enc_file.txt (1GB) containing encrypted chunks (Is it possible?). Now during decryption, I want to process chunks of enc_file.txt parallely. How to determine the boundaries of each chunks to submit to multiple threads? I hope I am more clear now –  Deepesh M Feb 1 '13 at 18:21
    
That's completely up to you. In your example, you have 10 chunks; you can decrypt the first five in one thread and the last five in another. The only restriction is that the size of each chunk must be a multiple of the block size of the cipher, e.g. 16 bytes in the case of AES. –  Conrado PLG Feb 1 '13 at 21:41
    
Thanks, now I am clear. –  Deepesh M Feb 2 '13 at 6:50

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.