Ben Laurie said:
I've been working on signatures recently, and I'm puzzled. As I
understand it, the form of a decrypted signature is:
01 FF FF ... FF FF 00 <ASN.1 nonsense> <hash>
However, every signature I look at decrypts to:
00 01 FF FF ... FF FF 00 <ASN.1 nonsense> <hash>
Before I hurt my head trying to figure out why, I wonder if there's
something obvious I missed?
Hi Ben,
leading zeros can be left out while it is still a large integer. Eg. for
RSA signatures it is pretty normal that the signature is a) one byte
smaller than the RSA-n or b) contains a leading zero. This pretty much
depends on your implementation of large integers. Or to give you an
example in C:
It does not matter whether you assign
int a=0x01;
or:
int a=0x000001;
or.... whatever, it is still a "1".
Really, leave the leading zero out. Even the former east-block states got
rid of their leading zeros - it works pretty well... ;-)
Konrad