aboutsummaryrefslogtreecommitdiffstats
path: root/lib/asn1/src/asn1ct_gen_per.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/asn1ct_gen_per.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/asn1ct_gen_per.erl')
-rw-r--r--lib/asn1/src/asn1ct_gen_per.erl16
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/asn1/src/asn1ct_gen_per.erl b/lib/asn1/src/asn1ct_gen_per.erl
index eab0f62ecf..79cff2eae2 100644
--- a/lib/asn1/src/asn1ct_gen_per.erl
+++ b/lib/asn1/src/asn1ct_gen_per.erl
@@ -297,6 +297,16 @@ emit_enc_enumerated_case(_Per,C, {0,EnumName}, Count) ->
emit_enc_enumerated_case(_Erule, C, EnumName, Count) ->
emit(["'",EnumName,"' -> ?RT_PER:encode_integer(",{asis,C},", ",Count,")"]).
+get_constraint([{Key,V}], Key) ->
+ V;
+get_constraint([], _) ->
+ no;
+get_constraint(C, Key) ->
+ case lists:keyfind(Key, 1, C) of
+ false -> no;
+ {Key,V} -> V
+ end.
+
%% Object code generating for encoding and decoding
%% ------------------------------------------------
@@ -1181,8 +1191,10 @@ gen_dec_prim(Erules,Att,BytesVar) ->
Imm = asn1ct_imm:per_dec_boolean(),
asn1ct_imm:dec_code_gen(Imm, BytesVar);
'OCTET STRING' ->
- emit({"?RT_PER:decode_octet_string(",BytesVar,",",
- {asis,Constraint},")"});
+ SzConstr = get_constraint(Constraint, 'SizeConstraint'),
+ Imm0 = asn1ct_imm:per_dec_octet_string(SzConstr, Aligned),
+ Imm = {convert,binary_to_list,Imm0},
+ asn1ct_imm:dec_code_gen(Imm, BytesVar);
'NumericString' ->
emit({"?RT_PER:decode_NumericString(",BytesVar,",",
{asis,Constraint},")"});