GPG仍然看到被撤消的子项的良好征兆仍然有效

时间:2019-02-03 19:10:49

标签: digital-signature gnupg verification sign

我已经创建了一个密钥,并创建了一个子密钥。使用子项,我签署了一个文件。验证工作。吊销了密钥,验证不成立。这是预期的行为。

但是,如果我尝试使用相同的子项签名并验证它仍然可以工作。我究竟做错了什么?这是我的全部工作:

$ gpg --gen-key
$ gpg -k
/Users/mustafa/.gnupg/pubring.kbx
---------------------------------
pub   rsa2048 2019-02-03 [SC] [expires: 2021-02-02]
      5DD923FBCF6392A5CB366167D4C0627A07510C6C
uid           [ultimate] Mustafa <mustafa91@gmail.com>
sub   rsa2048 2019-02-03 [E] [expires: 2021-02-02]

使用编辑键,添加一个子键。

$ gpg --edit-key 5DD923FBCF6392A5CB366167D4C0627A07510C6C

sec  rsa2048/D4C0627A07510C6C
     created: 2019-02-03  expires: 2021-02-02  usage: SC
     trust: ultimate      validity: ultimate
ssb  rsa2048/E058B91696C43666
     created: 2019-02-03  expires: 2021-02-02  usage: E

gpg> addkey

sec  rsa2048/D4C0627A07510C6C
     created: 2019-02-03  expires: 2021-02-02  usage: SC
     trust: ultimate      validity: ultimate
ssb  rsa2048/E058B91696C43666
     created: 2019-02-03  expires: 2021-02-02  usage: E
ssb  rsa2048/38616BDAE66E418C
     created: 2019-02-03  expires: 2019-02-13  usage: S
[ultimate] (1). Mustafa <mustafa91@gmail.com>

gpg> q
Save changes? (y/N) y

签名文件并进行验证。

$ gpg --armor --detach-sign --default-key 38616BDAE66E418C  test.txt
gpg: using "38616BDAE66E418C" as default secret key for signing

$ gpg --verify test.txt.asc test.txt
gpg: Signature made Sun Feb  3 21:49:43 2019 +03
gpg:                using RSA key 485FC77FC73DA3B800C7F41538616BDAE66E418C
gpg: Good signature from "Mustafa <mustafa91@gmail.com>" [ultimate]

使用消息“此密钥现在已掌握在敌人手中”来撤销密钥。

$ gpg --edit-key 5DD923FBCF6392A5CB366167D4C0627A07510C6C
gpg> key 2

sec  rsa2048/D4C0627A07510C6C
     created: 2019-02-03  expires: 2021-02-02  usage: SC
     trust: ultimate      validity: ultimate
ssb  rsa2048/E058B91696C43666
     created: 2019-02-03  expires: 2021-02-02  usage: E
ssb* rsa2048/38616BDAE66E418C
     created: 2019-02-03  expires: 2019-02-13  usage: S

gpg> revkey
sec  rsa2048/D4C0627A07510C6C
     created: 2019-02-03  expires: 2021-02-02  usage: SC
     trust: ultimate      validity: ultimate
ssb  rsa2048/E058B91696C43666
     created: 2019-02-03  expires: 2021-02-02  usage: E
The following key was revoked on 2019-02-03 by RSA key D4C0627A07510C6C Mustafa <mustafa91@gmail.com>
ssb  rsa2048/38616BDAE66E418C
     created: 2019-02-03  revoked: 2019-02-03  usage: S
[ultimate] (1). Mustafa <mustafa91@gmail.com>

尝试验证旧签名并查看失败。

$ gpg --verify test.txt.asc test.txt
gpg: Signature made Sun Feb  3 21:49:43 2019 +03
gpg:                using RSA key 485FC77FC73DA3B800C7F41538616BDAE66E418C
gpg: Good signature from "Mustafa <mustafa91@gmail.com>" [ultimate]
gpg: WARNING: This subkey has been revoked by its owner!
gpg: reason for revocation: Key has been compromised
gpg: revocation comment: This key is now in the hands of the enemy.

但是,尝试使用已撤销的密钥进行签名。

$ rm test.key.asc
$ gpg --armor --detach-sign --default-key 38616BDAE66E418C  test.txt
gpg: using "38616BDAE66E418C" as default secret key for signing

为什么它不会失败?如何验证?

$ gpg --verify test.txt.asc test.txt
gpg: Signature made Sun Feb  3 21:53:11 2019 +03
gpg:                using RSA key 5DD923FBCF6392A5CB366167D4C0627A07510C6C
gpg: Good signature from "Mustafa <mustafa91@gmail.com>" [ultimate]

1 个答案:

答案 0 :(得分:4)

看看最后两个摘录。尽管您已将默认签名密钥指定为38616BDAE66E418C,但在进行验证时,它仍报告已使用D4C0627A07510C6C签名。

如果您使用-v的{​​{1}}详细选项,则会看到,如果撤销了指定的默认密钥,它将退回到下一个可用的签名密钥。

为了说明这一点,我重新创建了您的方案:

gpg

在撤消之前使用子项签名:

sec  rsa2048/4E5CB15076F1318E
     created: 2019-02-09  expires: 2021-02-08  usage: SC
     trust: ultimate      validity: ultimate
ssb  rsa2048/3303CBB274AECA3B
     created: 2019-02-09  expires: 2021-02-08  usage: E
The following key was revoked on 2019-02-09 by RSA key 4E5CB15076F1318E Herp Derp <herp@derp.com>
ssb  rsa2048/8ABD3900E64E7972
     created: 2019-02-09  revoked: 2019-02-09  usage: S
[ultimate] (1). Herp Derp <herp@derp.com>

撤消后使用子项签名:

$ gpg -v --armor --detach-sign --default-key 8ABD3900E64E7972 test.txt
gpg: using pgp trust model
gpg: using "8ABD3900E64E7972" as default secret key for signing
gpg: using subkey 8ABD3900E64E7972 instead of primary key 4E5CB15076F1318E
gpg: writing to 'test.txt.asc'
gpg: RSA/SHA256 signature from: "8ABD3900E64E7972 Herp Derp <herp@derp.com>"

您可以看到在第二个示例中,gpg将子键标识为已撤消,并退回到主键。