Code
The cryptography of computers: hashes, AES and HMAC, RSA’s weak keys, Diffie–Hellman, certificates, one-time passwords, Shor and Grover, ML-KEM, BB84, Shamir’s shares, time locks, passwords.
Keys & Certificates
Reads a certificate, a certification request, a key or any ASN.1 in DER, and an SSH public key: the fields named as RFC 5280 names them, the object identifiers from the RFCs’ own ASN.1, the fingerprints, the public key as a JWK, an SSH key’s randomart, and the whole as bars over its bytes. It verifies no signature. What is pasted is never saved.
Terms
History, how it works, how it was checked, limits
History
ASN.1 describes data and its encoding rules write it as nested elements of a tag, a length and contents: BER, and DER, the form with one encoding for each value (ITU-T X.690). X.509 certificates are written so; RFC 5280 is the Internet’s profile of them, RFC 2986 the request a certificate is asked for with. Wrapped in Base64 between BEGIN and END lines they are the “PEM” files of RFC 7468. OpenSSH draws a key’s fingerprint as a small picture, whose walk Loss, Limmer and von Gernler described as the drunken bishop in 2009.
How it works
A PEM text, bare DER in hexadecimal or Base64, or an SSH public key is pasted. The elements are read one inside another; an OCTET STRING or BIT STRING that holds an encoding is opened, as an extension’s value and a public key are. A certificate’s, a request’s and a key’s elements are named as their RFC names them, object identifiers from the ASN.1 printed in six RFCs. The rows give the names as RFC 4514 writes them, the validity, the key, the extensions RFC 5280 §4.2.1 defines, and the SHA-256 and SHA-1 of the encoding; the public key is also written as a JWK. The figure draws every element as a bar over its bytes, its tag and length darker. An SSH key is read by its wire format, with OpenSSH’s two fingerprints and the randomart of its SHA-256.
How it was checked
OpenSSL’s asn1parse and this reader agree on the offset, depth, header length, length and type of all 766 elements of 30 encodings: every textual encoding RFC 7468 and RFC 8410 print, and certificates, a request and keys made for the tests. For each certificate the subject, issuer, serial number, dates, fingerprints and RSA modulus equal what openssl x509 prints. For three SSH keys the fingerprints and the randomart, by SHA-256 and by MD5, equal ssh-keygen’s output line for line.
The tests hold 27 checks of this tool; 16 rest on outside material, the first eight here:
- A standard’s own vectors OpenSSL’s asn1parse: all 766 elements of 30 encodings (every textual encoding RFC 7468 and RFC 8410 print, and Unveil’s own certificates, request and keys) at the same offset and depth, with the same header length, length and type
- A standard’s own vectors RFC 8410’s key written with indefinite lengths (BER) is read to its end-of-contents, and said to be BER
- A standard’s own vectors OpenSSL’s x509: for each of the 6 certificates the subject and issuer (RFC 2253’s form), the serial number, both dates, the SHA-256 and SHA-1 fingerprints and an RSA key’s modulus
- A standard’s own vectors OpenSSL’s x509 on Unveil’s server certificate: the same five alternative names, key usages, extended usages and basic constraints, in RFC 5280’s own words for them
- A standard’s own vectors OpenSSL’s x509 on Unveil’s certificate authority: CA:TRUE, pathlen:0 and a P-256 key (prime256v1 is RFC 5480’s secp256r1)
- A standard’s own vectors An RSA public key as a JWK (RFC 7518 §6.3): n is OpenSSL’s modulus in Base64url, e is AQAB for 65537
- A standard’s own vectors RFC 8410, §10.1: its Ed25519 public key as a JWK of type OKP (RFC 8037), x the 32 bytes of the key
- A standard’s own vectors RFC 7468, §13: its public key is on secp384r1, P-384 in a JWK, its two coordinates 48 bytes each
The other 8, and every tool’s checks
Limits
No signature is verified, no chain built, no revocation checked: the tool reads what a certificate says, not whether it is true. PKCS #7, CMS and PKCS #12 are shown as ASN.1 without their fields named; an encrypted key is not opened. An identifier outside the six RFCs is given by its numbers. A JWK is written for RSA, the three NIST curves and the curves of RFC 8037. SSH private keys, SSH certificates and the randomart of anything but an SSH key are not read.
- ITU-T Recommendation X.690 (02/2021), ASN.1 encoding rules: BER, CER and DER; X.680, Table 1
- D. Cooper and others, Internet X.509 Public Key Infrastructure Certificate and CRL Profile, RFC 5280 (2008)
- S. Josefsson and S. Leonard, Textual Encodings of PKIX, PKCS, and CMS Structures, RFC 7468 (2015)
- P. Hoffman and J. Schaad, New ASN.1 Modules for the PKIX, RFC 5912 (2010), with RFC 8410, RFC 5480, RFC 8017 and RFC 5758: the object identifiers
- M. Jones, JSON Web Key, RFC 7517, and JSON Web Algorithms, RFC 7518 (2015); I. Liusvaara, RFC 8037 (2017)
- T. Ylonen and C. Lonvick, The Secure Shell (SSH) Transport Layer Protocol, RFC 4253 (2006), §6.6; RFC 5656 §3.1; RFC 8709 §4
- Dirk Loss, Tobias Limmer and Alexander von Gernler, The drunken bishop: An analysis of the OpenSSH fingerprint visualization algorithm (2009)