1

I am working on securing a chat application written in Java (it is downloaded from the internet, and now I want to secure it in order to learn). I have read the documentation, but I am unable to figure out which mode of encryption is set by default, if I don't explicitly put one. Is it ECB? If so, what's the key differences between it and other modes of encryption in regards of a chat application? It's worth mentioning that I watched this explanation before posting here as I still couldn't figure out the answers to my questions.

The way I have encrypted/decrypted the messages transmitted is by:

  • A client writes a message, which gets encrypted (AES) and sent to the server
  • The server decrypts the message and broadcasts it to all the users on the server

I would say this is ECB.

I hope somebody can clarify it for me!

Bab
  • 433
  • 5
  • 12
  • 1
    The default is provider-specific. There is no reason to use the default, and relying on it is a common source of portability bugs. Always fully specify the "algorithm/mode/padding" argument to `Cipher.getInstance()`. – President James K. Polk Sep 26 '18 at 21:33
  • What is meant by provider-specific? – Bab Sep 26 '18 at 23:38
  • Bab: if more than one person has commented on a post, as is the case here, and you respond to one in particular, you should use the '@ user' feature to notify them. But anyway, provider-specific means specific to (i.e. can vary and is determined by) the provider, and the concept of providers is fundamental to Java crypto (JCA); since you asked about j7 (which is obsolete, BTW) see https://docs.oracle.com/javase/7/docs/technotes/guides/security/crypto/CryptoSpec.html#Design (but it's substantially the same in current versions) – dave_thompson_085 Sep 27 '18 at 00:11

1 Answers1

0

In the document you linked to, there is an example: Cipher c = Cipher.getInstance("AES/CBC/PKCS5Padding") it uses CBC mode. The same document lists ECB as a valid mode for AES.

You will have to spell out the mode yourself.

David Soroko
  • 8,521
  • 2
  • 39
  • 51