aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/asn1/src/asn1rtt_per.erl37
-rw-r--r--lib/asn1/src/asn1rtt_uper.erl36
2 files changed, 12 insertions, 61 deletions
diff --git a/lib/asn1/src/asn1rtt_per.erl b/lib/asn1/src/asn1rtt_per.erl
index 7194e8d127..4713125ffc 100644
--- a/lib/asn1/src/asn1rtt_per.erl
+++ b/lib/asn1/src/asn1rtt_per.erl
@@ -79,7 +79,7 @@ skipextensions(Bytes0, Nr, ExtensionBitstr) when is_bitstring(ExtensionBitstr) -
Prev = Nr - 1,
case ExtensionBitstr of
<<_:Prev,1:1,_/bitstring>> ->
- {Len,Bytes1} = decode_length(Bytes0, undefined),
+ {Len,Bytes1} = decode_length(Bytes0),
<<_:Len/binary,Bytes2/bitstring>> = Bytes1,
skipextensions(Bytes2, Nr+1, ExtensionBitstr);
<<_:Prev,0:1,_/bitstring>> ->
@@ -262,7 +262,7 @@ encode_semi_constrained_number(Lb, Val) ->
end.
decode_semi_constrained_number(Bytes) ->
- {Len,Bytes2} = decode_length(Bytes, undefined),
+ {Len,Bytes2} = decode_length(Bytes),
getoctets(Bytes2, Len).
encode_constrained_number({Lb,_Ub},_Range,{bits,N},Val) ->
@@ -465,7 +465,7 @@ encode_small_length(Len) ->
[1,encode_length(Len)].
-decode_length(Buffer, undefined) -> % un-constrained
+decode_length(Buffer) -> % un-constrained
case align(Buffer) of
<<0:1,Oct:7,Rest/binary>> ->
{Oct,Rest};
@@ -474,37 +474,12 @@ decode_length(Buffer, undefined) -> % un-constrained
<<3:2,_Val:14,_Rest/binary>> ->
%% this case should be fixed
exit({error,{asn1,{decode_length,{nyi,above_16k}}}})
- end;
+ end.
-decode_length(Buffer, {Lb,Ub}) when Ub =< 65535 ,Lb >= 0 -> % constrained
+decode_length(Buffer, {Lb,Ub}) when Ub =< 65535, Lb >= 0 -> % constrained
decode_constrained_number(Buffer, {Lb,Ub});
decode_length(Buffer, {Lb,_Ub}) when is_integer(Lb), Lb >= 0 -> % Ub > 65535
- decode_length(Buffer,undefined);
-decode_length(Buffer, {{Lb,Ub},Ext}) when is_list(Ext) ->
- case getbit(Buffer) of
- {0,Buffer2} ->
- decode_length(Buffer2, {Lb,Ub});
- {1,Buffer2} ->
- decode_length(Buffer2, undefined)
- end;
-
-%When does this case occur with {_,_Lb,Ub} ??
-% X.691:10.9.3.5
-decode_length(Bin, {_,_Lb,_Ub}) -> % Unconstrained or large Ub NOTE! this case does not cover case when Ub > 65535
- case Bin of
- <<0:1,Val:7,Rest/bitstring>> ->
- {Val,Rest};
- _ ->
- case align(Bin) of
- <<2:2,Val:14,Rest/binary>> ->
- {Val,Rest};
- <<3:2,_:14,_Rest/binary>> ->
- exit({error,{asn1,{decode_length,{nyi,length_above_64K}}}})
- end
- end;
-decode_length(Buffer, SingleValue) when is_integer(SingleValue) ->
- {SingleValue,Buffer}.
-
+ decode_length(Buffer).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% bitstring NamedBitList
diff --git a/lib/asn1/src/asn1rtt_uper.erl b/lib/asn1/src/asn1rtt_uper.erl
index d78116cc92..b5e8a3c3bb 100644
--- a/lib/asn1/src/asn1rtt_uper.erl
+++ b/lib/asn1/src/asn1rtt_uper.erl
@@ -113,7 +113,7 @@ skipextensions(Bytes0, Nr, ExtensionBitstr) when is_bitstring(ExtensionBitstr) -
Prev = Nr - 1,
case ExtensionBitstr of
<<_:Prev,1:1,_/bitstring>> ->
- {Len,Bytes1} = decode_length(Bytes0, undefined),
+ {Len,Bytes1} = decode_length(Bytes0),
<<_:Len/binary,Bytes2/bitstring>> = Bytes1,
skipextensions(Bytes2, Nr+1, ExtensionBitstr);
<<_:Prev,0:1,_/bitstring>> ->
@@ -290,7 +290,7 @@ encode_semi_constrained_number(Lb, Val) ->
end.
decode_semi_constrained_number(Bytes) ->
- {Len,Bytes2} = decode_length(Bytes, undefined),
+ {Len,Bytes2} = decode_length(Bytes),
{V,Bytes3} = getoctets(Bytes2,Len),
{V,Bytes3}.
@@ -416,36 +416,12 @@ encode_small_length(Len) ->
%% un-constrained
-decode_length(<<0:1,Oct:7,Rest/bitstring>>,undefined) ->
+decode_length(<<0:1,Oct:7,Rest/bitstring>>) ->
{Oct,Rest};
-decode_length(<<2:2,Val:14,Rest/bitstring>>,undefined) ->
+decode_length(<<2:2,Val:14,Rest/bitstring>>) ->
{Val,Rest};
-decode_length(<<3:2,_:14,_Rest/bitstring>>,undefined) ->
- exit({error,{asn1,{decode_length,{nyi,above_16k}}}});
-
-decode_length(Buffer,{Lb,Ub}) when Ub =< 65535, Lb >= 0 -> % constrained
- decode_constrained_number(Buffer,{Lb,Ub});
-decode_length(Buffer,{Lb,_}) when is_integer(Lb), Lb >= 0 -> % Ub > 65535
- decode_length(Buffer,undefined);
-decode_length(Buffer,{VR={_Lb,_Ub},Ext}) when is_list(Ext) ->
- {0,Buffer2} = getbit(Buffer),
- decode_length(Buffer2, VR);
-
-
-%When does this case occur with {_,_Lb,Ub} ??
-% X.691:10.9.3.5
-decode_length(Bin,{_,_Lb,_Ub}) -> %when Len =< 127 -> % Unconstrained or large Ub NOTE! this case does not cover case when Ub > 65535
- case Bin of
- <<0:1,Val:7,Rest/bitstring>> ->
- {Val,Rest};
- <<2:2,Val:14,Rest/bitstring>> ->
- {Val,Rest};
- <<3:2,_:14,_Rest/bitstring>> ->
- exit({error,{asn1,{decode_length,{nyi,length_above_64K}}}})
- end;
-decode_length(Buffer,SingleValue) when is_integer(SingleValue) ->
- {SingleValue,Buffer}.
-
+decode_length(<<3:2,_:14,_Rest/bitstring>>) ->
+ exit({error,{asn1,{decode_length,{nyi,above_16k}}}}).
% X.691:11
encode_boolean(true) ->