相同的RSA密钥,相同的消息,不同的加密 [英] Same RSA keys, same message, different encrypts

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

问题描述

我生成私人/公钥,还有一个小文本文件,

I generate private/public keys, and a small text file,

openssl genrsa -out priv.pem
openssl rsa  -out pub.pem -in priv.pem -pubout
echo "A" > plain.txt

使用公钥加密文本文件两次,因此,

When you encrypt the text file with the public key twice, as so,

openssl rsautl -encrypt -pubin -inkey pub.pem -in plain.txt -out cipher.txt

你会看到两个cipher.txt不同。这是我不明白的。

you will see that the two cipher.txt differ. This is what I do not understand.

推荐答案


使用公钥加密文本文件两次,你会看到两个cipher.txt不同。这是我不明白的。

When you encrypt the text file with the public key twice ... you will see that the two cipher.txt differ. This is what I do not understand.

这被称为概率加密(与确定性加密)。它的设计方式使得相同的消息加密两次不会产生相同的密文。它由于RSA使用的掩码功能和填充功能。

This is called probabilistic encryption (versus deterministic encryption). Its that way by design so that the same message encrypted twice does not produce the same cipher text. Its due to the masking function and padding functions used by RSA.

如果加密产生相同的密文,那么你的对手可以获得信息。例如,如果你的对手看到一个他不明白的消息,但观察者你的军队第二天早上攻击他的军队,他可能会猜到这个消息是黎明时袭击。如果他再次看到相同的加密消息,他可能会在第二天黎明准备好进行攻击。

If encryption produced the same cipher text, then your adversary could gain information. For example, if your adversary sees a message he does not understand but observers your army attacks his army the next morning, he might guess that the message was "Attack at dawn". If he sees that same encrypted message again, he's probably going to be ready for an attack at dawn the next day.

加密堆栈交换机上的人可能能够如果您想要MGF,OAEP等的详细信息,请进一步帮助您。此外,Steve Bellovin博士在一个简介加密术

The folks on the crypto stack exchange might be able to help you further if you want the details of MGFs, OAEP and the like. Also, Dr. Steve Bellovin has a very approachable introduction to cryptography at An Introduction to Cryptography.

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

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