Я пытался выяснить, как работает SHA-256. Одна вещь, которую я делал для других алгоритмов, - это то, что я разработал некоторую пошаговую псевдокодную функцию для алгоритма.
Я попытался сделать то же самое для SHA256, но до сих пор у меня довольно много проблем.
Я попытался разобраться, как работает диаграмма википедии, но помимо текстовой части, объясняющей функции, я не уверен, что у меня все получилось.
Вот что я до сих пор:
Input is an array 8 items long where each item is 32 bits.
Output is an array 8 items long where each item is 32 bits.
Calculate all the function boxes and store those values.
|I'll refer to them by function name
Store input, right shifted by 32 bits, into output.
| At this point, in the out array, E is the wrong value and A is empty
Store the function boxes.
| now we need to calculate out E and out A.
| note: I've replaced the modulo commands with a bitwise AND 2^(32-1)
| I can't figure out how the modulus adding lines up, but I think it is like this
Store (Input H + Ch + ( (Wt+Kt) AND 2^31 ) ) AND 2^31 As mod1
Store (sum1 + mod1) AND 2^31 as mod2
Store (d + mod2) AND 2^31 into output E
|now output E is correct and all we need is output A
Store (MA + mod2) AND 2^31 as mod3
Store (sum0 + mod3) AND 2^31 into output A
|output now contains the correct hash of input.
|Do we return now or does this need to be run repeatedly?
Я получил все эти дополнения по модулю? Также что такое Wt и Kt? Кроме того, это будет запускаться один раз, и вы закончите или его нужно запускать определенное количество раз, при этом вывод будет повторно использоваться как вход.
Вот ссылка, кстати. http://en.wikipedia.org/wiki/SHA-2#Hash_function
Спасибо большое, Brian