假设鲍勃从爱丽丝那里收到一条用他的公钥加密并用她的私钥签名的消息。现在他想向查理证明他收到了她发来的消息,内容与此完全相同。该消息是通过创建的gpg --sign --encrypt
。
我的想法是他可以解密该消息并将其及其签名保存在某处,但我找不到实现此目的的方法。但由于 GPG 对消息进行签名,然后对其进行加密,因此这至少在理论上是可能的。
现在他该如何做到这一点,或者您是否有任何其他想法,鲍勃如何向查理证明消息的真实性?
限制:
- 向查理·鲍勃提供私钥(显然)不是一个选择。
- 只能通过电子邮件进行沟通。
- 无法再联系到 Alice,因此重新发送消息或 Charlie 和 Alice 无法相互通信。鲍勃必须利用他已有的东西。
答案1
这是很难找到的。它不在本地man gpg
。
命令:
gpg -vi --unwrap msg1.gpg
(-v
意味着详细,-i
是交互式的,不会覆盖文件。)
警告:有时您可能(?)需要解压缩输出。
文档: https://gnupg.org/documentation/manuals/gnupg.pdf
--unwrap This command is similar to ‘--decrypt’ with the difference that the output
is not the usual plaintext but the original message with the encryption layer
removed. Thus the output will be an OpenPGP data structure which often
means a signed OpenPGP message. Note that this option may or may not
remove a compression layer which is often found beneath the encryption layer.
测试(在 Ubuntu 上,2023 年 8 月更新)。
### Alice(=testS) signed a message and encrypted it
### using Bobs(=test) public key. -r means --recipient
[0] $ echo A message to be signed a sent > message
[0] $ gpg -u testS -r test --sign --encrypt message
## Alice sent message.gpg to Bob
[0] $ gpg -vi --unwrap message.gpg # --output ...
gpg: WARNING: no command supplied. Trying to guess what you mean ...
gpg: public key is 3DF37C69945F312D
gpg: using subkey 3DF37C69945F312D instead of primary key 96B43A891E43F2F4
gpg: using subkey 3DF37C69945F312D instead of primary key 96B43A891E43F2F4
gpg: encrypted with 3072-bit RSA key, ID 3DF37C69945F312D, created 2023-08-29
"TEST TE <[email protected]>"
gpg: AES256 encrypted data
File 'message' exists. Overwrite? (y/N) n
Enter new filename: message-only-singed.gpg
## Bob sends "unwrapped" (=deciphered) file message-only-signed.php
## to Charlie
[0] $ gpg -d message-only-singed.gpg
A message to be signed a sent <---- The message
gpg: Signature made Tue 29 Aug 2023 22:55:11 CEST
gpg: using RSA key 6646102A06EC96A49AE8828FCDF0F02D337492DD
gpg: issuer "[email protected]"
gpg: Good signature from "tests <[email protected]>" [ultimate] <---- the sig
### Charlie sees that Alice=testS signed the message
(最后一个命令可以与 一起使用--output file
。)