小编Ser*_*gei的帖子

i2p会话密钥生成怀疑泄漏

我最近在I2P源代码(Java)中发现了以下片段:

private final SessionKey calculateSessionKey(BigInteger myPrivateValue, BigInteger publicPeerValue) {
    SessionKey key = new SessionKey();
    BigInteger exchangedKey = publicPeerValue.modPow(myPrivateValue, CryptoConstants.elgp);
    byte buf[] = exchangedKey.toByteArray();
    byte val[] = new byte[32];
    if (buf.length < val.length) {
        System.arraycopy(buf, 0, val, 0, buf.length);
                    ... //irrelevant details
    } else { // (buf.length >= val.length)
        System.arraycopy(buf, 0, val, 0, val.length);
                   ... //irrelevant details
    }
    key.setData(val);
    return key;
}
Run Code Online (Sandbox Code Playgroud)

据我所知,前256位buf[]被直接复制到会话密钥,并且没有运行SHA256摘要.我不是加密专家(也不是java),任何人都可以解释我,这不是安全漏洞吗?我的意思是,在标准的Diffie-Hellman维基页面中,SHA哈希也在密钥上运行.如果确实如此,您是否也可以举例说明如何利用它?

security cryptography sha256

4
推荐指数
1
解决办法
278
查看次数

标签 统计

cryptography ×1

security ×1

sha256 ×1