interledger / interledger-rs

An easy-to-use, high-performance Interledger implementation written in Rust
http://interledger.rs
Other
203 stars 70 forks source link

Implement nonce sequence and advancement #460

Open bstrie opened 5 years ago

bstrie commented 5 years ago

As brought up in a comment on the PR upgrading our version of ring: https://github.com/interledger-rs/interledger-rs/pull/413/files#r334223325

Why change to LessSafeKey? The docs say:

Prefer to use OpeningKey/SealingKey and NonceSequence when practical.

Thanks for the review! I am not a cryptography expert. This is what I understand the situation and hence my decisions so far:

My first thought is also to use OpeningKey/SealingKey, but these two key structures are now bound to a nonce sequence and have to encrypt/decrypt using the same nonce sequence. So it is not exactly the current behaviour we are using: which is to use a random nonce and append the nonce after the ciphertext.

But as the docs mention it is preferred to use OpeningKey/SealingKey instead, to make this possible we will have to implement a nonce sequence and advancement algorithm (There should be some good advancement strategy out there? I need to do some research) and we should manage the same nonce sequence between each encrypt-er and decrypt-er pairs?

Given the complexity I think it is better to move this into separate task and keep this PR as simple as keeping the current behaviour. I am also willing to continue this follow-up task and we can discuss more on the requirements.

emschwartz commented 5 years ago

@tarcieri Do you know if it would make sense for us to use the OpeningKey / SealingKey if we're using random nonces each time?