I'm trying to set up a gpg key generator/manager web based using openpgpjs and an openpgp server. I'm able to generate the key pair with no trouble at all, but when I want to send the armored public key to the pks, I get an error: "Error decoding keyblock".
After several tries (with url encoding, with no url encoding, through Ajax request or with a copy/paste directly on the pks' form...), I decided to try and import it in GnuPG : it worked!
Then I tried to export the key from GnuPG and copy the result in the pks's form, it worked too. So I tried to compare the imported file and the exported one expecting that some CR+LF would be differents. I was surprised that the entire ASCII-armored key is different.
So I have two questions:
As stated by @owlstead, the two applications are using different version of the open PGP protocol. Openpgpjs provides ASCII armored key using the new format while pks only accept the old format.
You need to decode the first byte of the key to notice it: Take the first 2 letters of the key and use the radix-64 table to get the binary value, then check the first 8 bits (one byte).
The first bit is always one, the second one should be one too (it means it's a new packet), then the following is the binary value corresponding to the content of the ASCII armor :
In the old format, the binary value is coded on 4 bits (bits 5 to 2), in the new one, it's on 6 bits (from 5 to 0).
More details can be found in RFC 2440, chapter 4.