cryptography - SHA 256伪代码?

标签 cryptography pseudocode sha sha256

我一直在尝试弄清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

非常感谢,
布赖恩

最佳答案

看一下描述算法的官方标准,这里描述变量:http://csrc.nist.gov/publications/fips/fips180-4/fips-180-4.pdf

(哦,现在我知道我的答案快迟到了一年,啊,没关系...)

关于cryptography - SHA 256伪代码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11937192/

相关文章:

java - 双曲曲面分割 Java 库

java - 找不到任何支持 RSA/None/OAEPWITHSHA-256ANDMGF1PADDING 的提供程序

rsa - PKCS11Interop Hash with SHA256 和 Sign with RSA 分两步

javascript - Objective-C 中的渐进式 HMAC SHA256

c++ - openssl RAND_add() 文档引用 RFC1750。 RFC1750 对此事保持沉默

python - 解密 SSL 预主 key

java - java中的SHA2密码散列

delphi - 使用 LockBox 读取 PEM 格式的私钥

java - 查找整数的最小 "factorization"到平方数

在 C 中使用 Luhn 算法进行信用卡验证