有没有办法存储密码加密数据以及过期日期?
我想将一些数据存储在密码加密文件中。该文件应包含: 1) 数据的有效期 2)数据本身 过期日期不一定需要加密,但需要防止篡改(例如,可以对整个文件进行签名)。
有没有办法使用 OpenSSL 使用一些定义明确的加密格式来做到这一点? 我只对用 C 语言编程(最好使用 OpenSSL API,例如 EVP_* 和朋友)感兴趣,执行进程、脚本、Java、.NET、Python 等都是不可能的。
聚苯乙烯 我非常熟悉 OpenSSL API,但不知何故我找不到任何好的(至少相对“干净”)的解决方案来解决这个问题。
I want to store some data in a password encrypted file. The file should contain:
1) Expiration date of the data
2) The data itself
The expiration date does not necessarily need to be encrypted, but needs to be secured from tampering (eg. the whole file can be signed).
Is there a way to do it using some well defined cryptographic format using OpenSSL ?
I'm only interested in doing it programmatically in C (preferably using OpenSSL API, e.g. EVP_* and friends), executing processes, scripts, Java, .NET, Python and the like are out of the question.
P.S.
I am very familiar with OpenSSL API, but somehow I could not find any good and (at least relatively 'clean') solution for this problem.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想你回答了你自己的问题。您必须对包括到期日期在内的整个文件进行数字签名,以保护到期日期的真实性,即使对于有权访问可用于解密实际数据的密码的用户也是如此。
生成用于签署加密文件的 RSA 密钥对。解密文件的用户应有权访问 RSA 公钥和密码。
这种方案显然有一些注意事项。例如,添加数字签名不会阻止用户简单地忽略到期日期、数字签名或两者。
I think you answered your own question. You have to digitally sign the entire file including the expiration date, in order to protect the authenticity of the expiration date, even from users who have access to the password that can be used for decrypting the actual data.
Generate e.g. a RSA key pair you use for signing the encrypted file. The users who decrypt the file should be given access to both the RSA public key and the password.
There are obviously a few caveats with such a scheme. For instance, adding a digital signature will not prevent the users from simply ignoring either the expiration date, the digital signature, or both.