如何保护加密密钥免遭逆向工程?

发布于 2024-11-16 16:43:23 字数 278 浏览 2 评论 0原文

我的软件使用 AES Rijndael。

我使用 SHA-256 哈希从任意长度的字符串生成密钥,然后将其作为私钥和公钥传递,因为在本例中我不需要区分两者。

如何保护我的密钥不被从可执行文件中窃取?

我知道不要使用文字,而是在运行时通过一些预先确定的步骤生成密钥,但无论如何,密钥在发送到 AES 初始化函数之前仍会位于内存中,因此可以很容易地检索到。

AES 显然非常安全,但如果有人破坏了可执行文件,这对我有什么好处呢?

解决这个问题时有一些常见的做法吗?

My software is using AES Rijndael.

I am using a SHA-256 hash to generate a key from a string with an arbitrary length, and then passing this as both the private and public key since in this instance I do not need to differentiate between the two.

How do I protect my key from being hacked out of the executable?

I know not to use a literal but instead generate the key at runtime with some predetermined steps, but all the same the key will still be in memory right before its sent on to the AES initialization function and so can quite easily be retrieved then.

AES is obviously very secure, but what good does that do me if someone breaks the executable instead?

Is there some common practise when solving this problem?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

一指流沙 2024-11-23 16:43:24

这是不可能的。这是 PC 上 DRM 方案的基本问题:它们需要将密钥保存在内存中,以便可以提取密钥。您也许可以在不使用它时将其遮盖起来,但仅此而已。如果您的应用程序很流行并且是分布式的,那么就会有人破解您的美味方案。这就是为什么一些公司将加密狗或 TPM 芯片用于高价值应用的原因。

This can't be done. This is the basic problem with e.g. DRM scheme's on PC's: they need to have the key in memory, so it can be extracted. You can maybe obscure it while it is not in use, but that's about it. And if your application is popular and distributed, then somebody will crack you delicious scheme. That's why some companies use dongles or TPM chips for high value applications.

笙痞 2024-11-23 16:43:24

有一种东西——在数学理论中非常复杂——被称为“白盒密码学”。在这种情况下,AES 算法在某种程度上进行了修改,以便在加密过程中建立秘密。我确切地知道这是如何实现的,但是这个不需要有初始化的秘密,但秘密是算法的一部分。
攻击者可能会发现您的 AES 实现有点“不同”,但在执行过程中密钥在内存中始终不可见。攻击者唯一的机会是复制整个白盒代码,但很难对其进行逆向工程 - 他只能使用它。无论如何,根据您使用 AES 的方式,这可能足以闯入。

There is something - very complex in mathematical theory - called "whitebox cryptography". In this case, the AES algorithm is modified in a way, that it builds up the secret during encryption. I do not know exactly, how this is achieved, but this one does not need to have a initialized secret, but the secret is part of the algorithm.
An attacker might see, that your AES implementation is a bit "different" but at no time in execution the key is visible in memory. The only chance an attacker will have, is to copy the whole whitebox code but it is really hard to reverse engineer this - he would just be able to use it. Anyway depending on the way you use the AES, this might be enough to break in.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文