35/WAKU2-NOISE: update RFC with padding algorithm (#526)

* fix(noise): update RFC to implementation

* fix(noise): specify padding; clarify Chachapoly tag size
This commit is contained in:
G 2022-08-16 22:36:04 +02:00 committed by GitHub
parent 26b3a33026
commit 7143c976fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -56,7 +56,7 @@ We refer to [Noise protocol framework specifications](http://www.noiseprotocol.o
Four Noise handshakes are currently supported: `K1K1`, `XK1`, `XX`, `XXpsk0`. Their description can be found in [Appendix: Supported Handshakes Description](#Appendix-Supported-Handshake-Description). Four Noise handshakes are currently supported: `K1K1`, `XK1`, `XX`, `XXpsk0`. Their description can be found in [Appendix: Supported Handshakes Description](#Appendix-Supported-Handshake-Description).
These are instantiated combining the following cryptographic primitives: These are instantiated combining the following cryptographic primitives:
- [`Curve25519`](http://www.noiseprotocol.org/noise.html#the-25519-dh-functions) for Diffie-Hellman key-exchanges (32 bytes curve coordinates); - [`Curve25519`](http://www.noiseprotocol.org/noise.html#the-25519-dh-functions) for Diffie-Hellman key-exchanges (32 bytes curve coordinates);
- [`ChaChaPoly`](http://www.noiseprotocol.org/noise.html#the-chachapoly-cipher-functions) for symmetric authenticated encryption (16 bytes block size); - [`ChaChaPoly`](http://www.noiseprotocol.org/noise.html#the-chachapoly-cipher-functions) for symmetric authenticated encryption (16 bytes authentication tag);
- [`SHA256`](http://www.noiseprotocol.org/noise.html#the-sha256-hash-function) hash function used in [`HMAC`](http://www.noiseprotocol.org/noise.html#hash-functions) and [`HKDF`](http://www.noiseprotocol.org/noise.html#hash-functions) keys derivation chains (32 bytes output size); - [`SHA256`](http://www.noiseprotocol.org/noise.html#the-sha256-hash-function) hash function used in [`HMAC`](http://www.noiseprotocol.org/noise.html#hash-functions) and [`HKDF`](http://www.noiseprotocol.org/noise.html#hash-functions) keys derivation chains (32 bytes output size);
#### Content Topics of Noise Handshake Messages #### Content Topics of Noise Handshake Messages
@ -81,7 +81,7 @@ After the second handshake message is correctly received by initiators, the reco
### Encryption Primitives ### Encryption Primitives
The symmetric primitives supported are: The symmetric primitives supported are:
- [`ChaChaPoly`](https://www.ietf.org/rfc/rfc7539.txt) for authenticated encryption (16 bytes block size). - [`ChaChaPoly`](https://www.ietf.org/rfc/rfc7539.txt) for authenticated encryption (16 bytes authentication tag).
## Specification ## Specification
@ -190,11 +190,9 @@ while ephemeral keys MAY be encrypted after a handshake is complete.
### Padding ### Padding
To prevent some metadata leakage, To prevent some metadata leakage,
encrypted transport messages SHOULD be padded before encryption encrypted transport messages SHOULD be padded before encryption.
to a multiple of the underlying symmetric cipher block size
(16 bytes for `ChaChaPoly`).
It is therefore recommended to right pad transport messages to a multiple of 256 bytes. It is therefore recommended to right pad transport messages using [RFC2630](https://datatracker.ietf.org/doc/html/rfc2630#section-6.3) so that their final length is a multiple of 248 bytes.
## After-handshake ## After-handshake
@ -327,6 +325,7 @@ The main difference with `XX` is that Alice's and Bob's static keys, when transm
5. [Noise protocol](http://www.noiseprotocol.org/noise.html) 5. [Noise protocol](http://www.noiseprotocol.org/noise.html)
6. [Noise handshakes as key-exchange mechanism for Waku2](https://forum.vac.dev/t/noise-handshakes-as-key-exchange-mechanism-for-waku2/130) 6. [Noise handshakes as key-exchange mechanism for Waku2](https://forum.vac.dev/t/noise-handshakes-as-key-exchange-mechanism-for-waku2/130)
7. [Augmented Backus-Naur form (ABNF)](https://tools.ietf.org/html/rfc5234) 7. [Augmented Backus-Naur form (ABNF)](https://tools.ietf.org/html/rfc5234)
8. [RFC2630 - Content-encryption Process and padding](https://datatracker.ietf.org/doc/html/rfc2630#section-6.3)
## Copyright ## Copyright