Stream Ciphers
Everything you need to know about PointyCastle's stream ciphers.
PointyCastle, as of now, supports three stream ciphers: ChaCha20 (original implementation), ChaCha20 (RFC-7539 implementation), and Salsa20. The parameters each needs are below in table form.
Cipher
IV? (Length)
Key Length
Salsa20
Yes, 8 bytes
32 bytes
ChaCha20
Yes, 8 bytes
32 bytes
ChaCha7539
Yes, 12 bytes
32 bytes
Because these are stream ciphers, no padding is necessary; each cipher can process any amount of data.
Constructing these algorithms is done either via the registry or via the class itself (see External API for more):
If you are using one of the ChaCha ciphers, you may also select the number of rounds.
Note: to use one of the ChaCha ciphers with the registry, you must append a /(rounds) to the end of the registry string. If you are unsure how many rounds to use, use 20.
Initializing looks pretty much the same with all these machines. Note the pattern of introducing parameters through the init method:
Finally, encryption (continuing from initialization.dart):
Decryption looks the same as encryption, but you pass the encrypted data and get back the original data. (This also continues from initialization.dart):
Isn't that simple? Most PointyCastle algorithms boil down like this: construct, initialize, and use.
Last updated