0
$\begingroup$

So, I have a java CipherInputStream encrypted using AES/GCM/NoPadding (Bouncy Castle). I can decrypt the stream just fine with the IV (12 bytes) and the AES key.

Is there any way I can decrypt the stream if I start reading it from some random byte?

Can I generate a correct new IV knowing the original one, byte im starting to read from and total stream length?

$\endgroup$
  • 1
    $\begingroup$ If you want to ask this question, but want implementation advice, you need to ask over on stackoverflow.com as we don't take care of programming questions. $\endgroup$ – SEJPM Oct 4 '16 at 13:42
2
$\begingroup$

Note: This answer is entirely theoretical and may not be implemented in your favorite software library.


Is there any way I can decrypt the stream if I start reading it from some random byte?

Yes and no.
Yes, you can jump to some random byte in a AES-GCM cipher text and decrypt it, by just applying the underlying CTR decryption, i.e. by incrementing the counter appropriately.

No, you really shouldn't do that, because this way you can't verify the tag, because this requires parsing and processing of the entire cipher text (including the IV). And if you can't verify the tag, the cipher text can be altered trivially without you even knowing it.

Yes and no, you can just verify the tag, as it's a function of the ciphertext and that quite fast and afterwards, if the tag is valid, decrypt only the bytes that interest you. The pure verification is as couple of times faster than the full verification and decryption and hence you indeed would save some computational ressources.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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