I'm currently teaching myself about cryptography with the intentions of learning more about cryptanalysis. As of now I'm learning about cipher modes! I understand that I should be looking into CBC, CFB, and OFB.

I understand that CBC mode is preferable when it comes to enciphering files and such but which mode is preferred for enciphering networking protocols?

I know that ECB mode is used for enciphering random data and is vulnerable to replay attacks. Though since it's easy to crypanalyze my assumption is that it shouldn't be used to protect the confidentiality of network data.

I'm open to the idea that my assumptions could be wrong. So once again, What is the best cipher mode to use for the encryption of data being sent over a tcp socket?

my goal this to implement AES though I still have many leaps to take. If the cipher modes can be used with other algorithms. please, don't hold back your knowledge!

  • What have you done to research this? Did you look at TLS 1.3 for example (e.g. this question)
    – Josef
    May 14, 2018 at 13:54

1 Answer 1


Modern network traffic encryption uses GCM by default.

ECB is used for teaching students about encryption. It's not really useful for anything else.

CBC is the simplest secure mode for static files, but it lacks authentication, so should never be used over a vulnerable channel (network). It's been obsoleted or deprecated from such uses.

It's not really ideal for files either, just simple. File encryption is generally best served by GCM-SIV (opinions will vary). For disk encryption the current industry-standard mode is XTS.

GCM combines most of the performance of CTR with good security, authentication and moderate overhead. If you plant to implement AES, use open source GCM implementations. Write only as much of your own code as necessary to integrate and call third-party libraries.

  • 1
    XTS isn't preferable for files either, its sole use case is disk encryption. May 14, 2018 at 15:53
  • True, it's disk specific. Adjusted. May 14, 2018 at 16:07
  • I don't know if this is necessarily true, depending on your definition of network traffic. KASUMI (used on 3G connections) for example is run in OFB mode, and WiFi (IEEE 802.11) when using CCMP uses AES in CCM mode. If the question is specifically about TLS then I'd say even then CBC is likely more popular, even if GCM is "better".
    – forest
    May 15, 2018 at 6:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .