spki: Document how to convert between `SubjectPublicKeyInfoRef` (or owned) and e.g. `p256::PublicKey`
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 42/100
- Tipo di issue
- Documentazione
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- rust
- Ambito
- cryptography, documentation
Direzione di ricerca
Inizia dalla documentazione di spki SubjectPublicKeyInfo e DecodePublicKey, quindi confrontala con le indicazioni sul parsing di p256 ed elliptic-curve menzionate nell’issue. Il lavoro è completato quando il percorso di conversione supportato è individuabile, con un esempio chiaro come p256::PublicKey::try_from(spki), e la documentazione o API pertinente è stata aggiornata di conseguenza.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
As part of migrating age-plugin-yubikey to yubikey 0.8 (using VS Code and rust-analyzer), I encountered SubjectPublicKeyInfo in a certificate. I need to parse this into an Option<p256::PublicKey> (returning None if invalid or not P-256), but there is no documentation anywhere in the spki crate on how to do this.
I found SubjectPublicKeyInfo::from_key which is how to convert any type implementing EncodePublicKey into an SPKI, but there is no equivalent reverse method. A DecodePublicKey trait exists, but there is no reference to it in the documentation of SubjectPublicKeyInfo (or its owned or ref aliases). DecodePublicKey also doesn't document how it should be used either.
I then turned to the p256 crate's documentation:
p256::EncodedPointhas no documentation of its own and is a type alias forelliptic_curve::sec1::EncodedPoint, so I looked there, and there's nothing helpful.p256::PublicKeyhas no documentation of its own (and therefore no documentation appears in VS Code viarust-analyzer) and is a type alias forelliptic_curve::PublicKey. Finally there, I found the Parsing "SPKI" Keys documentation! But it says to use theDecodePublicKeytrait, which has no methods that take aSubjectPublicKeyInfo.
I finally noticed the impl<T> DecodePublicKey for T where T: for<'a> TryFrom<SubjectPublicKeyInfoRef<'a>> at the bottom of the DecodePublicKey documentation, which gave me the idea to just try p256::PublicKey::try_from(spki), and it worked!
The conversion process should be greatly simplified, by way of one or more of the following:
- Have an explicit method on
SubjectPublicKeyInfofor converting into a key. This can internally just call through to theTryFromimpl, but the method would then be discoverable via IDE code completion. - Document in the
spkicrate how to convert from its types. A single example of the formp256::PublicKey::try_from(spki)would have saved me hours of time and frustration digging through documentation and source code.
- Lingua principale
- Rust
- Stelle
- 338
- Fork
- 188
- Merge medio
- 4g 6h
- PR unite (30g)
- 15
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di RustCrypto/formats
-
Difficoltà 1/5 1-3 ore Idoneità per principianti 86/100
RustCrypto/formats#2389 · 1 commento ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
RustCrypto/formats#2366 ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
RustCrypto/formats#2430 · 1 reazione ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
RustCrypto/formats#2428 · 1 commento ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
RustCrypto/formats#2427 · 1 commento ·
Tutte le issue di RustCrypto/formats
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
TheLarkInn/aipm#2413 ·
-
documentation
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
alexgorbatchev/simple-ptt#15 ·
-
tooling
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
todo:ticket
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
taikoxyz/taiko-mono#22168 · 1 commento ·