1
$\begingroup$

This question already has an answer here:

Normal AES-GCM generates an authentication tag at the end of encryption. I want to decrypt it while it is still being encrypted. This would be useful to send, encrypt, receive and decrypt a large file (for example) in one go.

This would also be useful for other things like for video streams or encrypted calls. How could I do that? Switching to CBC seems like a bad idea.

$\endgroup$

marked as duplicate by kelalaka, Gilles, AleksanderRas, tylo, puzzlepalace Aug 12 at 20:29

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    $\begingroup$ Welcome to Cryptography. This is rather a programming question, belongs to SO. There is already similar question arisen before, there. See this one, for example. $\endgroup$ – kelalaka Aug 10 at 15:34
  • 1
    $\begingroup$ @kelalaka this question is 65% crypto, 35% programming. The question you linked is a different issue. $\endgroup$ – user11227590 Aug 10 at 20:17
  • $\begingroup$ In one of the question in SO, I've proposed, splitting the file into parts than adding the TAG into the next block. as block-chain. Also, If you look at Netflix, it uses TLS with AES-GCM where TLS transfers only $2^{14}$-byte framing. $\endgroup$ – kelalaka Aug 10 at 20:48
  • 1
    $\begingroup$ See also this answer Real time video stream AES encryption with authentication $\endgroup$ – kelalaka Aug 10 at 21:35
  • $\begingroup$ @kelalaka: "...I've proposed, splitting the file into parts than adding the TAG into the next block. as block-chain..." Can you find that? I've been looking around and haven't been able to. $\endgroup$ – James K Polk Aug 14 at 18:37
0
$\begingroup$

AES-GCM can be used as a as stream cypher by splitting the input to multiple blocks along with a nonce. However using AE for each block may not be an efficient technique.

$\endgroup$
  • $\begingroup$ I don't have to decrypt every block instantly, I could split it up, for example frame by frame for video streaming. But how would I do that? Should I create a new individual IV and Tag for each new "Packet"? $\endgroup$ – user11227590 Aug 10 at 20:38
  • $\begingroup$ @user11227590 I think there's a counter value separate from the IV. Iterate the counter value. $\endgroup$ – Natanael Aug 11 at 0:11
  • $\begingroup$ Welcome to crypto.stackexchange - If you have the time, consider quoting/summarizing some of the content from the links in your answer; Links expire, and if that happens it can turn a useful answer into a non-useful one. Plus, a more detailed answer will probably net you more up votes. $\endgroup$ – Ella Rose Aug 11 at 2:43
  • $\begingroup$ @Natanael neither javas Cipher nor C#s AuthenticatedAesCng have got counter value. $\endgroup$ – user11227590 Aug 11 at 10:23

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