单密钥加密和多密钥解密 [英] Encryption with single key and decryption with multiple keys

查看:283
本文介绍了单密钥加密和多密钥解密的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种使用单密钥加密的机制.但是要解密,它需要多个密钥2、3、4和5.请注意,我希望所有(2、3、4和5)密钥都需要解密.我想在python中实现它.但我无法在网上找到具体的材料.我找到答案使用多个密钥进行加密/解密根据它,我可以为此目的使用GnuPG.我读了GnuPG,但找不到答案.我发现 Shamir的秘密共享我相信它可以解决我的问题.但是我找不到它在密码学或其他流行的python包中的实现.我已经准备好执行Shamir的Secret Sharing的Wikipedia页面中给出的代码.但我有一个问题.我不确定它的实施是否安全?

I am searching for a mechanism which encrypt using single key. but for decryption it require multiple keys 2,3,4 and 5. Note that I want all (2,3,4 and 5) keys need to decrypt. I want to implement it in python. but i couldn't found concrete material online. I found answer encryption/decryption with multiple keys according to it i can use GnuPG for this purpose. I read GnuPG but i couldn't able to find answer to it. I found Shamir's Secret Sharing I believe it could solve my problem. But i couldn't found it's implementation in cryptography or other popular python package. i am ready to implement code which is given in Wikipedia page of Shamir's Secret Sharing. but i have one problem. I am not sure about it's implementation is secure ?

推荐答案

请注意,我希望所有(2、3、4和5)密钥都需要解密.
找到了Shamir的秘密分享,我相信这可以解决我的问题

Note that I want all (2,3,4 and 5) keys need to decrypt.
found Shamir's Secret Sharing I believe it could solve my problem

Shamir的秘密共享也可以解决您的问题,但是可以做更多的事情(恢复仅包含一部分密钥的解密密钥).这样做是以牺牲复杂性和性能为代价的.如果您考虑将来使用这些股票(子集)的任何选项,请问您来自凯拉拉卡(Kelalaka)的链接可能是您所能获得的最佳选择.

Shamir's Secret Sharing could as well solve your problem, but it can do more (recover the decryption key having only a subset of the keys). It's doing that in expense of complexity and performance. If you consider any future option to use the shares (subsets), imho the link from Kelalaka is maybe the best you can get for your case.

如果需要用于解密的所有密钥,则可以使用任何安全操作(XOR,哈希,无加法运算,..)简化代码以从N个随机密钥(更快,更简单)派生加密密钥.我更喜欢使用简单的XOR,因为它是一种可交换的操作,速度快且开箱即用

If you need all the keys for decryption, you can simplify your code to derive the encryption key from N random keys (faster and simpler) using any secure operation (XOR, hash, remainterless addition, ..). I'd prefer using simple XOR as it is a commutative operation, fast and supported out of box

示例:

  • 生成N个随机解密密钥
  • 对所有解密密钥进行XOR以获得加密密钥

注意.您的第一个链接(使用多个密钥进行加密/解密)是使用GPG为多个收件人(公共密钥)分别加密一个加密密钥,因此任何收件人都将能够恢复加密密钥

Note. Your first link (encryption/decryption with multiple keys) is using GPG to encrypt a single encryption key for multiple recipients (public keys) separately, so any of the recipients would be able to recover the encryption key

这篇关于单密钥加密和多密钥解密的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆