ECDSA how-to: task × language
Short, working recipes for the ECDSA jobs that come up in real projects — verify a signature, sign a message, generate a key pair, convert a DER signature to raw r‖s, verify an ES256 JWT, decode an X.509 certificate, export a public key as PEM, compute a key fingerprint and more: 24 tasks in 12 languages and tools, from Node.js and Python to the OpenSSL CLI and browser WebCrypto.
Every snippet was executed against real tools before publication, and recipes are cross-checked between languages — a signature produced by the Python recipe verifies with the Node.js one, a Go signature verifies with OpenSSL, and a WebCrypto signature verifies in Node. Where a language has no honest native answer, the cell says so instead of pretending.
* Why some cells are empty
Convert DER ⇄ raw × OpenSSL: The openssl CLI has no command that re-encodes an ECDSA signature: asn1parse can dump r and s but nothing reassembles them. Use the browser DER ⇄ raw converter or one of the language recipes.
Verify an ES256 JWT × OpenSSL: A JWS ES256 signature is raw r‖s, and openssl dgst only consumes DER — rebuilding the DER requires scripting outside openssl itself. The JWT debugger verifies ES256 tokens in the browser instead.
Decode a certificate × WebCrypto: WebCrypto has no ASN.1 or certificate parser — importKey accepts bare SPKI keys only. In the browser, use a library such as @peculiar/x509 (which powers our certificate decoder).
Create a PKCS#12 bundle × Node.js: node:crypto has no PKCS#12 writer, and node-forge, the usual add-on, cannot store EC keys. OpenSSL or the Go, Python and Java recipes build the file instead.
Create a PKCS#12 bundle × WebCrypto: WebCrypto has no PKCS#12 format at all — it imports and exports keys, never key stores. Build the .p12 with OpenSSL or one of the server-side recipes.
Create a PKCS#12 bundle × Swift: Neither swift-crypto nor swift-certificates reads or writes PKCS#12, and Security.framework only imports it on Apple platforms. OpenSSL builds the file instead.
ML-KEM-768 encapsulation × PHP: PHP 8.5's OpenSSL extension loads ML-KEM keys but has no encapsulate or decapsulate function, and openssl_public_encrypt refuses them. Use the openssl CLI or another recipe.
ML-KEM-768 encapsulation × Ruby: The openssl gem 4.0 has no KEM methods: PKey#encrypt fails with “operation not supported for this keytype” on ML-KEM keys. Use the openssl CLI or another recipe.
The in-browser alternatives: DER ⇄ raw converter, JWT ES256 debugger and X.509 certificate decoder.
How these recipes are written
- Mainstream libraries only:
node:crypto, pycacryptography, the Go standard library, the OpenSSL 3 CLI, barecrypto.subtleand each other language's established crypto library — every recipe names the exact library and version it was executed with. - Interop first: every page states whether its signatures are ASN.1 DER or raw r‖s, because mismatched encodings — not broken keys — cause most "invalid signature" errors. The byte-level background is in ECDSA signature formats.
- Each recipe links the browser tool that checks its output — signature verifier, converter, JWT debugger — so you can confirm results without writing more code.