执行 PKSIGN 步骤后,macOS 11.5.2 上的 GPG 加密速度很慢

执行 PKSIGN 步骤后,macOS 11.5.2 上的 GPG 加密速度很慢

由于某种原因,GPG 在加密任何内容时似乎需要很长时间(2-3 秒)。这使得它特别难以与 git 一起使用,因为提交速度很慢,而重新定基的速度也很慢。

$ time (date | gpg -bsau KEY_ID)
...
0.01s user 0.02s system 0% cpu 2.801 total

我在 macOS 11.5.2 上使用 GPGSuite:

$ git --version
git version 2.33.0
$ gpg --version | head -n1
gpg (GnuPG/MacGPG2) 2.2.27

我已禁用从密钥服务器检索密钥的功能,此支持主题

在此处输入图片描述

我的钥匙圈中没有很多钥匙:

$ gpg --list-keys | grep -E '^(pub|sub)' | wc -l
      21

并且减速似乎出现在PKSIGN步骤之后和byte(s) skipped步骤之前:

$ date | gpg --debug-level 9 -bsau KEY_ID
...
gpg: DBG: iobuf-2.1: underflow: buffer size: 8192; still buffered: 0 => space for 8192 bytes
gpg: DBG: iobuf-2.1: underflow: A->FILTER (8192 bytes)
gpg: DBG: iobuf-2.0: underflow: buffer size: 8192; still buffered: 0 => space for 8192 bytes
gpg: DBG: iobuf-2.0: underflow: eof (pending eof)
gpg: DBG: iobuf-2.1: A->FILTER() returned rc=-1 (EOF), read 0 bytes
gpg: DBG: iobuf-2.1: pop in underflow (nothing buffered, got EOF)
gpg: DBG: iobuf chain: 2.0 '?' filter_eof=0 start=0 len=0
gpg: DBG: get_keygrip for public key
gpg: DBG: keygrip= XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX
gpg: DBG: chan_4 -> RESET
gpg: DBG: chan_4 <- OK
gpg: DBG: chan_4 -> SIGKEY XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
gpg: DBG: chan_4 <- OK
gpg: DBG: chan_4 -> SETKEYDESC Please+enter+the+passphrase+to+unlock+the+OpenPGP+secret+key:...
gpg: DBG: chan_4 <- OK
gpg: DBG: chan_4 -> SETHASH 8 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
gpg: DBG: chan_4 <- OK
gpg: DBG: chan_4 -> PKSIGN

[--------> DELAY IS HERE <-----------]

gpg: DBG: chan_4 <- [ XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX ...(273 byte(s) skipped) ]
gpg: DBG: chan_4 <- OK
gpg: DBG: build_packet() type=2
gpg: DBG: iobuf-4.0: close '?'
gpg: DBG: free_packet() type=2
gpg: DBG: armor-filter: control: 4
gpg: DBG: armor-filter: control: 5
gpg: DBG: iobuf-3.1: close 'armor_filter'
gpg: DBG: armor-filter: control: 2

我的钥匙除了有一张图片外,没有什么特别的:

pub   rsa2048 2015-08-18 [SC]
      KEY_ID
uid           [ultimate] a paid nerd <[email protected]>
uid           [ultimate] [jpeg image of size 10830]
uid           [ultimate] keybase.io/apaidnerd <[email protected]>
uid           [ultimate] a paid nerd <[email protected]>
sub   rsa2048 2015-08-18 [E]

答案1

虽然不是确切的原因,但是有一个解决方案:删除我的.gnupg目录解决了这个问题。

我怀疑我的.gnupg目录已经有 15 年的历史了,其中可能有一些旧密钥或遗留数据。所以我导出了我关心的密钥,将目录移开,重新导入了所有内容,现在一切都很快了。

相关内容