GPG Signature Verification
peter at digitalbrains.com
Wed Apr 26 12:23:49 CEST 2017
On 24/04/17 19:23, Peter Lebbing wrote:
> The part of "cmp" that would correspond to the constant part of the DER
> encoding I do not recognise.
It is still proper ASN.1, but it encodes a slightly different structure.
I wondered whether it was DER encoded or BER encoded, because I read
that BER was valid for old PKCS#1 v1.5 structures. DER is a subset of
BER. If the Python ASN.1 module pyasn1 rejects malformed DER encoding
then it is proper DER; or would pyasn1 be liberal in what it accepts?
Anyway, the two ASN.1 encoded objects are slightly different:
>>> import pyasn1.codec.der.decoder
>>> sha256der = b'\x30\x31\x30\x0d\x06\x09\x60\x86\x48\x01\x65\x03\x04\x02\x01\x05\x00\x04\x20' + chr(0)*32
(Sequence().setComponentByPosition(0, Sequence().setComponentByPosition(0, ObjectIdentifier(2.16.822.214.171.124.4.2.1)).setComponentByPosition(1, Null(''))).setComponentByPosition(1, OctetString(hexValue='0000000000000000000000000000000000000000000000000000000000000000')), '')
(Sequence().setComponentByPosition(0, Sequence().setComponentByPosition(0, ObjectIdentifier(2.16.8126.96.36.199.4.2.1))).setComponentByPosition(1, OctetString(hexValue='0000000000000000000000000000000000000000000000000000000000000000')), '')
There's an extra setComponentByPosition(1, Null('')) in the properly
encoded ASN.1. It would appear that the library you're using *is*
trying to generate a PKCS#1 v1.5 message, but that it ends up with a
slightly different DER encoding than what is defined for OpenPGP. You
will have to find a way to generate a EMSA-PKCS1-v1_5 structure that is
compatible to RFC 4880 (and RFC 3447 PKCS #1 Version 2.1).
I don't know much about ASN.1, so I can't really say anything useful
about the results of the experiment above.
I use the GNU Privacy Guard (GnuPG) in combination with Enigmail.
You can send me encrypted mail if you want some privacy.
My key is available at <http://digitalbrains.com/2012/openpgp-key-peter>
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 488 bytes
Desc: OpenPGP digital signature
More information about the Gnupg-users