0

我正在制作一个使用公钥和私钥进行大量加密和解密的共享对象。我想将这些密钥存储在二进制文件中,有什么方法可以安全地保存这些密钥,以便没有人可以使用它。那么如何在二进制文件中嵌入加密密钥?

4

3 回答 3

1

如果代码可以访问密钥,那么运行代码的机器上的用户也可以。这是无可争议的——除非你控制硬件,否则没有办法解决。

于 2013-10-17T15:13:01.460 回答
1

有什么方法可以安全地保存这些密钥,以便没有人可以使用它。

正如millimoose所说,不,你不能。或者更准确地说:您不能将数据、任何数据保存在二进制文件中,以使其对您的二进制文件有用,而不是对其他任何人有用。虽然通常不讨论这个通用的用例,但这是数字版权管理的核心——希望拥有一些只能以受控方式使用的数据(无论是加密的还是其他的)。

您可以完成的最好的工作,即使对于资金充足和积极进取的组织来说,这也是很多工作,将使用 TPM 代表您执行加密操作,并以与系统状态相关的方式。我猜这个解决方案不是你要找的。

于 2013-10-17T15:14:29.773 回答
0

You cannot do this if you don't have control over the hardware and operating system. If you have full control, then then there is little need to add additional protection to the key. The best way of security storing keys is keeping them out of the binary. You could for instance use a secure token. This could be a TPM, a smart card or even a HSM. Those secure tokens do the cryptographic calculations on the token itself, so you never need to load it into memory.

If you want to have a very safe storage in a binary then you could take a look at this HSM. You can run your code within the HSM. Even with such a HSM, you should only generate the keys within the HSM and keep them in there. Oh, yeah, this requires you to spend several thousand dollars on an HSM...

于 2013-10-21T00:04:55.363 回答