Commit 99cca91e authored by David Howells's avatar David Howells Committed by Rusty Russell

ASN.1: Use the ASN1_LONG_TAG and ASN1_INDEFINITE_LENGTH constants

Use the ASN1_LONG_TAG and ASN1_INDEFINITE_LENGTH constants in the ASN.1
general decoder instead of the equivalent numbers.
Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
parent facc0a6b
...@@ -81,7 +81,7 @@ static int asn1_find_indefinite_length(const unsigned char *data, size_t datalen ...@@ -81,7 +81,7 @@ static int asn1_find_indefinite_length(const unsigned char *data, size_t datalen
goto next_tag; goto next_tag;
} }
if (unlikely((tag & 0x1f) == 0x1f)) { if (unlikely((tag & 0x1f) == ASN1_LONG_TAG)) {
do { do {
if (unlikely(datalen - dp < 2)) if (unlikely(datalen - dp < 2))
goto data_overrun_error; goto data_overrun_error;
...@@ -96,7 +96,7 @@ static int asn1_find_indefinite_length(const unsigned char *data, size_t datalen ...@@ -96,7 +96,7 @@ static int asn1_find_indefinite_length(const unsigned char *data, size_t datalen
goto next_tag; goto next_tag;
} }
if (unlikely(len == 0x80)) { if (unlikely(len == ASN1_INDEFINITE_LENGTH)) {
/* Indefinite length */ /* Indefinite length */
if (unlikely((tag & ASN1_CONS_BIT) == ASN1_PRIM << 5)) if (unlikely((tag & ASN1_CONS_BIT) == ASN1_PRIM << 5))
goto indefinite_len_primitive; goto indefinite_len_primitive;
...@@ -222,7 +222,7 @@ int asn1_ber_decoder(const struct asn1_decoder *decoder, ...@@ -222,7 +222,7 @@ int asn1_ber_decoder(const struct asn1_decoder *decoder,
if (unlikely(dp >= datalen - 1)) if (unlikely(dp >= datalen - 1))
goto data_overrun_error; goto data_overrun_error;
tag = data[dp++]; tag = data[dp++];
if (unlikely((tag & 0x1f) == 0x1f)) if (unlikely((tag & 0x1f) == ASN1_LONG_TAG))
goto long_tag_not_supported; goto long_tag_not_supported;
if (op & ASN1_OP_MATCH__ANY) { if (op & ASN1_OP_MATCH__ANY) {
...@@ -254,7 +254,7 @@ int asn1_ber_decoder(const struct asn1_decoder *decoder, ...@@ -254,7 +254,7 @@ int asn1_ber_decoder(const struct asn1_decoder *decoder,
len = data[dp++]; len = data[dp++];
if (len > 0x7f) { if (len > 0x7f) {
if (unlikely(len == 0x80)) { if (unlikely(len == ASN1_INDEFINITE_LENGTH)) {
/* Indefinite length */ /* Indefinite length */
if (unlikely(!(tag & ASN1_CONS_BIT))) if (unlikely(!(tag & ASN1_CONS_BIT)))
goto indefinite_len_primitive; goto indefinite_len_primitive;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment