Now I had SeverHello which contains a cipher suite to be used in key exchange, I can start serious algorithms instead of tedious data parsing. I sent different cipher suites with ClientHello to different servers and found only a several types of them are used such as
I first took a look at the famous RSA algorithm. Hmmm, it involves lots of big integer operations. I don’t know which big int library is best for my C++ project. In Google’s foobar challenges, I used the standard BigInteger class in java. It was easy and had no problem. I don’t know why no big int library in C++ std or boost.
Anyway I wanted to start with a simpler algorithm to implement. SHA seems a good one and is used everywhere. By just implementing the pseudo code in Wikipedia, I could run it successfully although I spent a whole hour figuring out the bug when the input data size is bigger than zero. The length data to be appended at the end of the buffer is in bits, not in bytes!
The algorithm itself is pretty straightforward. It only involves with mixing data by rotating, shifting, XOR-ing and adding 32-bit values. Implementing this for FPGA or ASIC should be easy, too. SHA family algorithms are widely used for cryptocurrencies. Faster execution means more money. I wonder how much power is used on global scale just for executing this algorithm. I guess SHA is the algorithm which occupies the most execution time in globally, or historically.