-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Closed
Labels
Description
Currently, the nonces used in secret connection are 12 bytes / 96 bits and basically a big endian encoded counter:
tendermint/p2p/conn/secret_connection.go
Lines 335 to 344 in 013b9ce
| // increment nonce big-endian by 1 with wraparound. | |
| func incrNonce(nonce *[aeadNonceSize]byte) { | |
| for i := aeadNonceSize - 1; 0 <= i; i-- { | |
| nonce[i]++ | |
| // if this byte wrapped around to zero, we need to increment the next byte | |
| if nonce[i] != 0 { | |
| return | |
| } | |
| } | |
| } |
For the sake of consistency (ChaCha20 is all little endian) it would be great to change the nonce encoding to little endian, too.
Additionally to that, a counter using a simple 64-bit (unsigned) integer should be sufficiently large. It will not overflow in practice and we should have rekeyed long before it happens.
We should then also encode the chunk size here using little endian, too.
Related discussion: tendermint/tmkms#38 (comment)
Reactions are currently unavailable