Cryptography guides

Make an ECDSA signing pair and match the two PEM files

·

A workshop verifier needs the public key that belongs to a new signing key. Generate one pair, export the two files separately and derive the public part from the private file to check that they match.

RSA and ECDSA Key Generator

Generate a P-256 signing pair

Choose ECDSA P-256 in Key algorithm and select Generate key pair. The public field begins with BEGIN PUBLIC KEY and the fingerprint beneath the result status has 64 hexadecimal digits.

Save public-key.pem. Choose Download private key, then Save unencrypted private key only if you need private-key.pem. The private bytes are available to the signer, so keep the file separate from material you share.

Compare the labels on the exported PEM files
-----BEGIN PUBLIC KEY-----
-----BEGIN PRIVATE KEY-----

W3C Web Cryptography Level 2 — Generate a keyRFC 7468 — Textual encodings of PKIX, PKCS and CMS structures

Derive a public copy from the saved private file

With both demonstration files in a local folder, run OpenSSL pkey to derive a public PEM from private-key.pem. Compare that file to public-key.pem. For this example the public key and its named curve are identical.

The workspace fingerprint hashes the DER representation of the public key. Use OpenSSL pkey with -pubin and -outform DER to get the bytes to hash.

Derive the public part in OpenSSL
openssl pkey -in private-key.pem -pubout -out derived-public.pem

OpenSSL — pkey commandRFC 7468 — Textual encodings of PKIX, PKCS and CMS structures

Choose an algorithm your verifier accepts

If the receiving service specifies a 3072-bit RSA signing key, select RSA 3072 bits to generate a new pair with that modulus size. The public and private PEM headers stay the same while the encoded algorithm changes.

Generate a second P-256 pair and compare the fingerprint to the first. The curve stays fixed and the identity changes with each new pair.

W3C Web Cryptography Level 2 — Generate a key

Common questions

Does the public fingerprint include PEM line endings?

The digest covers DER SubjectPublicKeyInfo bytes. The public file wraps those bytes in PEM for transport.

How do I distinguish encrypted PKCS#8 from this export?

This export begins with BEGIN PRIVATE KEY. The PEM format for encrypted PKCS#8 begins with BEGIN ENCRYPTED PRIVATE KEY.

Sources

Put it into practice.

Related guides