The xChaCha cipher detailed here extends the nonce 192bits and works as follows (from the link):
- Pass the key and the first 16 bytes of the 24-byte nonce to HChaCha20 to obtain the subkey.
- Use the subkey and remaining 8 byte nonce with ChaCha20 as normal (prefixed by 4 NUL bytes, since [RFC8439] specifies a 12-byte nonce).
My question is could we encrypt the 2nd part of the nonce by running an additional initial round (HChaCha20) with the 16 bytes of the nonce and the key?
We could use one of the two parts of the nonce as a counter by incrementing them, given they occupy the usual counter slots. I suppose the same question applies to XSalsa20.
I presume this would compromise something somewhere. It seems like a very simple and cheap way to make a brute force more difficult. The additional round(s) would take about 10ms.
EDIT - hopefully the below makes the idea (somewhat) clearer. My impoverished code is in javascript.
Note: HChaCha20 is initialized the same way as the ChaCha cipher, except that HChaCha20 uses a 128-bit nonce and has no counter. Instead, the block counter is replaced by the first 32 bits of the nonce.
//Encrypt
subkey = hchacha20(key, nonce[0:15]);
nonce[0]+=1; //or any part which occupies the usual counter block, nonce[0-4]?
subkey2 = hchacha20(key, nonce[0:15]);
nonce[0]-=1; //or..etc
subnonce = subkey2 ^ nonce[16:23];
chacha20_nonce = "\x00\x00\x00\x00" + nonce[16:23];
//Run ChaCha20
output = ciphertext + nonce[0:15] + subnonce);
//Decrypt
subkey = hchacha20(key, nonce[0:15]);
nonce[0]+=1; //or any part which occupies the usual counter block, nonce[0-4]?
subkey2 = hchacha20(key, nonce[0:15]);
subnonce = subkey2 ^ nonce[16:23];
chacha20_nonce = "\x00\x00\x00\x00" + subnonce;
//Run ChaCha20
output = plaintext;