From 7c1786ef06498a80f982aa08da30e3775184c5d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Fri, 8 Mar 2013 09:51:43 +0100 Subject: PER/UPER: Correct decoding of ENUMERATEDs with a single value An ENUMERATED with as single value is not encoded. The decoder incorrectly assumed that it was encoded in one bit. --- lib/asn1/test/asn1_SUITE_data/Prim.asn1 | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'lib/asn1/test') diff --git a/lib/asn1/test/asn1_SUITE_data/Prim.asn1 b/lib/asn1/test/asn1_SUITE_data/Prim.asn1 index 17a5d3490a..c3d54dbbb3 100644 --- a/lib/asn1/test/asn1_SUITE_data/Prim.asn1 +++ b/lib/asn1/test/asn1_SUITE_data/Prim.asn1 @@ -22,6 +22,8 @@ BEGIN Enum ::= ENUMERATED {monday(1),tuesday(2),wednesday(3),thursday(4), friday(5),saturday(6),sunday(7)} + SingleEnumVal ::= ENUMERATED {true} + SingleEnumValExt ::= ENUMERATED {true, ...} ObjId ::= OBJECT IDENTIFIER @@ -35,4 +37,15 @@ BEGIN base (2), exponent (-125..128) } ) + Seq ::= SEQUENCE { + n Null, + i1 INTEGER (0..63), + e1 SingleEnumVal, + i2 INTEGER (0..63), + e2 SingleEnumVal, + i3 INTEGER (0..63), + b Bool, + i4 INTEGER (0..63) + } + END -- cgit v1.2.3 From 5588449531f1a41d05e5d2d4fe5976db643a18e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Tue, 12 Mar 2013 08:35:48 +0100 Subject: PER: Ensure that the complete encoding is at least one byte If the encoding is empty (i.e. if a top-level type is single-valued and therefore not encoding), the result should be a single zero byte. --- lib/asn1/test/testPrim.erl | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'lib/asn1/test') diff --git a/lib/asn1/test/testPrim.erl b/lib/asn1/test/testPrim.erl index 0d4427ba69..91fb9fffca 100644 --- a/lib/asn1/test/testPrim.erl +++ b/lib/asn1/test/testPrim.erl @@ -513,6 +513,14 @@ enum(Rules) -> case catch asn1_wrapper:encode('Prim','Enum',4) of Enum -> Enum end, ok end, + + case Rules of + Per when Per =:= per; Per =:= uper -> + {ok,<<0>>} = 'Prim':encode('SingleEnumVal', true), + {ok,<<0>>} = 'Prim':encode('SingleEnumValExt', true); + ber -> + ok + end, ok. -- cgit v1.2.3