miscreant / meta

Meta-repository for Miscreant: misuse-resistant symmetric encryption library with AES-SIV (RFC 5297) and AES-PMAC-SIV support
https://miscreant.io
Other
474 stars 27 forks source link

[Question] Nonce Length #168

Closed LuoZijun closed 6 years ago

LuoZijun commented 6 years ago

Line: https://github.com/miscreant/miscreant/blob/master/rust/src/aead.rs#L144

Some IV_LEN(NONCE_LEN) code:

Can you add document for that nonce length ?

tarcieri commented 6 years ago

Miscreant supports a variable-length nonce. This is for two reasons:

1) A nonce in Miscreant is just a variable-length header input to the S2V function, which is effectively just a chained PRF construction. There are no restrictions on the lengths of the inputs to S2V, and therefore there are no restrictions on the lengths of Miscreant's nonces 2) In my observations placing artificial restrictions on the lengths of nonces that aren't actually required in the underlying construction has lead people to do things which actually weaken the security of the system. For example, I've seen people who wish to bind all relevant cryptographic parameters hash them all with RIPEMD160 in order to create a 24-byte Salsa20 nonce, when the very first thing XSalsa20 does is run them through the variable-length HSalsa20 PRF.

The code snippets you found are as follows: