- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我相信我了解数字签名的工作原理,但我仍然不明白它如何仍然保证消息已被已知发件人 (Alice) 加密。
让我们假设 Alice 想给 Bob 发送消息。爱丽丝和鲍勃上周见过面,鲍勃正在等待回复 yes
或 no
。汤姆是中层黑客
// 1) Alice get's Bob public key
var bobPubKey = GetBobsPubKey();
// 2) Alice encrypts yes with bob's public key
var encryptedMessage = AssymetricEncryption.Encrypt("YES", bobPubKey );
// 3) Send message to bob
sendMsgToBob(encryptedMessage);
这种方法的问题是 Tom 可能截取了消息 encryptedMessage
并将该消息替换为 var newEncryptedMsg = AssymetricEncryption.Encrypt("NO!, bobPubKey );
当 bob 收到消息时,他不知道它已被 Tom 修改!
// 1) Alice get's Bob's public key
var bobPubKey = GetBobsPubKey();
// 2) Alice encrypts 'yes' with bob's public key
var encryptedMessage = AssymetricEncryption.Encrypt("YES", bobPubKey );
// 3) Alice creates a hash of the encrypted message
var hashOfEncMsg = Sha1(encryptedMessage);
// 4) Alice encryptes that hash with her priveate key
var digitalSignature = AssymetricEncryption.Encrypt(hashOfEncMsg , alicePrivKey);
// 5) Alice sends both the encryptedMsg plus the signature to Bob
var msgToSend = string.Format("someUrl.asp?encMsg={0}&digSignatrue={1}",encryptedMessage , digitalSignature );
sendBobAMsg(msgToSend ); // msg contains encryptedConted + digital Signature
这是鲍勃必须做的事情,以确保消息来自爱丽丝
// 0) Bob receives encrypted msg plus digital signatrue
var msg = RecieveMsg();
var digitalSignature = GetDigSgnatureFromMsg(msg);
var encryptedMessage = GetEncyptedMsgFromMsg(msg);
// 1) Decrypt the msg
var plainText = AssymetricEncryption.Decrypt(encryptedMessage , bobPrivateKey ); // = YES
/* now cause bob also received a digital signature let's do more steps to guaranty that the message came from Alice */
// 2) get Alice public key
var alicePubKey = GetAlicePubKey();
// 2) Create the same hash that Alice created for the msg
var ciphertext = AssymetricEncryption.Encrypt(plainText , bobPubKey ); // here plainText = YES
var hashOfEncMsg = Sha1(ciphertext);
// 3) Decrypt DigitalSignature hash with Alice public key
var aliceHash = AssymetricEncryption.Decrypt(digitalSignature , alicePublicKey);
// 4) Here alice Hash must equal hashOfEncMsg
if( hashOfEncMsg != aliceHash ) { throw new exception("Message has been modified or it does not come from Alice!");
所以我的问题是关于最后的第 4 步,其中 Alice 哈希必须等于 hashOfEncMsg。为什么如果此验证成立,Bob 可以保证消息来自 Alice?
我相信 Tom 仍然可以修改消息,方法如下:(我可能在某处错了;数字签名不可能不是他们声称的那样)。
Tom 拦截 Alice 的消息
Tom 知道该消息具有数字签名,因此他生成了一个 key 组合,其中他的公钥将与 Alice 的公钥相同。 (虽然 Tom 的私钥与 Alice 的不同)
Tom 用 Bob 的公钥加密“No”
Tom 像 Alice 一样创建数字签名,但使用他的私钥
当 bob 收到消息时,他用他的私钥解密它,他看到“否”
然后 bob 将验证签名以查看消息是否来自 alice
bob 用他的公钥加密“No”并计算哈希值。即 = hash1
bob 解密 get 的 alice 公钥,该公钥与 tom 的相同。
然后鲍勃使用该 key 解密挖掘签名。解密该挖掘签名应该等于 hash1
! .
Bob 现在认为 Alice 发送了 NO!
根据我收到的回复,这里是问题的解决方案:
Bob 可以保证消息来自 Alice,因为 Tom 无法生成与 Alice 公钥在数学上相关的私钥。换句话说,第 2 步(Tom 知道消息有数字......)将需要很多时间。因此,如果爱丽丝在合理的时间内回复,那么鲍勃可以保证消息来自爱丽丝。
最佳答案
汤姆必须加密“不!”拥有可以用爱丽丝的公钥解密的私钥,他不能使用自己的私钥。
这意味着 Tom 需要一对私钥/公钥,但他只知道公钥。从公钥计算私钥在计算上非常困难(在合理的时间内实际上是不可能的)。
关于c# - 数字签名如何保证消息已由 'Alice' 发送,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17390810/
为用户在您网站上的内容提供友好的 URL 当然是件好事。但如何最好地做到这一点呢?像 foo.com/users/alice 这样的东西有很多优点,最重要的是你不会弄乱你的根命名空间。但我认为对用户来
我正在尝试使用 AliceBundle 生成虚拟数据对于 Symfony 框架。除了我正在寻找一种方法将数组中的数据随机分配给名为 type 的属性之外,一切似乎都运行良好。 .看着faker lib
我相信我了解数字签名的工作原理,但我仍然不明白它如何仍然保证消息已被已知发件人 (Alice) 加密。 让我们假设 Alice 想给 Bob 发送消息。爱丽丝和鲍勃上周见过面,鲍勃正在等待回复 yes
为什么这里只调用了 H1 的 ServeHTTP 方法,而 H2 和 H3 似乎是被忽略了? alice似乎是一个不错的中间件链接,在这里我尝试将它与 httprouter 一起使用,但只有外部/最后
Substrate Collectables Workshop在某些时候建议开发者链为 Alice 提供预注资金的帐户。 Let's go into the Transfer app, and mak
我正在使用 alice-carousel ( https://github.com/maxmarinich/react-alice-carousel/blob/master/README.md ) 制
我的问题是关于这个 bundle :https://github.com/nelmio/alice 与 Symfony2 的结合。 我有一些固定装置想要加载到我的新网站中,这个 bundle 非常适合
我有一个 alice.ts 文件,其中实现了一个名为 Alice 的类和一个名为 IAlice 的接口(interface): export interface IAlice { readon
考虑我在 hackerrank 上发现的这个问题: Coins Problem Alice and Bob were sitting in the sun; drinking orange juice
我正在设置 NelmioAlice和 Faker通过 AlixeFixturesBundle 在 Symfony2 项目中.我需要一个 组合 装置,例如: representative{1..100}
我使用 hautelook/alice-bundle。 由于以下错误($ in 解释为对对象的引用),我无法在我的装置中使用编码的 bcrypt 密码: 在 SimpleObjectGenerator
每当我打开Alice 3并选择一个默认场景时,它就会崩溃。 操作系统:Linux Mint 19.2 终端输出: libpng warning: iCCP: known incorrect sRGB
我在序言中编写了一个程序。 parent(Amy,John). parent(Bob,John). parent(John,Ben). parent(Alice,Ben). 我在 Ubuntu 12.
我想问是否可以将数组作为某些元素的值传递?例如,在我的例子中,我正在尝试为 FOSUserBundle User 实体设置角色,该实体将 roles 作为值数组而不是普通值。我的装置中有这个: Use
我似乎不知道如何正确地一起使用中间件和 Http Router。 我的代码是: type appContext struct { db *mgo.Database } func main(){
我正在使用 justinas/alice Go 中的中间件,我想将参数传递给中间件中使用的函数。 例如: middlewareChain := alice.New(Func1(foo string,f
我有一个 MySQL 数据库转储,其中只有我想用作 Alice Fixtures 的数据。我希望将版本化的 yaml 文件提交到我的分支。有人知道解析 SQL 以从中生成 YAML 固定装置的库或包,
我在 Symfony 4 中使用 Alice 的数据装置时遇到问题。 当我运行 bin/consoledoctrine:fixtures:load 时,系统询问我是否要清除数据库,最终命令终止,没有任
使用 Netbeans 从现有的 Alice 3 项目创建可运行的 jar 后,出现以下错误: system property: org.alice.ide.rootDirectory is not
我将 Symfony2 与 Doctrine 结合使用,并使用 Alice Fixture 包来生成用于测试的装置。 在一种情况下,我需要创建一个 id 为 148 的固定装置来进行特定测试。我们所有
我是一名优秀的程序员,十分优秀!