aboutsummaryrefslogtreecommitdiffstats
path: root/lib/asn1/src/asn1rt_per_bin_rt2ct.erl
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2012-12-04 07:23:15 +0100
committerBjörn Gustavsson <[email protected]>2012-12-06 14:22:37 +0100
commitb38a42c5eacceee57333e26948216d199c123e84 (patch)
tree27d2dab58bf90738ab3d7415df45d837f8725035 /lib/asn1/src/asn1rt_per_bin_rt2ct.erl
parent9f83121db1cea3f9b3a8f87435b1767285556ab6 (diff)
downloadotp-b38a42c5eacceee57333e26948216d199c123e84.tar.gz
otp-b38a42c5eacceee57333e26948216d199c123e84.tar.bz2
otp-b38a42c5eacceee57333e26948216d199c123e84.zip
Optimize decoding of OCTET STRINGs
Decoding of fragmented OCTET STRINGs was only implemented when the size was constrained to a single value. While at it, support decoding fragmented OCTET STRINGS in all circumstances.
Diffstat (limited to 'lib/asn1/src/asn1rt_per_bin_rt2ct.erl')
-rw-r--r--lib/asn1/src/asn1rt_per_bin_rt2ct.erl21
1 files changed, 20 insertions, 1 deletions
diff --git a/lib/asn1/src/asn1rt_per_bin_rt2ct.erl b/lib/asn1/src/asn1rt_per_bin_rt2ct.erl
index a7536ee88b..e035ca49d1 100644
--- a/lib/asn1/src/asn1rt_per_bin_rt2ct.erl
+++ b/lib/asn1/src/asn1rt_per_bin_rt2ct.erl
@@ -22,6 +22,7 @@
-include("asn1_records.hrl").
+-export([decode_fragmented/3]).
-export([dec_fixup/3]).
-export([setchoiceext/1, setext/1, fixoptionals/3, fixextensions/2,
getext/1, getextension/2, skipextensions/3, getbit/1, getchoice/3 ]).
@@ -39,7 +40,6 @@
encode_relative_oid/1, decode_relative_oid/1,
complete/1]).
-
-export([encode_open_type/2, decode_open_type/2]).
-export([encode_GeneralString/2, decode_GeneralString/2,
@@ -1392,6 +1392,25 @@ decode_octet_string(Bytes,no,false) ->
%% Bytes3 = align(Bytes2),
getoctets_as_list(Bytes2,Len).
+decode_fragmented(SegSz0, Buf0, Unit) ->
+ SegSz = SegSz0 * Unit * ?'16K',
+ <<Res:SegSz/bitstring,Buf/bitstring>> = Buf0,
+ decode_fragmented_1(Buf, Unit, Res).
+
+decode_fragmented_1(<<0:1,N:7,Buf0/bitstring>>, Unit, Res) ->
+ Sz = N*Unit,
+ <<S:Sz/bitstring,Buf/bitstring>> = Buf0,
+ {<<Res/bitstring,S/bitstring>>,Buf};
+decode_fragmented_1(<<1:1,0:1,N:14,Buf0/bitstring>>, Unit, Res) ->
+ Sz = N*Unit,
+ <<S:Sz/bitstring,Buf/bitstring>> = Buf0,
+ {<<Res/bitstring,S/bitstring>>,Buf};
+decode_fragmented_1(<<1:1,1:1,SegSz0:6,Buf0/bitstring>>, Unit, Res0) ->
+ SegSz = SegSz0 * Unit * ?'16K',
+ <<Frag:SegSz/bitstring,Buf/bitstring>> = Buf0,
+ Res = <<Res0/bitstring,Frag/bitstring>>,
+ decode_fragmented_1(Buf, Unit, Res).
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Restricted char string types