Fix decoding of ASN.1 LONG and ZLONG items
authorRichard Levitte <levitte@openssl.org>
Mon, 20 Mar 2017 20:31:02 +0000 (21:31 +0100)
committerRichard Levitte <levitte@openssl.org>
Mon, 20 Mar 2017 21:09:57 +0000 (22:09 +0100)
commitca2045dc545ba4afe8abbe29d0316ee3d36da7df
tree6cda19369300ab6fcd5eaa0b98dcc02434fe6c5b
parent2ca2e9175d54dc66a66fe2a51ff5dd9b3bc899dc
Fix decoding of ASN.1 LONG and ZLONG items

LONG and ZLONG items (which are OpenSSL private special cases of
ASN1_INTEGER) are encoded into DER with padding if the leading octet
has the high bit set, where the padding can be 0x00 (for positive
numbers) or 0xff (for negative ones).

When decoding DER to LONG or ZLONG, the padding wasn't taken in
account at all, which means that if the encoded size with padding
is one byte more than the size of long, decoding fails.  This change
fixes that issue.

Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/3000)
crypto/asn1/x_long.c