, 8 tweets, 2 min read Read on Twitter
1/ Cryptographers can't code. I mention this because at the moment I'm trying to write a simple implementation of ChaCha20, and am being amazingly defeated by this task.
2/ My first stab at this is just to follow rfc7539, which looks simple enough. But then I realize that this is broken. They arbitrarily decided to change the algorithm from a 64-bit counter and 64-bit nonce/IV to a 32-bit counter and 96-bit nonce/IV.
3/ That means after 256-gigabytes, the keystream wraps around and repeats. This is a big BIG HUUUGGGEEEE no-no!!! I can't believe what I'm looking at here.
4/ My grandfather was a cryptographer in WW II and tells the story of discovering the Germans were using an algorithm that eventually repeated, that they didn't know repeated, which the Allies figured out, enabling them to decrypt all the messages.
5/ RFC 7539 also defines the algorithm using 10 rounds, whereas other RFC documents say that it should be used with 8, 12, or 20 rounds.

So when SSL uses ChaCha20, which version is it actually using? I have no clue.
6/ So I look around at the code written by others. OMG I want to stab my eyes out. Cryptographers love cryptic variable names. They also love rearranging code in cryptic ways that make no sense to anybody but themselves.
7/ Oh, god, I missed it, 10 rounds means 20 rounds -- depending upon how you count. That's because when counting "20" you refer to non-identical rounds of 4 steps each, but when counting "10" it's identical rounds of 8 steps each. Because freakin cryptographers.
8/ BTW, this code isn't portable.
ChaCha uses an ASCII string for constants, because that's unlikely to be a backdoor.
But in C, such a string isn't guaranteed to be ASCII. It will be EBCDIC when compiled on IBM mainframes.
Missing some Tweet in this thread?
You can try to force a refresh.

Like this thread? Get email updates or save it to PDF!

Subscribe to Robᵇᵉᵗᵒ Graham
Profile picture

Get real-time email alerts when new unrolls are available from this author!

This content may be removed anytime!

Twitter may remove this content at anytime, convert it as a PDF, save and print for later use!

Try unrolling a thread yourself!

how to unroll video

1) Follow Thread Reader App on Twitter so you can easily mention us!

2) Go to a Twitter thread (series of Tweets by the same owner) and mention us with a keyword "unroll" @threadreaderapp unroll

You can practice here first or read more on our help page!

Follow Us on Twitter!

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just three indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3.00/month or $30.00/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!