There are several constructions based on stream ciphers that use a 32-bit counter:
- AES-GCM
- AES-GCM-SIV
- ChaCha20Poly1305 (IETF version, but we can implement the "legacy" version with one too)
I was thinking it would be interesting to have a Ctr32 type which is generic around the block size. If so, I could impl the ChaCha20 and Salsa20 core functions as a sort of 512-bit wide pseudo-BlockCipher, which would let us have reusable stream cipher buffer management and seeking across all three of the aforementioned ciphers. Note that pulling this off would also need for it to be generic around endianness, as I believe AES-GCM needs a big endian counter and AES-GCM-SIV and ChaCha20Poly1305 need a little endian counter.
If we had that, it would also eliminate the need for the salsa20-core crate, or rather, we could merge it into the salsa20 crate.
Notably right now the only other ctr type, Ctr128, is specialized to a 128-bit block size. This actually seems ok to me, as it seems rather unusual to use a 128-bit counter with anything other than a 128-bit block size.
There are several constructions based on stream ciphers that use a 32-bit counter:
I was thinking it would be interesting to have a
Ctr32type which is generic around the block size. If so, I could impl the ChaCha20 and Salsa20 core functions as a sort of 512-bit wide pseudo-BlockCipher, which would let us have reusable stream cipher buffer management and seeking across all three of the aforementioned ciphers. Note that pulling this off would also need for it to be generic around endianness, as I believe AES-GCM needs a big endian counter and AES-GCM-SIV and ChaCha20Poly1305 need a little endian counter.If we had that, it would also eliminate the need for the
salsa20-corecrate, or rather, we could merge it into thesalsa20crate.Notably right now the only other
ctrtype,Ctr128, is specialized to a 128-bit block size. This actually seems ok to me, as it seems rather unusual to use a 128-bit counter with anything other than a 128-bit block size.