hapijs / iron

Encapsulated tokens (encrypted and mac'ed objects)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Why not public/private key cryptography?

christhomas opened this issue · comments

I realise that maybe I'm out of my depth here, but if I never ask, I might never know the reason.

Why not just encrypt the data with off the shelf public/private key encryption? It appears at face value to support what you want to do without all the specialised wrapping, apart from the extra fields to support features such as TTL, the server could encrypt it's data using it's own public key and send it to the client, knowing the client cannot decrypt it anyway.

or maybe this is what it's doing and I need to learn more of the terminology?

You are mixing a bunch of different things. You should never use your server TLS certificate keys for anything other than that. Using asymmetric encryption is much slower than symmetric one. There is no need for a public key because no one else is allowed to decode the message. And you will still need everything else this is doing.

yes true, I'm not trying to attack the idea, I'm just wondering because I had a conversation with a friend about the topic recently.

also, this only really solves one part of the problem, protecting the data from snooping, it doesn't do the rest of what this system does, which is manage the session and implement the logic for handling the login and authentication.

the only difference I can see, an advantage is that public key encryption lets you give you publically the encryption key as long as you secure the private key, so you can stop people from obtaining messages encrypted and decoding them, which is possible with a symmetric key, but if I encrypt something, I need to obtain the private key to do that, which might not be possible.

I'm not sure what you're referring to with "you are mixing a bunch of different things" since I'm talking about encrypting the data using a public key, which stops people from snooping the data, secures the transport of information and negates the need for any HMAC's or other hashes since the whole package is protected by the encryption key

Obviously I'm not taking into account the performance differences between the two

Encryption and verification are not the same thing. Using public key here only adds the benefit that you can separate the server encrypting the data from the server decoding it without sharing the full key. That's pretty much it.

commented

This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.