diff options
author | 2015-06-16 06:11:39 +0000 | |
---|---|---|
committer | 2015-06-16 06:11:39 +0000 | |
commit | 2b93cbaa87a6a03a859b2d59d406ebfaba6a912a (patch) | |
tree | 4f29042df9e01103ab04338d4116ef2e75d77c51 /lib/libssl/bs_cbs.c | |
parent | Add a uslcom id for the Netgear M7100 console from Andrew Daugherity. (diff) | |
download | wireguard-openbsd-2b93cbaa87a6a03a859b2d59d406ebfaba6a912a.tar.xz wireguard-openbsd-2b93cbaa87a6a03a859b2d59d406ebfaba6a912a.zip |
Simplify cbs_get_any_asn1_element_internal based on comments from jsing@
Diffstat (limited to 'lib/libssl/bs_cbs.c')
-rw-r--r-- | lib/libssl/bs_cbs.c | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/lib/libssl/bs_cbs.c b/lib/libssl/bs_cbs.c index ba38303c18a..1b513c9a0e2 100644 --- a/lib/libssl/bs_cbs.c +++ b/lib/libssl/bs_cbs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bs_cbs.c,v 1.9 2015/06/15 07:35:49 doug Exp $ */ +/* $OpenBSD: bs_cbs.c,v 1.10 2015/06/16 06:11:39 doug Exp $ */ /* * Copyright (c) 2014, Google Inc. * @@ -262,21 +262,17 @@ cbs_get_any_asn1_element_internal(CBS *cbs, CBS *out, unsigned *out_tag, /* Handle indefinite form length */ if (num_bytes == 0) { /* DER encoding doesn't allow for indefinite form. */ - if (strict) { + if (strict) return 0; - } else { - if ((tag & CBS_ASN1_CONSTRUCTED) != 0 && - num_bytes == 0) { - /* indefinite length */ - if (out_header_len != NULL) - *out_header_len = 2; - return CBS_get_bytes(cbs, out, 2); - } else { - /* Primitive cannot use indefinite. */ - return 0; - } - } + /* Primitive cannot use indefinite in BER or DER. */ + if ((tag & CBS_ASN1_CONSTRUCTED) == 0) + return 0; + + /* Constructed, indefinite length allowed in BER. */ + if (out_header_len != NULL) + *out_header_len = 2; + return CBS_get_bytes(cbs, out, 2); } /* CBS limitation. */ @@ -286,7 +282,7 @@ cbs_get_any_asn1_element_internal(CBS *cbs, CBS *out, unsigned *out_tag, if (!cbs_get_u(&header, &len32, num_bytes)) return 0; - /* DER has a minimum length octet requirements. */ + /* DER has a minimum length octet requirement. */ if (len32 < 128) /* Should have used short form instead */ return 0; |