如何安全存储加密密码
我正在开发 Java RCP 应用程序。用户需要使用智能卡验证自己的身份才能访问该应用程序。在其中,他可以打开/保存需要加密存储的文件。
目前,我使用基于密码的 AES 加密和硬编码密码。 这显然不安全,所以我需要一种不同的方法来加密/解密文件。
引起这个问题的原因是需要满足一些要求:
- 没有保证的网络连接(必须在离线模式下可用)
- 多个用户必须有权访问文件(因此没有公钥/私钥加密)
- 不应该有一个用于所有文件的“master”密钥
编辑: 我不需要非常高的安全级别。对于攻击者来说,获取密钥应该比打开分布式 JAR 文件并以纯文本形式获取密钥要困难一些。
任何提示将不胜感激。
I am working on a Java RCP application. A user needs to authenticate himself with his SmartCard to get access to the application. Inside this, he can open/save files which need to be stored encrypted.
Currently, I'm using a password-based AES encryption with a hard-coded password.
This is obviously not secure, so I need a different approach to encrypt/decrypt files.
What arouses this problem is that there are a few requirements to be met:
- no guaranteed network connection (must be usable in offline-mode)
- multiple users must have access to the files (so no public/private key encryption)
- there should not be one "master"-key used for all files
Edit:
I doesn't need to have a very high level of security. It should just be a little bit harder for an attacker to get the key as to just open the distributed JAR file and get the key in plain text.
Any hints would be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
为每个文件创建一个新密钥。使用该密钥加密文件(使用 AES)。
然后,对于每个被允许读取该文件的用户,使用其公钥(对应于其智能卡上的私钥)加密新密钥。将这些加密密钥与文件一起存储。
当用户想要读取文件时,软件使用他的智能卡来恢复用于该文件的内容加密密钥。
文件格式可以使用 PKCS #7 的加密消息语法或 OpenPGP。
For each file, create a new key. Encrypt the file with that key (using AES).
Then, for each user that is allowed to read the file, encrypt the new key with their public key (one that corresponds to a private key on their smart card). Store these encrypted keys with the file.
When a user wants to read a file, the software uses his smart card to recover the content encryption key used for the file.
The file format could use PKCS #7's Cryptographic Message Syntax or OpenPGP.
警告:我不太熟悉安全性,这只是我的想法。
建议将每个文件的密码设置为包含为每个文件随机生成的已知盐的哈希值,以及为每个用户单独加密的单个密码短语。您可以在本地安全地存储随机盐,因为它们不是文件的密钥,并且没有用户知道解锁文件的密码。通过使用公钥加密对密码进行加密和签名,您可以对用户进行身份验证并控制每个用户、每个文件的访问。
这样,您可以使用每个用户的公钥加密来传递密码,该密码不会存储在系统中的任何位置,彼此独立地保护文件,并且不依赖于外部来源。
Caveat: I am not well-versed in security and this is just something that crossed my mind.
As a suggestion, make the password for each file be a hash containing a known salt that is randomly generated for each file, and a single passphrase that is encrypted individually for each user. You can safely store the random salts locally, because these are not the key to the file, and no user knows the passphrase to unlock the file. By encrypting and signing the passphrase with public key encryption, you can authenticate users and control access on a per-user, per-file basis.
This way, you could use public key encryption from each user to deliver the passphrase, which is not stored anywhere in the system, secure the files independently of each other of each other, and not be dependent on outside sources.