Toolvito

Works on this device

Private Key Format Validator

Paste a test private key into the masked box, or open a key file, and see whether its format is right: the PEM lines, the Base64 text, the DER structure, and the fields of PKCS#8, PKCS#1, SEC1 or OpenSSH. The tool tells you the key type, the size and whether it is encrypted. Use a test key, never a key that protects real systems.

Enter your values

Paste a PEM or OpenSSH private key. Use a test key. The box is masked and nothing is saved.

Your values

Paste a test key with its BEGIN and END lines. The box is masked, line breaks are dropped (the check does not need them), and the key is never saved or sent.

Your values are worked out in this browser. They are not sent to a server.

Your result will show here

Fill in the values, then choose Check the format.

How to use this validator

  1. Make or take a test key. Do not paste a key that protects real servers, accounts or money: a web page is no place for it.
  2. Choose Paste a key (masked) and paste the key with its BEGIN and END lines, or choose Open a key file for a .pem, .key, id_ed25519 or binary .der file.
  3. Choose Check the format. Read the result, the format, the key type and size, and the table of checks.

What is checked

  • PEM armour (RFC 7468): a BEGIN and an END line with the same label, and Base64 text between them. In a file, lines of 64 characters are the strict form; other lengths are noted. The old OpenSSL encryption with Proc-Type and DEK-Info lines is recognised.
  • DER: every value has a tag and a length; DER writes a length below 128 in one byte, never with a leading zero byte and never open-ended, writes every INTEGER in as few bytes as possible, and has nothing after the outer value.
  • PKCS#8 (label PRIVATE KEY, RFC 5208 and RFC 5958): the version, the algorithm (RSA, RSA-PSS, EC, Ed25519, Ed448, X25519, X448, DSA) and the key inside it.
  • Encrypted PKCS#8 (label ENCRYPTED PRIVATE KEY): PBES2 with PBKDF2 (its hash and iterations) or scrypt, and the cipher (AES-128, AES-192, AES-256 or Triple DES, CBC). Older schemes are named.
  • PKCS#1 (label RSA PRIVATE KEY, RFC 8017): n = p × q, e × d = 1 mod lcm(p − 1, q − 1), and the three values used for fast signing (dP, dQ, qInv).
  • SEC1 (label EC PRIVATE KEY, RFC 5915): version 1, the private key as long as the curve needs (32 bytes for P-256), the curve, and the form of the public point.
  • OpenSSH (label OPENSSH PRIVATE KEY, openssh-key-v1): the cipher and KDF, one key, the two check numbers, the padding 1, 2, 3 ..., the private part against the public part, and the SHA-256 fingerprint of the public key as ssh-keygen -l shows it.

What you never see

The results name formats, algorithms, sizes and checks only. The table "DER structure" lists each value of a DER key with its offset, depth, type and length, never its contents. No number or byte of the key is shown, printed, copied or put into a file, and the comment of an OpenSSH key is counted, not shown. The masked box is never saved. The fingerprint and the public exponent come from the public part of the key.

An encrypted key stays encrypted: the tool never asks for the password, so it can check the wrapping (the scheme, the salt, the iterations, the lengths) but not the key inside.

Worked example

The example is a made-up Ed25519 test key in PKCS#8 form: 48 bytes of DER with version 0, the algorithm id-Ed25519 (1.3.101.112) without parameters, and a 32-byte private key. The result is "Well-formed private key", format PKCS#8, key type Ed25519, 256 bits, not encrypted. The file example is a made-up OpenSSH Ed25519 test key whose fingerprint is SHA256:LVC7PY6ur9Dk+WVIYQsgEU2uvTXAor8XoYLl+ZmNyRo.

Limits you should know

  • A right format does not make a key safe. The tool does not test whether the primes of an RSA key are prime, and it does not check that an EC, Ed25519 or X25519 public key belongs to its private key.
  • OpenPGP key blocks, PuTTY .ppk files, PKCS#12 (.p12, .pfx) files and Java key stores are not read.
  • The masked box drops line breaks, so the length of the Base64 lines is checked only in a file.

Related tools