Псевдокод SHA 256?

Я пытался понять, как работает 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

Большое спасибо, Брайан

17
задан codelion 13 August 2012 в 18:41
поделиться