paseto-standard / paseto-spec

Specification for Platform Agnostic SEcurity TOkens (PASETO)
165 stars 9 forks source link

Implicit length requirement of symmetric key #16

Closed brycx closed 2 years ago

brycx commented 2 years ago

In v2.local the symmetric key, provided by the user, is passed directly to XChaCha20-Poly1305. This gives the key an implicit requirement of being 32 bytes in length. In v4.local, the symmetric key is instead passed to BLAKE2b which supports keys in range of 1..=64.

I have so far not been able to find any place where the expected length of a symmetric key for v4.local is defined. Is this intended to remain 32 as with v2.local or should an implementer support that which BLAKE2b does?

Checking the PHP implementation, it seems to expect 32:

https://github.com/paragonie/paseto/blob/0d3558824bf77af36ad0cd6e4bb69dbd90ace3c9/src/Protocol/Version4.php#L52

In any case, I believe this could be worthwhile mentioning in the spec of Version 4. Or, perhaps, I've missed something obvious?

paragonie-security commented 2 years ago

It's always supposed to be 32 bytes (256 bits).

paragonie-security commented 2 years ago

We've made this explicit, rather than leaving developers to guess about this.

https://github.com/paseto-standard/paseto-spec/commit/500ef6730358e29c0d22836a17f22ba42de32ba4 + https://github.com/paseto-standard/paseto-spec/commit/09c3c5dc586fd4b7d6e21f3dd7c9e66c86270ed0

brycx commented 2 years ago

Thank you!