AES 密钥生成

发布于 2025-01-13 00:23:24 字数 86 浏览 3 评论 0原文

AES 始终创建唯一的密钥。即使我的互联网已断开。我知道再次创建已生成的相同密钥的可能性很小,但我的问题是算法在哪里存储所有这些密钥,以便确保该密钥已被使用。

AES always create a unique key. Even I have my internet disconnected. I know there is very little probability to create same key again that is already generated but my question is that where the algorithm is storing all those keys so that it is making sure that the key is already being used.

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

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

发布评论

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

评论(1

幸福丶如此 2025-01-20 00:23:24

没有算法。如果您想存储密钥以供检查,您可以随意这样做。

请记住,“非常小的概率”实际上是“令人难以置信的、令人难以置信的小概率”。对于随机选择的 256 位密钥,在选择超过 1035 个密钥后,发生单次冲突的可能性为百万分之一。 (也就是说,如果您选择 1035 个键一百万次,您会期望这些集合中的一个有一个重复项。)

要获得 10 35 个密钥,您需要为每人创建大约 10,000,000,000,000,000,000,000,000 个密钥世界。一旦你这样做了,两把钥匙发生冲突的可能性就是百万分之一。

有关如何计算这些值的更多详细信息,请参阅生日攻击

如果您的随机数生成器配置正确,您将永远不会在随机选择的 AES-256 密钥上发生冲突。如果您要创建大量密钥(例如数百亿个),我会考虑验证如何生成随机数以验证其设置是否正确。但对于较小的集合,如果您在普通计算机和操作系统上使用普通的加密随机数生成器,那么这不太可能成为问题。在非常大的尺度上,与随机数碰撞相比,由于硬件错误和宇宙射线(是的,严重的)翻转位而出现问题的可能性要大得多。

但如果您想检查重复项,您可以按照您喜欢的任何方式进行跟踪。没有特定的算法。将它们放入数据库并查找。

There is no algorithm. If you want to store keys to check, you are free to do so.

Keep in mind that "very little probability" is really "incredibly, mind-bogglingly little probability." For a 256-bit key chosen at random, there is a 1 in a million chance that a single collision will occur after selecting over 1035 keys. (That is to say, if you selected 1035 keys a million times, you would expect one of those collections to have a single duplicate.)

To get 1035 keys, you would need to create about 10,000,000,000,000,000,000,000,000 keys per person in the world. Once you had done that, you'd have a one-in-a-million chance that two keys would collide.

For more details on how you calculate these values, see the Birthday Attack.

If your random number generator is configured properly, you will never, ever, have a collision on a randomly selected AES-256 key. If you are creating a very large number of keys, say in the tens of billions, I would consider validating how you generate random numbers to verify that it's set up correctly. But for smaller sets, it's incredibly unlikely that's going to be an issue if you're using the normal cryptographic random number generators on common computers and OSes. At very large scales, you're dramatically more likely to have problems due to hardware errors and cosmic rays (yes, seriously) flipping bits than due to random number collisions.

But if you want to check for duplicates, you can keep track any way you like. There is no particular algorithm. Put them in a database and look them up.

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