paragonie / paseto

Platform-Agnostic Security Tokens
https://paseto.io
Other
3.23k stars 108 forks source link

How to generate keys #65

Closed vegardlarsen closed 6 years ago

vegardlarsen commented 6 years ago

Thanks for this project. I have been reading through trying to get a grasp on things, and I think an important function for your API would be generating keys in a secure matter.

I see from your tests that symmetric keys for v2 are generated from 32 random bytes. Is 256 bits considered secure enough here? Could this be documented somewhere?

I think it would be useful if ProtocolInteface had two extra methods that would correspond to the algorithms in use:

It would be up to each version to decide what is considered a secure enough key. These could take an optional key length, preferably with guidance in the documentation as to which length to choose?

paragonie-scott commented 6 years ago

Is 256 bits considered secure enough here?

Yes.

These could take an optional key length, preferably with guidance in the documentation as to which length to choose?

At no point in the Paseto protocol is the key size dynamic.

This is all hard-coded into each protocol version. The goal of Paseto was to reduce the number of knobs and levers that developers have to mess with.

vegardlarsen commented 6 years ago

Thanks for the quick response.

I must have missed the part about static key lengths; but my point still stands. It should be easy to generate keys for use with each protocol version, and standardizing (in code) how keys are generated in each version would remove another opportunity for doing the wrong thing.

I love this project by the way. :)

paragonie-scott commented 6 years ago

That was a good idea, and it also uncovered a deficiency in the implementation. 👍