In researching GnuPG ECC support, I generated a number of sample ECDH/ECDSA
keypairs and exported them to keyring format in order to analyze the data format
(and confirm that I was reading RFC 6637 correctly).
In doing so, I noticed that ECDH and ECDSA private keys are being encoded in an
unusual way, always indicating a bit count divisible by 8 even when the most
significant bit is zero. Furthermore, when the most significant bit IS set, an
extra 00 byte is being prepended (e.g. "01 08 00 88 a3 a2 ... 4a 0c" rather than
"01 00 88 a3 a2 ... 4a 0c"), analagous to what is done with ASN.1 encoding; in
the case of a NIST P-256 key, the private key's length was reported as 264 bits.
This does not appear to happen in any other places - MPIs in RSA/DSA/ELG
public/private keys, ECDH/ECDSA public keys, and encryption/signature data all
have appropriate bit counts and no leading null bytes.
I'm not certain if this is strictly incorrect (RFC 4880 section 3.2 states that
the length starts "from its most significant non-zero bit", but it does not
stipulate that it MUST be that way). However, it may lead to interoperability
issues as other applications start supporting ECDH/ECDSA keys.
Observed in gpg2 version 2.1.2 - not certain if the latest dev code also has it,
since I'm having trouble building it.