aboutsummaryrefslogtreecommitdiffstats
path: root/lib/asn1
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2014-10-30 14:12:51 +0100
committerBjörn Gustavsson <[email protected]>2015-01-12 11:40:26 +0100
commit5abac511937a99414902d3052fb633e1a65812d3 (patch)
tree923ba92f5ff7ebe2a71e01f04e694436fe3b6651 /lib/asn1
parentd0b902b1909ae6d17fd2548baf0fd95ab44f0631 (diff)
downloadotp-5abac511937a99414902d3052fb633e1a65812d3.tar.gz
otp-5abac511937a99414902d3052fb633e1a65812d3.tar.bz2
otp-5abac511937a99414902d3052fb633e1a65812d3.zip
Fix instantiation of an inlined type in a value definition
Diffstat (limited to 'lib/asn1')
-rw-r--r--lib/asn1/src/asn1ct_check.erl25
-rw-r--r--lib/asn1/test/asn1_SUITE_data/ParamBasic.asn111
-rw-r--r--lib/asn1/test/testParamBasic.erl3
3 files changed, 22 insertions, 17 deletions
diff --git a/lib/asn1/src/asn1ct_check.erl b/lib/asn1/src/asn1ct_check.erl
index 5f07933c74..904979e86e 100644
--- a/lib/asn1/src/asn1ct_check.erl
+++ b/lib/asn1/src/asn1ct_check.erl
@@ -395,7 +395,7 @@ do_checkv(S, Name, Value)
{pobjectsetdef,Name};
{objectsetdef} ->
{objectsetdef,Name};
- {objectdef} ->
+ {asn1_class, _} ->
%% this is an object, save as typedef
#valuedef{checked=C,pos=Pos,name=N,type=Type,
value=Def} = Value,
@@ -1398,7 +1398,7 @@ check_fieldname_element_1(S, #valuedef{}=VDef) ->
try
check_value(S, VDef)
catch
- throw:{objectdef} ->
+ throw:{asn1_class, _} ->
#valuedef{checked=C,pos=Pos,name=N,type=Type,
value=Def} = VDef,
ClassName = Type#type.def,
@@ -2091,8 +2091,9 @@ check_value(S, #valuedef{}=V) ->
end.
check_valuedef(#state{recordtopname=TopName}=S0, V0) ->
- #valuedef{name=Name,type=Vtype,value=Value,module=ModName} = V0,
+ #valuedef{name=Name,type=Vtype0,value=Value,module=ModName} = V0,
V = V0#valuedef{checked=true},
+ Vtype = check_type(S0, #typedef{name=Name,typespec=Vtype0},Vtype0),
Def = Vtype#type.def,
S1 = S0#state{type=Vtype,tname=Def,value=V0,vname=Name},
SVal = update_state(S1, ModName),
@@ -2102,15 +2103,8 @@ check_valuedef(#state{recordtopname=TopName}=S0, V0) ->
%% If V isn't a value but an object Type is a #classdef{}
S2 = update_state(S1, RefM),
case Type of
- #classdef{} ->
- throw({objectdef});
#typedef{typespec=TypeSpec0}=TypeDef ->
- TypeSpec = try check_type(S2, TypeDef, TypeSpec0) of
- TypeSpec1 -> TypeSpec1
- catch
- throw:{asn1_class,_} ->
- throw({objectdef})
- end,
+ TypeSpec = check_type(S2, TypeDef, TypeSpec0),
S3 = case is_contextswitchtype(Type) of
true ->
S2;
@@ -2127,7 +2121,7 @@ check_valuedef(#state{recordtopname=TopName}=S0, V0) ->
V#valuedef{type=Type}),
V#valuedef{value=CheckedVal}
end;
- 'ANY' ->
+ 'ASN1_OPEN_TYPE' ->
{opentypefieldvalue,ANYType,ANYValue} = Value,
CheckedV = check_value(SVal,#valuedef{name=Name,
type=ANYType,
@@ -2141,11 +2135,6 @@ check_valuedef(#state{recordtopname=TopName}=S0, V0) ->
#'SEQUENCE'{} ->
{ok,SeqVal} = convert_external(SVal, Value),
V#valuedef{value=normalize_value(SVal, Vtype, SeqVal, TopName)};
- {'SelectionType',SelName,SelT} ->
- CheckedT = check_selectiontype(SVal, SelName, SelT),
- NewV = V#valuedef{type=CheckedT},
- SelVDef = check_value(S1#state{value=NewV}, NewV),
- V#valuedef{value=SelVDef#valuedef.value};
_ ->
V#valuedef{value=normalize_value(SVal, Vtype, Value, TopName)}
end.
@@ -3220,6 +3209,8 @@ check_type(S=#state{recordtopname=TopName},Type,Ts) when is_record(Ts,type) ->
CheckedT = check_selectiontype(S,Name,T),
TempNewDef#newt{tag=merge_tags(Tag,CheckedT#type.tag),
type=CheckedT#type.def};
+ 'ASN1_OPEN_TYPE' ->
+ TempNewDef;
Other ->
exit({'cant check' ,Other})
end,
diff --git a/lib/asn1/test/asn1_SUITE_data/ParamBasic.asn1 b/lib/asn1/test/asn1_SUITE_data/ParamBasic.asn1
index 8a69a6addd..f175aabd26 100644
--- a/lib/asn1/test/asn1_SUITE_data/ParamBasic.asn1
+++ b/lib/asn1/test/asn1_SUITE_data/ParamBasic.asn1
@@ -61,4 +61,15 @@ Seq ::= SEQUENCE {
ObjectSet-1 ALGORITHM-IDENTIFIER ::= { {INTEGER IDENTIFIED BY {2 1 1}}, ... }
ObjectSet-2 ALGORITHM-IDENTIFIER ::= { ... }
+-- Test a value that uses the instantiation of a parameterized type inline.
+-- (Adapted from PKCS-5.)
+--
+
+algid-hmacWithSHA1 AlgorithmIdentifier2 {{ObjectSet-3}} ::=
+ {algorithm id-hmacWithSHA1, parameters NULL : NULL}
+
+ObjectSet-3 TYPE-IDENTIFIER ::= { {NULL IDENTIFIED BY id-hmacWithSHA1} }
+
+id-hmacWithSHA1 OBJECT IDENTIFIER ::= {2 9 9 9 7}
+
END
diff --git a/lib/asn1/test/testParamBasic.erl b/lib/asn1/test/testParamBasic.erl
index 52c6426414..ab5bf70e55 100644
--- a/lib/asn1/test/testParamBasic.erl
+++ b/lib/asn1/test/testParamBasic.erl
@@ -50,6 +50,9 @@ main(Rules) ->
roundtrip('Seq', {'Seq',
{'Seq_c1',{2,1,1},42},
{'Seq_c2',{2,1,1,1},asn1_NOVALUE}}),
+
+ {_,{2,9,9,9,7},'NULL'} = 'ParamBasic':'algid-hmacWithSHA1'(),
+
ok.
roundtrip(Type, Value) ->