I would like to upload my public key to a key server, but I already have my key infrastructure in place without GPG and I don't want to install extra software I don't need. Is there an easy way to ASCII-armor my public key without installing the whole GnuPG software suite?
1 Answer
OpenPGP's "Radix-64" ASCII armor, described in RFC 4880 § 6, is mostly just standard Base64 with PEM-like begin/end headers, and with a CRC24 checksum at the end. It can be implemented like this:
Write the Armor Header Line; optional Armor Headers; and a blank line:
-----BEGIN PGP PUBLIC KEY BLOCK----- Version: conradpgp v1.0 (leave this line empty)
Write the Base64-encoded message, wrapped to 76 characters per line.
Write the checksum line, consisting of a
=
followed by the Base64-encoded Armor Checksum:The checksum is a 24-bit Cyclic Redundancy Check (CRC) converted to
four characters of radix-64 encoding by the same MIME base64
transformation, preceded by an equal sign (=). The CRC is computed
by using the generator 0x864CFB and an initialization of 0xB704CE.
The accumulation is done on the data before it is converted to
radix-64, rather than on the converted data. A sample implementation
of this algorithm is in the next section.(See section 6.1 for the example CRC24 code.)
Finally, write the Armor Tail:
-----END PGP PUBLIC KEY BLOCK-----
-
2
-