Include JS WebCrypto raw format for openssl_get_publicKey
Nessuno ha ancora preso questa issue.
- Lingua principale
- C
- Stelle
- 40.4k
- Fork
- 8.1k
- Merge medio
- 2g 13h
- PR unite (30g)
- 96
Descrizione
Description
With the inclusion of JS WebCrypto API, I believe it is necessary to support the exported raw format when client sends their own public EC keys to the server.
const { publicKey } = await crypto.subtle.generateKey({
name : 'ECDH',
namedCurve : 'P-256'
}, true, ['deriveBits'])
const exported_key = new Uint8Array(await crypto.subtle.exportKey('raw', publicKey))
fetch('key.php', {
method : 'post',
body : btoa(String.fromCharCode(...exported_key))
}).then(e=>e.text())
However, openssl_pkey_get_public only accepts PEM formatted string. This would mean a whole lot of concatenating to do before we are able to get the public OpenSSLAsymmetricKey
$raw_format = base64_decode(file_get_content("php://input"));
// This header is only for P-256
$asn_1_header = pack('C*', ...[48, 89, 48, 19, 6, 7, 42, 134, 72, 206, 61, 2, 1, 6, 8, 42, 134, 72, 206, 61, 3, 1, 7, 3, 66, 0]);
var_dump(openssl_get_publicKey("-----BEGIN PUBLIC KEY-----\n".base64_encode($asn_1_header.$raw_format)."\n-----END PUBLIC KEY-----"));
It would be pretty cool to simplify it so that it becomes the following.
openssl_get_publicKey($raw_format);
I think alternatively we can make a new function for openssl to load what JS Web Crypto generated as "raw" type.
Note
I know that WebCrypto API does allow exporting SPKI key but that is besides the point. To add to this, when you subscribe to pushmanager, a p256dh is given in "raw" format as defined by WebCrypto API.
Guida per i contributori
Apri la guida per i contributori
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.
Direzione di ricerca
Inizia dagli entry point openssl_get_publicKey e openssl_pkey_get_public e verifica come vengono attualmente accettate le chiavi pubbliche OpenSSL. Determina come debba essere riconosciuto e supportato l’input non elaborato di chiavi pubbliche EC WebCrypto, incluso l’esempio P-256 indicato; il lavoro è completato quando l’input non elaborato può produrre un OpenSSLAsymmetricKey senza wrapping manuale ASN.1 o PEM.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- javascript, php
- Ambito
- cryptography
- Tipo di issue
- Funzionalità
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 30/100