7
$\begingroup$

Which of these two methods suits better the implementation of a secure chat application? In this context, chat will be limited up to 150 letters for one message.

I would prefer RSA because what I know RSA is really secure if it is used for small text and also if I will use groups it is easy in RSA because of public key distribution. Specially for chat application where user can write very small letters message I don't know if AES will be good for security.

AES is better in performance specially if I will compare 256 bit vs 4096 bit. RSA will be slower for encrypt and decrypt. But my goal is to have strong secure chat and not super fast chat.

What would be the more apt method?

I will use this chat only for sending message, e.g. no attachments, etc.

$\endgroup$
7
  • 12
    $\begingroup$ I would advise that you don’t devise your own scheme for a secure chat. Take a look at existing and reviewed crypto protocols and libraries for chat applications. $\endgroup$ Commented Jul 1, 2017 at 13:42
  • 2
    $\begingroup$ Everything depends on your security level. Do you mean neighbourhood level (your next door neighbour who spies you), hacker level (who might listen in for fun) or state level? This decision will govern your choice of key management and distribution. Who do you want to keep out? $\endgroup$
    – Paul Uszak
    Commented Jul 1, 2017 at 13:55
  • 4
    $\begingroup$ You may strongly want to consider using the Signal Protocol $\endgroup$
    – SEJPM
    Commented Jul 1, 2017 at 18:25
  • $\begingroup$ It's worth noting that the 4096-bit RSA keyspace is sparse; this is, there aren't $2^{4096}$ valid keys within it. Among other factors, this is one reason you can't directly compare it to AES's 256-bit keyspace. $\endgroup$
    – Nat
    Commented Jul 2, 2017 at 5:17
  • 1
    $\begingroup$ If you are making a secure chat application that others will use, i.e. it is not a hobby project for yourself alone, then this is not a question you should be asking. If you ask this for real-world use, use an existing protocol. If you ask this for a non-serious hobby project, then indicate so and use the given answers. $\endgroup$
    – Luc
    Commented Jul 2, 2017 at 11:34

5 Answers 5

22
$\begingroup$

RSA and AES do not oppose, and often are rightly used together in hybrid encryption. RSA can do things that AES can not, like allowing encryption to designated recipients, or allowing anyone to check that a message is not altered or from a different person than is apparent. Using AES or other form of symmetric encryption is a must when encrypting more than few hundred characters.

To choose a cryptosystem, you must first define your goals. Secure chat is not nearly precise enough. Confidentiality? Integrity? Proof of origin? Central registry of participants? How is registration and loss of keys handled?

$\endgroup$
1
$\begingroup$

"But my goal is to have strong secure chat and not super fast chat."

I would advise taking a look at Signal protocol. It is designed exactly for secure messaging and considers a lot of security aspects.

If you ask me the question that way, "RSA or AES"...well...The question should not be asked that way, but here's my answer: I would go for AES128+ and some Diffie-Hellman for key establishing.

$\endgroup$
0
$\begingroup$

RSA Pros:

  • Public/Private key based, messages can be exchanged without sharing the private key
    • Clients only need to send their public key, which ensures that the decryption key can't be compromised during the exchange.
  • Single recipient, a message sent to a specific client can only be read by that client
  • Easily revoke client access, to prevent a client from receiving a message all you need to do is not use their public key

RSA Cons:

  • Computationally expensive, RSA is very demanding of the CPU
  • Battery eater, using RSA frequently will drain the battery of mobile devices

AES Pros:

  • Fast/Energy Efficient, most new processors include instruction sets for AES encryption/decryption

AES Cons:

  • Key-based, requires all clients to know and use the same key
    • If the key is leaked, all future communication with that key is compromised
    • Anybody with the key can read the message, disallowing for messages to be sent to a specific person within the group
    • Unless you have a specific key for each person, no way to remove access for specific people

As @fgrieu stated, "hybrid encryption" would be the best choice for your application. Use RSA to exchange an AES key, that way there's no chance for the AES key to be compromised during the exchange, and you benefit from both the speed of AES and the security of RSA.

$\endgroup$
1
  • 1
    $\begingroup$ A few mistakes: clients don't need to just send the public key: they need to make sure that the key is trusted by the senders otherwise an adversary could pose as a receiver. If an RSA private key is leaked then communication to the receiver holding the key just as compromised as the situation for AES. $\endgroup$
    – Maarten Bodewes
    Commented Jul 1, 2017 at 23:58
-2
$\begingroup$

Both are quite secure given what we know today and what we think we know about what's coming in the next 20-30 years. Given that I'd chose AES-256.

$\endgroup$
1
  • 3
    $\begingroup$ You may want to add reasoning to support why you would pick "AES over RSA" to improve your answer. You may also want to adress the concern that two do very different things... $\endgroup$
    – SEJPM
    Commented Jul 1, 2017 at 18:28
-3
$\begingroup$

Disclaimer: The below answer is to the question-as-asked, rather than seeking to address the use scenario in the question.

Double crypt

You want to double-crypt; use AES or RSA, then the other. AES is super-fast on modern computers, so using both is basically as fast as RSA alone. So if you're not confident about either one, you may as well use both.

  • Encrypt your messages using RSA, then AES.

  • Decrypt your mesages using AES, then RSA.

Or, you can flip the order:

  • Encrypt your messages using AES, then RSA.

  • Decrypt your mesages using RSA, then AES.

RSA's way too slow for most uses, so this isn't a scheme most programmers would consider without a good reason. Plus, there's a lot that you're not doing (e.g. message authentication, protecting against replay attacks, inserting randomness into the messages), so it's probably open to some pretty easy attacks despite both RSA and AES being pretty strong individually, and even moreso together.

But, for the question as you've asked it, it's the way to go.

$\endgroup$
6
  • $\begingroup$ Could down-voters explain? $\endgroup$
    – Nat
    Commented Jul 4, 2017 at 7:47
  • $\begingroup$ I did not downvote but: So if you're not confident about either one, you may as well use both. No! just don't use it ! Also recommending a double crypt, is never a good option: e.g. 2xDES allows attack MitM. $\endgroup$
    – Biv
    Commented Jul 4, 2017 at 7:53
  • $\begingroup$ @Biv That logic doesn't follow; if you compare AES+RSA to 2xDES, then either alone is 1xDES, which is vastly weaker. Also, you can't MitM 256-bit AES; the keyspace is too large to fit into our universe according to known physics, much less being feasible on modern hardware. $\endgroup$
    – Nat
    Commented Jul 4, 2017 at 7:59
  • $\begingroup$ I'm not denying that a MitM on 256-bit AES is infeasible. Even attacking a single AES is not in that scale of feasibility. I'm just abstracting the reasoning about double encryption. $\endgroup$
    – Biv
    Commented Jul 4, 2017 at 8:08
  • $\begingroup$ @Biv Yeah, the MitM attack's a popular observation here, though it's so strange. I mean, first, it's completely infeasible - using modern technology, it's better to brute-force than to MitM a large keyspace. Secondly, MitM is just a special case of a space-time tradeoff attack, which is possible against single-cryption schemes, e.g. AES alone; so, stacking cryption schemes doesn't actually introduce any new weakness. I kinda suspect that everyone talks about MitM because it's so easy to understand, but it's also silly. $\endgroup$
    – Nat
    Commented Jul 4, 2017 at 8:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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