You appear to be asking about keys exported from GnuPG, although you don't actually say so, and it isn't clear if you mean public keys (only) or secret (aka private) keys.
Nor if you mean the GnuPG suite (which includes both gpg
and gpgsm
) or the gpg
program only.
First, to clarify, the extension on a filename doesn't really matter; what is important is the format of the data in the file(s). People often (usually?) choose the extension to reflect the format, and some programs (like the GUI Kleopatra in gpg4win) encourage this, but GnuPG itself can process a file depending on its actual format without regard to the extension (or lack thereof).
gpg
processes OpenPGP messages using OpenPGP keys, and for all files (except clearsigned) it supports binary or 'ASCII armored' variants. There is one OpenPGP-defined format for each of public and private keys, and those are the (only) export formats gpg
supports, in both variants. People generally use .asc
for armored files, because the actual content type can be determined by looking at the first (or last) line; .gpg
is sometimes used for binary files, but sometimes people use other extensions to indicate the type of content as well as format, such as .enc
for encrypted, .sig
for signed or signature, .key
or maybe .pub
or .sec
for keys, etc.
Public keys are protected against tampering by at least one signature, and don't need to be confidential; private keys have one signature, and are encrypted with password-based encryption using reasonable algorithms by default (unless you have deliberately configured them badly) so their confidentiality is protected if you use a good password (including passphrase) and not otherwise.
gpgsm
processes S/MIME (effectively CMS) messages using S/MIME keys and certificates, and similarly supports binary and PEM files; although not identical, PEM is very similar to PGP's ASCII armor and gpgsm
adapts option --armor
to actually mean PEM. gpgsm
supports exporting public keys as X.509 certificates, and private keys in PKCS1, PKCS8, or PKCS12 formats, all in binary and PEM variants. However Kleopatra supports only X.509 and PKCS12. Similarly people, and Kleopatra, use .pem
for PEM and varying extensions like .p7s .p7m .der .p12
for binary.
X.509 public keys (certs) are protected from tampering by CA signature and don't need confidentiality, like PGP public keys. PKCS1 and PKCS8 private keys from gpgsm
are not encrypted, which is very bad, and not protected from tampering either, but as noted Kleopatra doesn't support these. PKCS12 private keys are protected by a password-based MAC and also include the X.509 cert which is protected as above and partially verifies the private key. The private key is encrypted by password-based encryption with 3DES which is decent but at risk if and when quantum analysis succeeds, and dependent on the password in the same fashion as gpg
/OpenPGP; following common practice, the cert is encrypted with a weak algorithm (RC2-40) which is unnecessary and silly.
The main differences are that a PGP key can only be used with PGP programs and not S/MIME, while the S/MIME format keys can only be used with S/MIME and similar programs but not PGP, so which is better depends on who you want or need to communicate with. The text formats (armor and PEM) are necessary if you want or need to process the key as text, for example with cut-and-paste; otherwise it doesn't matter to (most? all?) programs, although the text formats are easier for a person to identify, especially if the filename was badly chosen or altered accidentally.