0

Diffie-Hellman won't really work here, since only one side has a public key, one side has the private. It must be this way to prevent decryption when the data is at-rest on one of the sides before transmission.

Currently, I am using RSA-2048 only, which limits the payload size to 245 bytes. I want to support much larger sizes of data, so a RSA/AES hybrid makes sense.

I know that it would work if I generate a random AES key, encrypt that AES key using the RSA public key, encrypt the real payload using the AES key, and then serialize them in sequence (this has to be transmitted as one chunk) like so...

<RSA-encrypted-AES-key> <some-delimiter> <data-encrypted-with-AES>

My question is... should I just use the above format with the delimiter? Seems pretty straight forward. Perhaps there is a more standard / expected way to serialize these two together?

  • 1
    I don't think you need a standard. In this case, you can concatenate it the way you want, use JSON, XML, use MIME Encoding, whatever works for you. – ThoriumBR Aug 6 at 15:51
  • 1
    I'm not even sure that you need a delimiter if the encrypted key is the same size every time. – user Aug 6 at 15:56
  • good point on fixed size. might use one just in case we want longer keys alter – Wisteso Aug 6 at 16:59
  • 1
    RSA-KEM little explanation, here or rfc5990 – kelalaka Aug 6 at 17:08
  • 1
    Dupe security.stackexchange.com/questions/233290 and security.stackexchange.com/questions/233293 . Also remember Stevens: "the great thing about standards is there are so many to choose from". – dave_thompson_085 Aug 7 at 3:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.