keytool如何保护钥匙? [英] How does keytool protect keys?

查看:102
本文介绍了keytool如何保护钥匙?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Java Keytool实用程序构建密钥库时,如何保护密钥?我通读了文档,意识到每个私钥都有一个密钥密码,然后商店有一个商店密码.

但是使用什么机制来保护数据?它是加密密码吗?如果是这样,算法是什么?我特别关注keytool在构建JKS文件时如何进行保护.

解决方案

Sun的默认JKS密钥库使用专有算法,主要是为了避免对标准算法的导出限制.该算法在此类中实现,

  sun.security.provider.KeyProtector

这是算法的说明

这是Sun专有的可导出算法的实现,旨在保护(或恢复)敏感密钥的明文版本时使用.此算法无意用作通用密码.密钥保护算法的工作原理如下:p-用户密码s-随机盐X-异或密钥P-待保护密钥Y-受保护密钥R-密钥库中存储的内容步骤1:获取用户的密码,将随机盐(固定大小)添加到其中,并对其进行哈希处理:d1 =摘要(p,s)将d1存储在X中.步骤2:获取用户密码,添加上一步的摘要结果,并对其进行哈希处理: dn =摘要(p,dn-1).将dn存储在X中(将其附加到先前存储的摘要中).重复此步骤,直到X的长度与私钥P的长度匹配为止.步骤3:对X和P进行XOR,并将结果存储在Y中:Y = X XORP.步骤4:存储s,Y和digest(p ,P)在结果缓冲区R中:R = s + Y +摘要(p,P),其中"+"表示串联. (注意:digest(p,P)存储在结果缓冲区中,以便在恢复密钥时,我们可以检查恢复的密钥是否确实与原始密钥匹配.)R存储在密钥库中.恢复受保护的密钥的步骤如下:步骤1和步骤2与上述相同,除了盐不是随机生成的,而是从步骤4的结果R(第一长度字节)中提取的.步骤3(XOR操作)产生纯文本密钥.然后将密码与恢复的密钥连接起来,并与R的最后一个长度(digest(p,P))字节进行比较.如果它们匹配,则恢复的密钥的确与原始密钥相同.

When you are building a key store with the Java Keytool utility, how are the keys protected? I've read through the documentation, and I realize that each private key has a key password, and then the store has a store password.

But what mechanism is used to protect the data? Is it an encryption cipher? If so, what is the algorithm? I'm focused specifically on how keytool does the protection when it is building a JKS file.

解决方案

Sun's default JKS keystore uses a proprietary algorithm, primarily to get around exporting restrictions on standard algorithms. The algorithm is implemented in this class,

  sun.security.provider.KeyProtector

The is the description of the algorithm,

This is an implementation of a Sun proprietary, exportable algorithm intended for use when protecting (or recovering the cleartext version of) sensitive keys. This algorithm is not intended as a general purpose cipher. This is how the algorithm works for key protection: p - user password s - random salt X - xor key P - to-be-protected key Y - protected key R - what gets stored in the keystore Step 1: Take the user's password, append a random salt (of fixed size) to it, and hash it: d1 = digest(p, s) Store d1 in X. Step 2: Take the user's password, append the digest result from the previous step, and hash it: dn = digest(p, dn-1). Store dn in X (append it to the previously stored digests). Repeat this step until the length of X matches the length of the private key P. Step 3: XOR X and P, and store the result in Y: Y = X XOR P. Step 4: Store s, Y, and digest(p, P) in the result buffer R: R = s + Y + digest(p, P), where "+" denotes concatenation. (NOTE: digest(p, P) is stored in the result buffer, so that when the key is recovered, we can check if the recovered key indeed matches the original key.) R is stored in the keystore. The protected key is recovered as follows: Step1 and Step2 are the same as above, except that the salt is not randomly generated, but taken from the result R of step 4 (the first length(s) bytes). Step 3 (XOR operation) yields the plaintext key. Then concatenate the password with the recovered key, and compare with the last length(digest(p, P)) bytes of R. If they match, the recovered key is indeed the same key as the original key.

这篇关于keytool如何保护钥匙?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆