diff options
author | Björn Gustavsson <[email protected]> | 2012-12-04 07:23:15 +0100 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2012-12-06 14:22:37 +0100 |
commit | b38a42c5eacceee57333e26948216d199c123e84 (patch) | |
tree | 27d2dab58bf90738ab3d7415df45d837f8725035 /lib/asn1/src/asn1rt_uper_bin.erl | |
parent | 9f83121db1cea3f9b3a8f87435b1767285556ab6 (diff) | |
download | otp-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_uper_bin.erl')
-rw-r--r-- | lib/asn1/src/asn1rt_uper_bin.erl | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/asn1/src/asn1rt_uper_bin.erl b/lib/asn1/src/asn1rt_uper_bin.erl index 2cd68c62a0..afb3cb28d9 100644 --- a/lib/asn1/src/asn1rt_uper_bin.erl +++ b/lib/asn1/src/asn1rt_uper_bin.erl @@ -25,6 +25,7 @@ %%-compile(export_all). +-export([decode_fragmented/3]). -export([setext/1, fixoptionals/3, fixextensions/2, getext/1, getextension/2, skipextensions/3, getbit/1, getchoice/3 ]). @@ -1119,6 +1120,24 @@ decode_octet_string1(Bytes,no) -> {Len,Bytes2} = decode_length(Bytes,undefined), 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). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |