Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

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

Aperta Adatta ai principianti
#188 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
78/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
c

Direzione di ricerca

Leggi le funzioni cupsJWTMakePrivateKey(), make_ec_key() e cupsJWTLoadCredentials() in cups/jwt.c, oltre a openssl_create_key() in cups/tls-openssl.c. Sostituisci i quattro usi di NID_secp256k1 identificati nell’issue con NID_X9_62_prime256v1. Esegui testjwt e testjson, poi verifica che ES256 funzioni con chiavi NIST P-256 standard mentre ES384 ed ES512 continuino a funzionare correttamente.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
C
Stelle
84
Fork
50
Merge medio
10h 49m
PR unite (30g)
5

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di OpenPrinting/libcups

Tutte le issue di OpenPrinting/libcups

Issue simili

Altre issue su C

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.