aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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,