]> granicus.if.org Git - openssl/commit
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:11:02 +0000 (22:11 +0100)
commit2e5adeb2904dd68780fb154dbeb6e3efafb418bb
treeb839c66bf395fa95a8d069e947feabd682ae8627
parent9abe889702bdc73f9490f611f54bf9c865702554
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)
(cherry picked from commit ca2045dc545ba4afe8abbe29d0316ee3d36da7df)
crypto/asn1/x_long.c