# GNU 隐私卫士

**GNU 隐私卫士**（GnuPG，或称 GPG）是 OpenPGP 标准的一个自由软件实现，用于加密和[数字签名](https://www.edgepedia.org/zh/digital-signature)，提供公钥加密与对称加密、签名、密钥管理，并支持 S/MIME 和 SSH 协议。自 1997 年问世以来，它一直是以 GNU 通用公共许可证发布的自由软件，主要是一个命令行工具，设计上用于与其他应用集成，其之上构建了一系列前端和库。<sup>[1](https://www.gnupg.org/index.en.html)</sup>

| 关键事实 | 详情 |
|---|---|
| 它是什么 | OpenPGP 的自由实现，外加 S/MIME 和 SSH 支持；自 1997 年起以 GPL 授权<sup>[1](https://www.gnupg.org/index.en.html)</sup> |
| 标准沿革 | RFC 1991（PGP 消息交换格式）→ RFC 2440 → RFC 4880 → RFC 9580（2024 年 7 月）<sup>[2](https://www.rfc-editor.org/rfc/rfc9580.html)</sup> |
| 密钥结构 | 一个主密钥对加上零个或多个从属密钥对，捆绑在一起进行密钥管理；子密钥通常用于签名和加密<sup>[3](https://gnupg.org/gph/en/manual.html)</sup><sup> • </sup><sup>[4](https://dl.acm.org/doi/10.1145/2905760.2905761)</sup> |
| 信任模型 | 以用户为中心的信任网（一个完全可信或三个部分可信的签名者，路径不超过五步）；PGP 是 GnuPG 中的默认信任模型，TOFU+PGP 可作为替代方案<sup>[3](https://gnupg.org/gph/en/manual.html)</sup><sup> • </sup><sup>[5](https://docs.kernel.org/process/maintainer-pgp-guide.html)</sup><sup> • </sup><sup>[27](https://gnupg.org/documentation/manuals/gnupg/GPG-Configuration-Options.html)</sup> |
| 治理 | 自 2001 年起由 g10 Code GmbH 维护，主要靠捐款资助<sup>[6](https://lists.gnupg.org/pipermail/gnupg-announce/2026q3/000516.html)</sup> |
| 近期分裂 | LibrePGP 分支于 2023 年 11 月 29 日宣布；RFC 9580 于 2024 年 7 月发布，版本号从 5 递增到 6<sup>[7](https://lwn.net/Articles/953797/)</sup><sup> • </sup><sup>[8](https://www.openpgp.org/about/gnupg/)</sup> |

## GnuPG 是什么

三个名称常被互换使用，但所指不同。**PGP** 起源于 1991 年，最初是商业产品，其权利此后几经易主；如今这个名称属于那条商业血脉。**OpenPGP** 是定义消息格式和算法的开放标准，使不同程序能够互操作，最初标准化为 RFC 1991，然后是 RFC 2440（1998 年），再是 RFC 4880，现在是 RFC 9580。<sup>[9](https://secure-os.org/articles/gpg-vs-pgp/)</sup><sup> • </sup><sup>[2](https://www.rfc-editor.org/rfc/rfc9580.html)</sup> **GnuPG** 是该标准的一个独立的自由实现。由于 GnuPG 在功能上（尽管不总是在线缆比特层面）与 PGP 2.x 在大多数情况下相同，协议分析常将 OpenPGP 格式等同于 PGP。<sup>[10](https://www.cs.auckland.ac.nz/%7Epgut001/pubs/app_sec.pdf)</sup>

GnuPG 支持 OpenPGP 和 S/MIME，并包含 Gpg-Agent。<sup>[6](https://lists.gnupg.org/pipermail/gnupg-announce/2026q3/000516.html)</sup> 2.4.0 版（2022 年 12 月）是稳定版本，2.2 作为长期支持分支至少维护到 2024 年底，1.4 仅保留用于解密因安全原因被新版本拒绝的非常老旧的数据。<sup>[11](https://lists.gnupg.org/pipermail/gnupg-announce/2022q4/000477.html)</sup>

## 工作原理

OpenPGP 结合了对称加密和公钥加密。每个对象用一个全新的、一次性使用的对称会话密钥加密，然后该会话密钥再用接收者的公钥加密。<sup>[2](https://www.rfc-editor.org/rfc/rfc9580.html)</sup>

GnuPG 密钥不是单个密钥，而是一个捆绑包：一个主密钥对加上零个或多个从属密钥对。公开部分包含主签名密钥、子密钥和用户 ID；私钥环只保存私有部分。<sup>[3](https://gnupg.org/gph/en/manual.html)</sup> 主密钥作为稳定的标识符，而子密钥通常寿命较短、角色专门化，常用于签名和加密；将身份绑定到主密钥使密钥轮换变得简单直接。<sup>[4](https://dl.acm.org/doi/10.1145/2905760.2905761)</sup>《GNU 隐私手册》描述了预期的做法：主密钥寿命长，部分原因是为了不丢失在其上收集的签名，而加密子密钥可以定期更换以增加安全性，因为加密密钥一旦被破解，只危及该子密钥处理过的过往会话流量。<sup>[3](https://gnupg.org/gph/en/manual.html)</sup>

## 信任网

OpenPGP 是仅有的两个具有完整公钥基础设施的广泛使用的密码学标准之一；另一个是 X.509，用于 HTTPS 和 S/MIME。<sup>[12](https://blog.pgpkeys.eu/state-keyservers-2024.html)</sup> 这两个 PKI 的根本区别在于谁为谁担保。

OpenPGP 信任网是一个以用户为中心、自组织的 PKI，其中任何实体都可以证明某个用户 ID（姓名和电子邮件地址）绑定到一个密钥对。验证的工作方式是寻找从用户自己的密钥到目标密钥的认证路径，而不是从根证书颁发机构向下沿链条查找，它使用两个本地存储的信任概念：一个密钥作为其他密钥引入者的可信度，以及一个公钥本身的可靠度。<sup>[13](https://ralphholz.science/publications/InvestigatingTheOpenpgpWebpgpWebOfTrust.pdf)</sup> 在 GnuPG 的具体规则中，一个密钥如果被足够多的有效密钥签名（一个完全可信的密钥，或三个部分可信的密钥），并且签名密钥回到用户自己密钥的路径不超过五步，则该密钥有效；默认值可以调整。<sup>[3](https://gnupg.org/gph/en/manual.html)</sup> 一个密钥作为其他密钥的认证者，可以被标记为完全可信、部分可信或不可信，用户自己的密钥始终是完全可信的。<sup>[14](https://www.cs.umd.edu/class/fall2018/cmsc818O/papers/why-johnny-cant-encrypt.pdf)</sup> 密钥签名有两个目的：检测密钥环上的篡改，以及证明一个密钥确实属于某个用户 ID 所指名的人。<sup>[3](https://gnupg.org/gph/en/manual.html)</sup> 会议上的密钥签名会是创建这些认证的主要机制。<sup>[13](https://ralphholz.science/publications/InvestigatingTheOpenpgpWebpgpWebOfTrust.pdf)</sup>

**可用性批评。** 1999 年那项经典的《为什么约翰尼不能加密》研究发现，PGP 5.0 给普通用户带来了危险，例如 RSA 密钥接收者无法解密为混合密钥类型加密的文件，而且用户无法可靠地执行密钥管理任务。<sup>[14](https://www.cs.umd.edu/class/fall2018/cmsc818O/papers/why-johnny-cant-encrypt.pdf)</sup> 后来一项同行评审的分析认为，首次使用信任（TOFU）策略——检查签名者是否沿用过往消息中使用的同一密钥——对大多数用户来说比信任网具有更强的实际安全性，因为信任网需要太多用户支持；TOFU 在存在先前已验证消息时能检测伪造或中间人攻击，但无法抵御持续的中间人攻击。<sup>[4](https://dl.acm.org/doi/10.1145/2905760.2905761)</sup> 这一批评已被软件吸收：[Linux 内核](https://www.edgepedia.org/zh/linux-kernel)项目推荐组合的 TOFU+PGP 信任模型，它是 GnuPG v2 中默认 PGP 信任模型的替代方案，后者在创建新信任数据库时是默认值，通过 `~/.gnupg/gpg.conf` 中的 `trust-model` 设置来设定。<sup>[5](https://docs.kernel.org/process/maintainer-pgp-guide.html)</sup><sup> • </sup><sup>[27](https://gnupg.org/documentation/manuals/gnupg/GPG-Configuration-Options.html)</sup>

## 实践中的密钥管理

密钥对创建后，手册的第一条指示是立即为主公钥生成一份撤销证书，以便在密钥丢失或泄露时可以宣布其无效。<sup>[3](https://gnupg.org/gph/en/manual.html)</sup> Ubuntu 的贡献者指南更进一步，建议将主密钥保持离线，或仅在离线会话中使用，并且仅用于创建或轮换子密钥。<sup>[15](https://documentation.ubuntu.com/project/contributors/setup/set-up-and-manage-pgp-keys/)</sup>

密钥发现通过密钥服务器和 Web 密钥目录（WKD）进行。截至 2024 年，keys.openpgp.org 是 OpenPGP 软件附带的最常见的默认密钥服务器，尽管 Mailvelope 和 Proton 等一些供应商运营着自己的默认密钥服务器。<sup>[12](https://blog.pgpkeys.eu/state-keyservers-2024.html)</sup> keys.openpgp.org 支持电子邮件验证但不支持第三方签名，许多客户端现在默认将来自此类服务器的密钥视为可信，实际上将运营者视为权威。<sup>[12](https://blog.pgpkeys.eu/state-keyservers-2024.html)</sup> 它成为 GPGTools、Enigmail、OpenKeychain、GPGSync、Debian 和 [NixOS](https://www.edgepedia.org/zh/nixos) 中的默认密钥服务器。<sup>[16](https://keys.openpgp.org/about/news/three-months-later/)</sup>

硬件令牌通过 GnuPG 的智能卡支持集成。作为智能卡使用的 [YubiKey](https://www.edgepedia.org/zh/yubikey) 存储 PGP 认证、签名和加密密钥，使用存储的私钥的操作在 YubiKey 上进行，而不是在计算机上；密钥结构要求一个永不改变的主密钥加上可更换的子密钥，每个主密钥可以有多个子密钥。<sup>[17](https://developers.yubico.com/PGP/PGP_Walk-Through.html)</sup>

## 数据一览

- MIT SKS 密钥服务器截至 2024 年 6 月 19 日报告共有 6,941,277 个密钥。<sup>[18](https://pgp.mit.edu/pks/lookup?op=stats)</sup>
- 2014 年 1 月对 SKS 密钥服务器池的一次转储发现，94.74% 的密钥是版本 4（RFC 4880）密钥，其中 DSA 主密钥占 74.4%，RSA 占 25.6%；密钥长度从 224 位到 32,768 位不等，椭圆曲线密钥只占极小部分。<sup>[19](https://lists.gnutls.org/pipermail/gnupg-users/2014-January/048931.html)</sup>
- EFAIL 研究在 35 个受测 S/MIME 电子邮件客户端中的 23 个、以及 28 个受测 OpenPGP 电子邮件客户端中的 10 个中发现了泄露通道。<sup>[20](https://www.usenix.org/system/files/conference/usenixsecurity18/sec18-poddebniak.pdf)</sup>
- 上线约三个月后，keys.openpgp.org 报告流量约为每秒十次请求，一个月内发送了大约 100,000 封验证邮件。<sup>[16](https://keys.openpgp.org/about/news/three-months-later/)</sup>

## 安全历史与漏洞

**EFAIL（2018 年）。** EFAIL 攻击利用 CBC 和 CFB 加密模式中的可延展性，将恶意明文片段注入加密电子邮件；这些片段滥用现有的、符合标准的回传通道（如 HTML 渲染和图像加载）来泄露完整的解密明文，而且即使对很久以前收集的电子邮件也有效。作者建议更新 OpenPGP 和 S/MIME 标准本身来修复这些漏洞。<sup>[20](https://www.usenix.org/system/files/conference/usenixsecurity18/sec18-poddebniak.pdf)</sup>

**签名伪造（2019 年）。** 一项后续的 USENIX 研究展示了五类实用的签名伪造攻击，在 20 个受测的支持 OpenPGP 的电子邮件客户端中的 14 个、以及 22 个支持 S/MIME 的客户端中的 15 个中伪造了任意消息的签名，且未攻击底层密码学原语；作者指出这引发了对 OpenPGP 和 S/MIME 电子邮件应用实际安全性的担忧。<sup>[21](https://www.usenix.org/conference/usenixsecurity19/presentation/muller)</sup>

**ElGamal 侧信道。** 使用符合标准的 2048 位 ElGamal 密钥解密密文时，与解密者共处同一操作系统或虚拟机的攻击者可能通过侧信道攻击完全恢复解密密钥。<sup>[22](https://cacm.acm.org/research/on-the-insecurity-of-elgamal-in-openpgp/)</sup>

**密钥服务器滥用。** SKS 密钥服务器仍然缺乏对使用同一用户 ID 大规模创建密钥的有效防护，导致一些密钥所有者在这些服务器上实际上无法被发现。<sup>[12](https://blog.pgpkeys.eu/state-keyservers-2024.html)</sup>

## 与 S/MIME 的比较

这两个完整 PKI 标准的主要区别在于谁管理密钥。使用 PGP 时没有中心可信权威；用户生成自己的密钥对，并负责通过密钥服务器或直接交换来查找、下载和认证其他用户的公钥。<sup>[23](https://www.frontiersin.org/journals/big-data/articles/10.3389/fdata.2021.568284/full)</sup> S/MIME 对用户隐藏密钥管理：证书来自证书颁发机构，自动嵌入外发邮件，并在收到时由邮件客户端导入，大多无需用户直接交互。<sup>[23](https://www.frontiersin.org/journals/big-data/articles/10.3389/fdata.2021.568284/full)</sup> 权衡在于用户控制和去中心化信任与受管理但依赖 CA 的基础设施之间；上述 EFAIL 和签名伪造结果影响了两个标准的电子邮件客户端。<sup>[20](https://www.usenix.org/system/files/conference/usenixsecurity18/sec18-poddebniak.pdf)</sup><sup> • </sup><sup>[21](https://www.usenix.org/conference/usenixsecurity19/presentation/muller)</sup>

## 谁在使用 GnuPG

GnuPG 仍然嵌入在自由软件发布基础设施中。Ubuntu 贡献者用它来管理加密密钥，并为每次软件包上传添加签名。<sup>[15](https://documentation.ubuntu.com/project/contributors/setup/set-up-and-manage-pgp-keys/)</sup> Linux 内核项目为使用 GnuPG 签署内核版本的维护者维护了一份官方 PGP 指南。<sup>[5](https://docs.kernel.org/process/maintainer-pgp-guide.html)</sup> Debian 和 NixOS 附带 keys.openpgp.org 作为默认密钥服务器。<sup>[16](https://keys.openpgp.org/about/news/three-months-later/)</sup> 与此同时，大多数 Linux 发行版附带的 GnuPG 都带有 FreePG 补丁集，默认禁用非 OpenPGP 格式，许多发行版正在其打包系统中积极从 GnuPG 迁移到符合 OpenPGP 的软件。<sup>[8](https://www.openpgp.org/about/gnupg/)</sup>

## 近期发展

**分裂。** 2022 年 9 月 6 日，GnuPG 宣布将实施规范修订的早期草案，而不是 IETF OpenPGP 工作组其余成员商定的版本。为尽量减少生态系统损害，最终标准 RFC 9580（2024 年 7 月发布）将若干版本号从 5 递增到 6，并更改了其他码点，以避免与 GnuPG 的不同格式产生冲突定义。<sup>[8](https://www.openpgp.org/about/gnupg/)</sup> 2023 年 11 月 29 日，Werner Koch 宣布了 LibrePGP 项目，采用 Koch 撰写的草案（RFC 4880bis）作为 LibrePGP 0.8.2；支持 LibrePGP 的主要实现者是 GnuPG 和 RNP，后者提供 Thunderbird 的 OpenPGP 支持。<sup>[7](https://lwn.net/Articles/953797/)</sup> LibrePGP 弃用指定撤销者功能，认为 GnuPG 自 2.1 版（2014 年）以来创建的托管撤销证书更可取；批评者反驳说，指定撤销者对于大规模部署作为证书撤销列表的替代品很重要。<sup>[24](https://www.librepgp.org/)</sup>

**合规性。** 两个阵营对 GnuPG 的地位描述不同。OpenPGP.org 网站指出，GnuPG 仅实现了当前规范的部分内容：RFC 4880、RFC 5581（Camellia）、RFC 6637（ECC），以及 RFC 9580 中的 Brainpool 和 25519Legacy 曲线。<sup>[8](https://www.openpgp.org/about/gnupg/)</sup> 一份 GnuPG 邮件列表的说法认为，GnuPG 于 1999 年完全符合 RFC 2440，并一直完全符合，直到 2024 年 7 月 RFC 9580 发布。<sup>[25](https://lists.gnupg.org/pipermail/gnupg-users/2026-May/068314.html)</sup> 两种说法都同意分歧始于 2022 年，且 RFC 9580 是当前标准。

**后量子工作。** GnuPG 2.5.24（2026 年 9 月 23 日发布）增加了一个 `--allow-9980` 选项，支持使用 ML-KEM（又称 Kyber）配合 X448、X25519、Brainpool 或 NIST 曲线的 PQC 加密，如 RFC 9980 所规定，同时推荐使用 LibrePGP Kyber 算法来实现后量子抗性；用于支持 RFC 9980、尚在开发中的代码位于 `wk/rfc9980` 分支上。<sup>[6](https://lists.gnupg.org/pipermail/gnupg-announce/2026q3/000516.html)</sup><sup> • </sup><sup>[26](https://lwn.net/Articles/1090390/)</sup> 在 RFC 9580 一方，Proton 在其 OpenPGP.js 和 GopenPGP 库中实现了 crypto-refresh 功能，Thunderbird 的 Kai Engert 指出默认 ECC 曲线被认为比 RSA-4096 更强，后量子加密计划于次年部署。<sup>[7](https://lwn.net/Articles/953797/)</sup>

**治理与资金。** 自 2001 年以来，GnuPG 的维护和开发由 g10 Code GmbH 完成，主要靠捐款资助，全职开发者从事 GnuPG、Libgcrypt、GPGME、Kleopatra、Okular 和 Gpg4win 的工作。<sup>[6](https://lists.gnupg.org/pipermail/gnupg-announce/2026q3/000516.html)</sup> 在 2.4.0 发布时，三名全职雇员和两名承包商专门从事 GnuPG 及密切相关的软件。<sup>[11](https://lists.gnupg.org/pipermail/gnupg-announce/2022q4/000477.html)</sup>

## References

1. [The GNU Privacy Guard, official project site](https://www.gnupg.org/index.en.html)
2. [RFC 9580: OpenPGP, IETF](https://www.rfc-editor.org/rfc/rfc9580.html)
3. [The GNU Privacy Handbook, GnuPG project](https://gnupg.org/gph/en/manual.html)
4. [TOFU for OpenPGP, ACM](https://dl.acm.org/doi/10.1145/2905760.2905761)
5. [Kernel Maintainer PGP guide, Linux kernel documentation](https://docs.kernel.org/process/maintainer-pgp-guide.html)
6. [GnuPG 2.5.24 and Gpg4win 5.1.1 release announcement, gnupg-announce](https://lists.gnupg.org/pipermail/gnupg-announce/2026q3/000516.html)
7. [A schism in the OpenPGP world, LWN.net](https://lwn.net/Articles/953797/)
8. [GnuPG and OpenPGP, OpenPGP.org](https://www.openpgp.org/about/gnupg/)
9. [GPG vs PGP: What's the Difference?, secure-os.org](https://secure-os.org/articles/gpg-vs-pgp/)
10. [Performance Characteristics of Application-level Security Protocols, Peter Gutmann](https://www.cs.auckland.ac.nz/%7Epgut001/pubs/app_sec.pdf)
11. [GnuPG 2.4.0 released (silver anniversary), gnupg-announce](https://lists.gnupg.org/pipermail/gnupg-announce/2022q4/000477.html)
12. [The State of the Keyservers in 2024, blog.pgpkeys.eu](https://blog.pgpkeys.eu/state-keyservers-2024.html)
13. [Investigating the OpenPGP Web of Trust, Hauck, Holz et al.](https://ralphholz.science/publications/InvestigatingTheOpenpgpWebpgpWebOfTrust.pdf)
14. [Why Johnny Can't Encrypt: A Usability Evaluation of PGP 5.0, Whitten & Tygar](https://www.cs.umd.edu/class/fall2018/cmsc818O/papers/why-johnny-cant-encrypt.pdf)
15. [Set up and manage PGP keys, Ubuntu project documentation](https://documentation.ubuntu.com/project/contributors/setup/set-up-and-manage-pgp-keys/)
16. [keys.openpgp.org — Three months later](https://keys.openpgp.org/about/news/three-months-later/)
17. [PGP Walk-Through, Yubico developer documentation](https://developers.yubico.com/PGP/PGP_Walk-Through.html)
18. [SKS OpenPGP Keyserver statistics, pgp.mit.edu](https://pgp.mit.edu/pks/lookup?op=stats)
19. [OpenPGP key statistics, gnupg-users mailing list, January 2014](https://lists.gnutls.org/pipermail/gnupg-users/2014-January/048931.html)
20. [Efail: Breaking S/MIME and OpenPGP Email Encryption using Exfiltration Channels, Poddebniak et al., USENIX Security 2018](https://www.usenix.org/system/files/conference/usenixsecurity18/sec18-poddebniak.pdf)
21. [Johnny, you are fired! – Spoofing OpenPGP and S/MIME Signatures in Emails, USENIX Security 2019](https://www.usenix.org/conference/usenixsecurity19/presentation/muller)
22. [On the (In)Security of ElGamal in OpenPGP, Communications of the ACM](https://cacm.acm.org/research/on-the-insecurity-of-elgamal-in-openpgp/)
23. [Usability of End-to-End Encryption in E-Mail Communication, Frontiers in Big Data, 2021](https://www.frontiersin.org/journals/big-data/articles/10.3389/fdata.2021.568284/full)
24. [LibrePGP project site](https://www.librepgp.org/)
25. [PGP and GnuPG specifications, gnupg-users mailing list](https://lists.gnupg.org/pipermail/gnupg-users/2026-May/068314.html)
26. [GnuPG RFC 9980 support may be on the horizon, LWN.net](https://lwn.net/Articles/1090390/)
27. [GPG Configuration Options (Using the GNU Privacy Guard)](https://gnupg.org/documentation/manuals/gnupg/GPG-Configuration-Options.html)

---
*Initially written Sep 17, 2026 · Reviewed: Sep 30, 2026; Oct 15, 2026 · Edited: Sep 30, 2026; Oct 15, 2026 · Last review: Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 网络与安全 › Security governance and internet policy › Cryptographic protocols › Secure messaging and email protocols

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/gnu-privacy-guard

English original: https://www.edgepedia.org/gnu-privacy-guard
