如何使用 P-256、ED25519 和 Curve25519 查找并升级 SSH 和 PGP 密钥
How to find and upgrade SSH and PGP keys using P‑256, ED25519, and Curve25519

原始链接: https://sethmlarson.dev/how-to-find-and-upgrade-256-bit-curve-keys

作者认为,谷歌决定在 2027 年 3 月 17 日之后不再接受长期有效的 ECDSA P-256 根/中间 CA 证书,是 256 位椭圆曲线可能正接近高成本破解的有力证据。由于 SSH 和 PGP 密钥也可能长期有效,作者建议在接下来几个月内审查这些密钥,但不必恐慌。作者提供了一些命令,用于查找已在 SSH 代理中注册的 P-256、Ed25519 和 Curve25519 密钥,以及匹配 25519/256 标识的 PGP 密钥,同时排除后量子算法。在作者的系统上,有一个 SSH Ed25519 密钥需要注意,而 RSA-4096 PGP 密钥目前被认为风险较低。抗量子 SSH 密钥尚未广泛可用:OpenSSH 从 10.6p2 开始支持 mldsa44-ed25519,GitHub 尚不支持 ML-DSA,而且该标准仍是 IETF 草案。在 mldsa44-ed25519 能够端到端使用之前,作者建议将 P-384 或 RSA-4096 作为临时方案,但对硬件密钥和 Bitwarden 等密码管理器有一些注意事项。在生成并测试替代密钥后,从服务、代理和本地系统中移除旧密钥。

一篇 Hacker News 讨论帖讨论了一篇文章,内容是关于查找并升级使用 P-256、Ed25519 和 Curve25519 的 SSH/PGP 密钥。评论者质疑为什么需要更换 Ed25519 SSH 密钥,指出它们主要用于身份验证,而攻击者并不会去破解公钥部分。有人建议避免大范围公开公钥,也有人询问 iOS Secure Enclave 或硬件令牌中的 P-256 密钥是否也应淘汰。回复称,实际风险尚不确定,对大多数用户而言可能很小。工具方面的限制以及体积较大的后量子签名,例如 JWT cookie 大小问题,可能会拖慢采用速度。一位评论者分享了一条手动 SSH 密钥扫描命令。还有人表达对不断变化的密码学建议感到困惑或沮丧;一条回复称,Ed25519 目前并不被认为不好,但未来可能出现的漏洞和量子计算方面的担忧正在引发焦虑。总体建议是:清点密钥,在条件允许时升级系统,并关注新进展。
相关文章

原文

Probably the strongest evidence that there exists an expensive break of 256-bit elliptic curves arrived yesterday, Google announced that root and intermediate CA certificates (read: "long-lived") that used the ECDSA P-256 curve would not be accepted after March 17, 2027. This is ~100 days (a very short timespan for anything that affects "all CAs") and would affect ~25% of all web traffic, which is not something one would do for no reason.

Speaking of long-lived keys, SSH and PGP keys are similar to root and intermediate CA certificates in that way. I don't think this is a "drop everything and do this now" situation, but the timeline of "next three months" seems prudent. Here's how to find keys that you should upgrade on your system:

ssh-add -L | grep -E '^[^ ]*(nistp256|25519)' | grep -vE '^[^ ]*ml-?dsa'

This command finds P-256, ED25519, and Curve25519 keys that are registered with your SSH agent. The same is true for PGP keys, if you have those on your system:

gpg -k --keyid-format long | grep -E '^(pub|sub|sec|ssb)[#>]? +[^/ ]*(25519|256)' | grep -viE 'ky[0-9]|dil[0-9]|ml-?kem|ml-?dsa'

Here's what running these commands returns on my computer as of this morning:

ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINzmaKr8fHsDNPeht128GMbA+fe53pjYbPgS0V8dhjfK SSH

Seems that my PGP key is using RSA-4096 which is not a concern for today. Okay, so let's upgrade the SSH key now. Unfortunately I'm not able to generate quantum-safe SSH keys yet (ssh -Q key | grep -i mldsa is empty), Ubuntu 26.04.1 ships 10.2p1, but support for mldsa44-ed25519 in OpenSSH 10.6p2.

GitHub doesn't support ML-DSA for SSH yet (SSH ML-DSA is still an IETF draft). If GitHub supports mldsa44-ed25519 SSH keys at the time you're reading this then use ssh-keygen -t mldsa44-ed25519 ..., otherwise proceed with P-384 or RSA-4096.

You can generate a P-384 elliptic curve SSH key like so:

ssh-keygen -t ecdsa -b 384 -C '(comment)' (...options for encryption like '-a 100')

Note that if you're generating a new key with a hardware key (-sk suffix) please check that the generated key is actually using P-384, OpenSSH will ignore the -b option for hardware keys. From the OpenSSH -b manpage:

"ECDSA-SK, Ed25519 and Ed25519-SK keys have a fixed length and the -b flag will be ignored."

After you generate the file locally, register the SSH key with your password manager and remove the files from your filesystem. Funnily enough, this is how I discovered that Bitwarden only supports ED25519 and RSA SSH keys. It pains me to say that having an RSA-4096 key is a decent stop-gap at this point until you can upgrade to a quantum-safe key across both your hardware key / password manager and services you're using the key with.

After you've generated and tested using your new key then don't forget to unregister your now unused key with services and removing the key from your SSH agent, computer, etc.

Thank you to William Woodruff for reviewing this document prior to publication.

Thanks for reading!

Send me an email or message on Mastodon or Bluesky. The best way to support my writing is sharing links with your friends or colleagues. If you’d like to be notified of future publications either subscribe via RSS or add your email to the newsletter:

联系我们 contact @ memedata.com