Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is this scenario secure?

I'm using RSA to encrypt communication between a server and a client. Lets say we have 2 Asymetric keys, key 1 and key2.

The server has key1 (Private) from the start and the client has the key1(public)

So here is the scenario:

  1. the client generates key2
  2. client connects to the server
  3. sending key2(public) encrypted with key1(public)
  4. from now on the server will send all data encrypted with the key2(public)
  5. the client sends some random data to the server
  6. the server sends back the same data hashed
  7. the client verifies that the data is right

As far as I can see this should prevent a man-in-the-middle attack, or am I missing something? At point 7 the client should know if someone is trying to give the server the wrong key to encrypt with, as no one else but the server can decrypt key2(public).

If there is anything that can be done to improve the security please tell me.

like image 781
Peter Avatar asked Mar 04 '09 18:03

Peter


People also ask

What is security scenario?

1 a policy of temporary secrecy by police or those in charge of security, in order to protect a person, place, etc., threatened with danger, from further risk.

Which of the following ways can you secure your password from disclosure?

Using passwords that can't be easily guessed, and protecting your passwords by not sharing them or writing them down can help to prevent this. Passwords should be at least 8 characters in length and use a mixture of upper and lower case letters, numbers, and symbols.


2 Answers

The best thing you can do to improve the security is to use an existing design and not try to reinvent the wheel. I'm not saying that what you've done is necessarily wrong, but just that many people much smarter than you and me have spent a lot of time thinking about this problem. Use TLS instead.

like image 120
Greg Hewgill Avatar answered Sep 21 '22 11:09

Greg Hewgill


As long as key1 (private) has not been intercepted somehow by a third-party, your scenario looks secure.

I think I saw this somewhere in a paper actually. In it, Alice gave Bob an unlocked box (key 1 public), then Bob put a bunch of his own boxes (key 2 public) in it, locks it and sends it back to Alice. Alice then opens the box(key 1 private), and now she can securely seal the boxes that Bob just gave her.

Despite the box analogy, that's essentially what you're doing, so I'd say its secure.

like image 37
samoz Avatar answered Sep 22 '22 11:09

samoz