I'm realy a newbie in cryptography, I want to do MQTT payload encryption with AES, i've done it with PyCrypto library, but i'm still wondering how I can encrypt AES key before sending it to the subscriber, so i choose Python library called PyNacl to do that with ECC (curve25519), but i have no idea how to exchange the public key between the publisher and subscriber, have you any idea to do that ?

up vote 3 down vote accepted

Public keys by definition are public (no need to keep them secret).

So there is no reason it can't be available for download via http or at a push published as a retained message on a known MQTT topic.

  • thanks for responding if i got what you said , i can exchange public key in a separate topic and play with the code so that the message is sent only after receipt of the public key , right? – paulo huigo Aug 6 at 15:43
  • As a retained message the key would be delivered to the device as soon as it subscribed to the topic – hardillb Aug 6 at 15:44
  • ok that's clear , thank you – paulo huigo Aug 6 at 15:48
  • please I am stuck in python code, here is the scenario, client A want to send encrypted data to client B, but first he must receive client B public key, so both client A and B are publisher and subscriber at the same time on the same topic, client B send his public key as a retained message then B encrypt data and send it to B, for me it seems confusing when i want to implement it in paho mqtt python , have you any example to do that ? – paulo huigo Aug 7 at 15:41

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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