I've a Device A which will communicate with multiple devices on a network (BLE and/or NFC).

All the devices will be handled a Token upon authentication which somehow needs to be transferred over to the Device A over network securely and confidentially.

What is the best possible way to achieve it.? I guess something like SSL handshaking will be secure, but a simpler solution will be preferred.

Basically Device A needs to act as a server.

Research done so far has led me to the following flow:

  • Device A manages to send a public key to client.
  • The client uses the key to encrypt the Token and send it to Device A.
  • Only Device A can read the Token and authenticate the client.

Problems with this approach (and their solutions, as per my limited knowledge while dealing with security systems):

  • The token is same and the public key might repeat as well, giving a weak point in the system.

    • The token will be transferred over the network with a nonce.
  • MIM attack: Any Device X can mimic Device A and send a public key to client and initiate transaction. Now Device X knows the Token and mimic the client.

    • The Device A should possess some kind of digital certificate to prove its authenticity. The digital certificate will be assigned by a server written in Python/Django. And the all the clients should be able to verify the certificate without interacting with server.


  • Since I need this for mobile devices, I need the public private key pair to be as short as possible but yet secure.


  • How can I implement the last part algorithm? Is there any open source python library available for generating, issuing and verifying certificates?
  • Is the algorithm secure ? I'm a newbie in security and would like any valuable feedback.

Thanks in Advance!!

  • You don't care if the public key repeats. It's meant to be public. If you buy a 2-year SSL cert, your site will use the same public key for 2-years. Not a problem. Apr 21, 2015 at 19:13
  • What do you mean that the token may repeat? When a client authenticates it may get the same token for different sessions? That sounds like a vulnerability. Apr 21, 2015 at 19:14
  • @NeilSmithline the token will repeat. It appeared to be a vulnerability to me as well. So I introduced a Nonce as well. It should overcome the vulnerability. Right? I'm not sure about it, please provide your feedback considering it. Thanks Apr 22, 2015 at 5:45
  • The repeating token sounds problematic and a nonce sounds like a good fix. That said, without a better understanding of the whole setup, that's about the best that I can say. Hope that helps. Apr 23, 2015 at 14:24
  • @NeilSmithline Yes, I understand. Surely it helped :) Thanks a lot. Apr 24, 2015 at 18:11

1 Answer 1


Sounds like a very cool project. It seems that you have rediscovered the very problem that Kerberos was designed to solve.

Looking at your example, why would you not just use PKI both ways? Or can you not control the certificates at both ends? You could look at SSL session initialization to see how you could transfer a confidential message under the gaze of a warden.

If you are rolling your own solution, you will find that secure key storage is a very difficult problem to overcome.

EDIT: To address your well thought out concern, Elliptic Curve Cryptography is often used on mobile devices because of computational limitations.

  • Yeah. Don't roll your own. SSL already solves the MiTM attack problem so you don't need to. Apr 21, 2015 at 19:11
  • I would agree to not use your own secure channel. But, I would recommend re-implementation for educational purposes, sometimes it can be the best way for the deepest understanding. But, I would certainly recommend against using it in any production capacity.
    – M15K
    Apr 21, 2015 at 19:17
  • @M15K Thanks a ton. I'll read about it and bother you guys in case I have any doubts. Apr 22, 2015 at 5:42
  • @NeilSmithline SSL already solves MiTM attack, but the problem is (or I'm not yet aware of it) that I need to secure the connection between two MOBILE (Android and/or iOS, I forgot to mention) devices. How can I implement SSL for mobile clients is really what I'm looking for. Thanks Apr 22, 2015 at 5:45
  • @M15K I also forgot to mention my concerns. Please have a look at it whenever possible. Thanks a lot. Apr 22, 2015 at 6:56

You must log in to answer this question.

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