Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

ES256 / ECDSA P-256 keys use secp256k1 instead of NIST P-256 in the OpenSSL build

未关闭 适合新手
#188 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
78/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
c

调研方向

阅读 cups/jwt.c 中的 cupsJWTMakePrivateKey()、make_ec_key() 和 cupsJWTLoadCredentials() 函数,以及 cups/tls-openssl.c 中的 openssl_create_key()。将 issue 中指出的四处 NID_secp256k1 替换为 NID_X9_62_prime256v1。运行 testjwt 和 testjson,然后检查 ES256 是否能使用标准 NIST P-256 密钥正常工作,同时确保 ES384 和 ES512 仍然正确。

由索引模型根据 Issue 内容生成。

描述

In the OpenSSL build, libcups generates every key labelled "P-256" on the secp256k1 curve (the Koblitz curve) instead of NIST P-256 (secp256r1 / NID_X9_62_prime256v1). RFC 7518 section 6.2.1.1 defines the JWK "crv":"P-256" and the ES256 algorithm as NIST P-256. P-384 and P-521 are correct, so it looks like a secp256k1 vs secp256r1 slip, and the only OpenSSL constant for r1 is NID_X9_62_prime256v1.

Affected code (OpenSSL build only; the GnuTLS build uses SECP256R1 and is correct):

  1. cups/jwt.c, cupsJWTMakePrivateKey(): ES256 key generation uses NID_secp256k1
  2. cups/jwt.c, make_ec_key(): the "P-256" import/verify branch uses NID_secp256k1
  3. cups/jwt.c, cupsJWTLoadCredentials(): the curve read-back maps NID_secp256k1 to "P-256"
  4. cups/tls-openssl.c, openssl_create_key(): CUPS_CREDTYPE_ECDSA_P256_SHA256 uses NID_secp256k1

Effect:

  1. The key is on the wrong curve while still labelled "P-256". With Python cryptography, the public key point is not on NIST P-256; it is on secp256k1.
  2. cupsJWTHasValidSignature() rejects a valid ES256 token signed with a real P-256 key, and ES256 tokens CUPS signs are rejected by RFC-compliant libraries. jwcrypto rejects CUPS ES256 tokens, and CUPS reports a standard jwcrypto P-256 token as invalid. ES384 and ES512 are fine. It fails closed; there is no bypass.
  3. A CUPS_CREDTYPE_ECDSA_P256_SHA256 certificate is generated on secp256k1 but presented as P-256, so standard TLS clients reject it. This type is opt-in; the default is RSA-3072 or P-384.

Present in libcups 3.0.0 and 3.0.3. CUPS 2.5 master has the same code.

Fix: change NID_secp256k1 to NID_X9_62_prime256v1 in all four places. P-384 and P-521 already use NID_secp384r1 and NID_secp521r1.

Verified on macOS arm64 with Homebrew OpenSSL 3.6.3. After the fix the key point is on NIST P-256, jwcrypto verifies CUPS ES256 tokens, CUPS verifies standard P-256 tokens, and testjwt (ES256 and ES384 included) and testjson pass. I can open a PR with the fix if you want.

主要语言
C
星标
84
派生
50
平均合并
10 小时 49 分钟
30 天内合并 PR
5

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

OpenPrinting/libcups 的其他 Issue

查看 OpenPrinting/libcups 的全部 Issue

相似的 Issue

更多 C Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。