aboutsummaryrefslogtreecommitdiffstats
path: root/lib/asn1
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2014-04-28 12:25:22 +0200
committerBjörn Gustavsson <[email protected]>2014-06-05 13:46:27 +0200
commit739ad067cf8775558fade616353f44d49a13a487 (patch)
treeddb83e2af2a8e069eb53260418e13e1521c6112c /lib/asn1
parent7929b72efed6b2f5dee18a0b758ae4d6f001f054 (diff)
downloadotp-739ad067cf8775558fade616353f44d49a13a487.tar.gz
otp-739ad067cf8775558fade616353f44d49a13a487.tar.bz2
otp-739ad067cf8775558fade616353f44d49a13a487.zip
Correct OCTET STRING default when legacy_erlang_types is active
The default value for an OCTET STRING when legacy_erlang_types was active would be a binary instead of a list.
Diffstat (limited to 'lib/asn1')
-rw-r--r--lib/asn1/src/asn1ct_gen.erl5
-rw-r--r--lib/asn1/test/testSeqSetDefaultVal.erl24
2 files changed, 21 insertions, 8 deletions
diff --git a/lib/asn1/src/asn1ct_gen.erl b/lib/asn1/src/asn1ct_gen.erl
index 149813c3aa..c6561bcdb4 100644
--- a/lib/asn1/src/asn1ct_gen.erl
+++ b/lib/asn1/src/asn1ct_gen.erl
@@ -1378,6 +1378,11 @@ conform_value(#type{def={'BIT STRING',[]}}, Bs) ->
bitstring when is_bitstring(Bs) ->
Bs
end;
+conform_value(#type{def='OCTET STRING'}, String) ->
+ case asn1ct:use_legacy_types() of
+ false -> String;
+ true -> binary_to_list(String)
+ end;
conform_value(_, Value) -> Value.
named_bitstring_value(List, Names) ->
diff --git a/lib/asn1/test/testSeqSetDefaultVal.erl b/lib/asn1/test/testSeqSetDefaultVal.erl
index b54391d63f..4b106e72e3 100644
--- a/lib/asn1/test/testSeqSetDefaultVal.erl
+++ b/lib/asn1/test/testSeqSetDefaultVal.erl
@@ -107,7 +107,7 @@ main(Rule, Opts) ->
{ber,[der]} ->
der(),
case 'Default':legacy_erlang_types() of
- false -> ok;
+ false -> der_new_types();
true -> der_legacy()
end;
{_,_} ->
@@ -242,13 +242,6 @@ der() ->
#'SetInts'{a=1,b=-1,c=three,d=1},
#'SetInts'{a=1,b=-1,c=3,d=1}),
-
- roundtrip(<<48,0>>, 'SeqOS',
- #'SeqOS'{a = <<172>>,b = <<16#A8,16#A0>>,c='NULL'}),
-
- roundtrip(<<49,0>>, 'SetOS',
- #'SetOS'{a = <<172>>,b = <<16#A8,16#A0>>,c='NULL'}),
-
roundtrip(<<48,0>>,
'SeqOI',
#'SeqOI'{a={1,2,14,15},
@@ -397,9 +390,24 @@ der() ->
c=[second], d = <<>>}),
ok.
+der_new_types() ->
+ io:put_chars("Performing DER-specific tests with new types..."),
+
+ roundtrip(<<48,0>>, 'SeqOS',
+ #'SeqOS'{a = <<172>>,b = <<16#A8,16#A0>>,c='NULL'}),
+
+ roundtrip(<<49,0>>, 'SetOS',
+ #'SetOS'{a = <<172>>,b = <<16#A8,16#A0>>,c='NULL'}),
+ ok.
+
der_legacy() ->
io:put_chars("Performing DER-specific tests with legacy types..."),
+ roundtrip(<<48,0>>, 'SeqOS',
+ #'SeqOS'{a=[172],b=[16#A8,16#A0],c='NULL'}),
+ roundtrip(<<49,0>>, 'SetOS',
+ #'SetOS'{a=[172],b=[16#A8,16#A0],c='NULL'}),
+
roundtrip(<<48,0>>,
'SeqBS',
#'SeqBS'{a=2#0110101,