Skip to content

Commit

Permalink
asn_der_ber: only allow three different tag-length encodings:
Browse files Browse the repository at this point in the history
- primitive, definitive length
- constructed, definitive length
- constructed, indefinitive length

a primitive with indefinitive length leads to an error
  • Loading branch information
hannesm committed Jan 28, 2020
1 parent 6fe05bf commit 17d733e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/asn_ber_der.ml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,13 @@ module R = struct
| 0x80 -> Tag.Context_specific tag_v
| _ -> Tag.Private tag_v
and coding =
(* according to layman's guide to a subset of ASN.1, BER, and DER, there
are three possibilities in BER (DER restricts this further):
- (a) primitive + definitive length
- (b) constructed + definitive length
- (c) constructed + indefinite length *)
match (t0 land 0x20, l0) with
| (0, 0x80) -> error cs "primitive and indefinite length"
| (0, _ ) -> Primitive len
| (_, 0x80) -> Constructed_indefinite
| _ -> Constructed len in
Expand Down

0 comments on commit 17d733e

Please sign in to comment.