Search code examples
javaencryptionudpaesblowfish

What cipher for encrypting UDP packets?


I have an application that does time-sensitive communications over UDP (like video streaming or a game). Packets may be lost, and do not need to be re-transmitted.

What cipher should I use to encrypt the datagrams?

I'm leaning towards blowfish in ECB mode. I know ECB mode has problems, but I need to support missing packets, so the encryption cannot rely on previous blocks. Is there a better cipher or mode I can use to reduce the issues with ECB mode and still allow for missing packets?

(I'd like to keep everything pure Java, so I cannot use DTLS.)


Solution

  • You can use CBC mode, you just need to encrypt each packet as a separate CBC stream. That means re-starting CBC each packet, with a fresh IV.

    By the way, Blowfish is only a 64 bit (block size) block cipher, which these days inherently gives it a fairly low margin of security.