gpt4 book ai didi

java - JCEKS PBE 用于加密私钥的算法是什么?

转载 作者:行者123 更新时间:2023-12-01 10:21:09 32 4
gpt4 key购买 nike

我想解密 Java JCEKS keystore 中的私钥,但我不想使用 Java。

我可以找到 PBEWithMD5AndTripleDES 的描述,但找不到实际的实现。

此评论据称解释了推导过程:

/**
* This class implements a proprietary password-based encryption algorithm.
* It is based on password-based encryption as defined by the PKCS #5
* standard, except that is uses triple DES instead of DES.
*
* Here's how this algorithm works:
*
* 1. Create random salt and split it in two halves. If the two halves are
* identical, invert one of them.
* 2. Concatenate password with each of the halves.
* 3. Digest each concatenation with c iterations, where c is the
* iterationCount. Concatenate the output from each digest round with the
* password, and use the result as the input to the next digest operation.
* The digest algorithm is MD5.
* 4. After c iterations, use the 2 resulting digests as follows:
* The 16 bytes of the first digest and the 1st 8 bytes of the 2nd digest
* form the triple DES key, and the last 8 bytes of the 2nd digest form the
* IV.
*
* @author Jan Luehe
* @see javax.crypto.Cipher
*/

但是,第一个串联是密码 + half-of-salt,还是half-of-salt + 密码?后面几轮的输入是密码+摘要,还是摘要+密码

在 8 位字符或完整的 16 位字符以及可能的串联组合之间,您可能会认为通过反复试验我现在应该已经解决了。

我知道迭代密码,甚至是密文应该解密的明文(即我有解密的数据)。

派生 24 字节 DES3 key (无论是修复奇偶校验还是不管它)和 8 字节 IV,在 DES3 CBC 模式下解密,我都无法重新创建我的明文。

此评论描述的算法是什么?

最佳答案

感谢回复评论的 erikson 1 on this answer另一个问题,以及 Ebbe M. Pedersen。最后,我应该在尝试不同的组合时被答案绊倒,但不知何故错过了。

对于感兴趣的人,一旦您打开 JKS 并找到条目,加密的 PKCS#8 将显示 JCEKS 算法 1.3.6.1.4.1.42.2.19.1 以及盐和迭代计数参数以及这些参数和您的 8-位/字符密码,您可以解密密文以找到保存您私钥的内部未加密 PKCS#8。

def jce_pbkdf1(password, salt, iterations)
salts = [copy = salt.dup, copy.slice!((copy.length / 2)..-1)]
octets = salts.map { |half| (iterations).times.inject(half) { |digest| OpenSSL::Digest.digest('md5', digest + password) } }.join
return octets[0..23], octets[24..-1] // key (parity not set) and IV
end

关于java - JCEKS PBE 用于加密私钥的算法是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35610017/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com