I am playing around with GPG which I'd like to use to sign an integer and use the resulting signature binary in another piece of code. So far I have created a simple PGP packet parser with which I think I can successfully extract the elliptic curve point representing the public key.

Comes then signature parsing from the PGP message and which I haven't been able to interpret so far, finding no hints in RFC4880 or 5480 which define all bytes up to the last 68, the signature representation. But how should this 68 bytes be parsed exactly? Which RFC would be the one to look at?

  • $\begingroup$ In my experience, when trying to coerce implementations to interoperate, gpg --list-packets is less than totally useless. YMMV. $\endgroup$
    – fgrieu
    Feb 24, 2019 at 16:21
  • $\begingroup$ Thanks, OpenPGP Alliance point to RFC6637 which defines additional parameters for EC public keys, that's already helping. I'll dig deeper in RFC4880 to see how to format the integer I want to be signed. I still lack reference with regards to EC signature format which should be defined in a separate RFC... $\endgroup$
    – roshii
    Feb 24, 2019 at 16:21
  • $\begingroup$ I've reopened the question since you cannot find the signature definition in the referenced standards, and asking for it seems on topic to me. $\endgroup$
    – Maarten Bodewes
    Feb 24, 2019 at 16:55
  • $\begingroup$ security.stackexchange.com/a/94937/46255 is that link sufficient? $\endgroup$
    – Natanael
    Feb 24, 2019 at 23:53
  • $\begingroup$ It appears to be MPI(r) MPI(s) same as for DSA, in rfc4880 $\endgroup$ Feb 25, 2019 at 5:51

1 Answer 1


An ECDSA signature in PGP is indeed encoded as MPI(r) MPI(s)
This is confirmed by RFC6637 which refers back to RFC4880. This is made more clear in draft RFC4880bis which incorporates the former.

Multiprecision integers (MPI) format is itself described in RFC4880, section 3.2


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.