Current section

Files

Jump to
ca src UsefulDefinitions.erl
Raw

src/UsefulDefinitions.erl

%% Generated by the Erlang ASN.1 BER compiler. Version: 5.0.9
%% Purpose: Encoding and decoding of the types in UsefulDefinitions.
-module('UsefulDefinitions').
-compile(nowarn_unused_vars).
-dialyzer(no_improper_lists).
-include("UsefulDefinitions.hrl").
-asn1_info([{vsn,'5.0.9'},
{module,'UsefulDefinitions'},
{options,[{i,"src"},noobj,{outdir,"src"},{i,"."},{i,"priv/kep"}]}]).
-export([encoding_rule/0,maps/0,bit_string_format/0,
legacy_erlang_types/0]).
-export(['dialyzer-suppressions'/1]).
-export([
enc_ID/2
]).
-export([
dec_ID/2
]).
-export([
ds/0,
module/0,
serviceElement/0,
applicationContext/0,
attributeType/0,
attributeSyntax/0,
objectClass/0,
algorithm/0,
abstractSyntax/0,
dsaOperationalAttribute/0,
matchingRule/0,
knowledgeMatchingRule/0,
nameForm/0,
group/0,
subentry/0,
operationalAttributeType/0,
operationalBinding/0,
schemaObjectClass/0,
schemaOperationalAttribute/0,
administrativeRoles/0,
accessControlAttribute/0,
rosObject/0,
contract/0,
package/0,
accessControlSchemes/0,
certificateExtension/0,
managementObject/0,
attributeValueContext/0,
idmProtocol/0,
problem/0,
notification/0,
matchingRestriction/0,
controlAttributeType/0,
usefulDefinitions/0,
informationFramework/0,
directoryAbstractService/0,
distributedOperations/0,
protocolObjectIdentifiers/0,
selectedAttributeTypes/0,
selectedObjectClasses/0,
authenticationFramework/0,
algorithmObjectIdentifiers/0,
directoryObjectIdentifiers/0,
upperBounds/0,
dap/0,
dsp/0,
distributedDirectoryOIDs/0,
directoryShadowOIDs/0,
directoryShadowAbstractService/0,
disp/0,
dop/0,
opBindingManagement/0,
opBindingOIDs/0,
hierarchicalOperationalBindings/0,
dsaOperationalAttributeTypes/0,
schemaAdministration/0,
basicAccessControl/0,
directoryOperationalBindingTypes/0,
certificateExtensions/0,
directoryManagement/0,
enhancedSecurity/0,
iDMProtocolSpecification/0,
directoryIDMProtocols/0,
'id-oc'/0,
'id-at'/0,
'id-as'/0,
'id-mr'/0,
'id-nf'/0,
'id-sc'/0,
'id-oa'/0,
'id-ob'/0,
'id-doa'/0,
'id-kmr'/0,
'id-soc'/0,
'id-soa'/0,
'id-ar'/0,
'id-aca'/0,
'id-ac'/0,
'id-rosObject'/0,
'id-contract'/0,
'id-package'/0,
'id-acScheme'/0,
'id-ce'/0,
'id-mgt'/0,
'id-idm'/0,
'id-avc'/0,
'id-pr'/0,
'id-not'/0,
'id-mre'/0,
'id-cat'/0
]).
-export([info/0]).
-export([encode/2,decode/2]).
encoding_rule() -> ber.
maps() -> false.
bit_string_format() -> bitstring.
legacy_erlang_types() -> false.
encode(Type, Data) ->
try iolist_to_binary(element(1, encode_disp(Type, Data))) of
Bytes ->
{ok,Bytes}
catch
Class:Exception:Stk when Class =:= error; Class =:= exit ->
case Exception of
{error,{asn1,Reason}} ->
{error,{asn1,{Reason,Stk}}};
Reason ->
{error,{asn1,{Reason,Stk}}}
end
end.
decode(Type, Data) ->
try
Result = decode_disp(Type, element(1, ber_decode_nif(Data))),
{ok,Result}
catch
Class:Exception:Stk when Class =:= error; Class =:= exit ->
case Exception of
{error,{asn1,Reason}} ->
{error,{asn1,{Reason,Stk}}};
Reason ->
{error,{asn1,{Reason,Stk}}}
end
end.
encode_disp('ID', Data) -> enc_ID(Data);
encode_disp(Type, _Data) -> exit({error,{asn1,{undefined_type,Type}}}).
decode_disp('ID', Data) -> dec_ID(Data);
decode_disp(Type, _Data) -> exit({error,{asn1,{undefined_type,Type}}}).
info() ->
case ?MODULE:module_info(attributes) of
Attributes when is_list(Attributes) ->
case lists:keyfind(asn1_info, 1, Attributes) of
{_,Info} when is_list(Info) ->
Info;
_ ->
[]
end;
_ ->
[]
end.
%%================================
%% ID
%%================================
enc_ID(Val) ->
enc_ID(Val, [<<6>>]).
enc_ID(Val, TagIn) ->
encode_object_identifier(Val, TagIn).
dec_ID(Tlv) ->
dec_ID(Tlv, [6]).
dec_ID(Tlv, TagIn) ->
decode_object_identifier(Tlv, TagIn).
ds() ->
{2,5}.
module() ->
{2,5,1}.
serviceElement() ->
{2,5,2}.
applicationContext() ->
{2,5,3}.
attributeType() ->
{2,5,4}.
attributeSyntax() ->
{2,5,5}.
objectClass() ->
{2,5,6}.
algorithm() ->
{2,5,8}.
abstractSyntax() ->
{2,5,9}.
dsaOperationalAttribute() ->
{2,5,12}.
matchingRule() ->
{2,5,13}.
knowledgeMatchingRule() ->
{2,5,14}.
nameForm() ->
{2,5,15}.
group() ->
{2,5,16}.
subentry() ->
{2,5,17}.
operationalAttributeType() ->
{2,5,18}.
operationalBinding() ->
{2,5,19}.
schemaObjectClass() ->
{2,5,20}.
schemaOperationalAttribute() ->
{2,5,21}.
administrativeRoles() ->
{2,5,23}.
accessControlAttribute() ->
{2,5,24}.
rosObject() ->
{2,5,25}.
contract() ->
{2,5,26}.
package() ->
{2,5,27}.
accessControlSchemes() ->
{2,5,28}.
certificateExtension() ->
{2,5,29}.
managementObject() ->
{2,5,30}.
attributeValueContext() ->
{2,5,31}.
idmProtocol() ->
{2,5,33}.
problem() ->
{2,5,34}.
notification() ->
{2,5,35}.
matchingRestriction() ->
{2,5,36}.
controlAttributeType() ->
{2,5,37}.
usefulDefinitions() ->
{2,5,1,0,3}.
informationFramework() ->
{2,5,1,1,3}.
directoryAbstractService() ->
{2,5,1,2,3}.
distributedOperations() ->
{2,5,1,3,3}.
protocolObjectIdentifiers() ->
{2,5,1,4,3}.
selectedAttributeTypes() ->
{2,5,1,5,3}.
selectedObjectClasses() ->
{2,5,1,6,3}.
authenticationFramework() ->
{2,5,1,7,3}.
algorithmObjectIdentifiers() ->
{2,5,1,8,3}.
directoryObjectIdentifiers() ->
{2,5,1,9,3}.
upperBounds() ->
{2,5,1,10,3}.
dap() ->
{2,5,1,11,3}.
dsp() ->
{2,5,1,12,3}.
distributedDirectoryOIDs() ->
{2,5,1,13,3}.
directoryShadowOIDs() ->
{2,5,1,14,3}.
directoryShadowAbstractService() ->
{2,5,1,15,3}.
disp() ->
{2,5,1,16,3}.
dop() ->
{2,5,1,17,3}.
opBindingManagement() ->
{2,5,1,18,3}.
opBindingOIDs() ->
{2,5,1,19,3}.
hierarchicalOperationalBindings() ->
{2,5,1,20,3}.
dsaOperationalAttributeTypes() ->
{2,5,1,22,3}.
schemaAdministration() ->
{2,5,1,23,3}.
basicAccessControl() ->
{2,5,1,24,3}.
directoryOperationalBindingTypes() ->
{2,5,1,25,3}.
certificateExtensions() ->
{2,5,1,26,0}.
directoryManagement() ->
{2,5,1,27,1}.
enhancedSecurity() ->
{2,5,1,28,1}.
iDMProtocolSpecification() ->
{2,5,1,30,4}.
directoryIDMProtocols() ->
{2,5,1,31,4}.
'id-oc'() ->
{2,5,6}.
'id-at'() ->
{2,5,4}.
'id-as'() ->
{2,5,9}.
'id-mr'() ->
{2,5,13}.
'id-nf'() ->
{2,5,15}.
'id-sc'() ->
{2,5,17}.
'id-oa'() ->
{2,5,18}.
'id-ob'() ->
{2,5,19}.
'id-doa'() ->
{2,5,12}.
'id-kmr'() ->
{2,5,14}.
'id-soc'() ->
{2,5,20}.
'id-soa'() ->
{2,5,21}.
'id-ar'() ->
{2,5,23}.
'id-aca'() ->
{2,5,24}.
'id-ac'() ->
{2,5,3}.
'id-rosObject'() ->
{2,5,25}.
'id-contract'() ->
{2,5,26}.
'id-package'() ->
{2,5,27}.
'id-acScheme'() ->
{2,5,28}.
'id-ce'() ->
{2,5,29}.
'id-mgt'() ->
{2,5,30}.
'id-idm'() ->
{2,5,33}.
'id-avc'() ->
{2,5,31}.
'id-pr'() ->
{2,5,34}.
'id-not'() ->
{2,5,35}.
'id-mre'() ->
{2,5,36}.
'id-cat'() ->
{2,5,37}.
%%%
%%% Run-time functions.
%%%
'dialyzer-suppressions'(Arg) ->
ok.
ber_decode_nif(B) ->
asn1rt_nif:decode_ber_tlv(B).
dec_subidentifiers(<<>>, _Av, Al) ->
lists:reverse(Al);
dec_subidentifiers(<<1:1,H:7,T/binary>>, Av, Al) ->
dec_subidentifiers(T, Av bsl 7 + H, Al);
dec_subidentifiers(<<H,T/binary>>, Av, Al) ->
dec_subidentifiers(T, 0, [Av bsl 7 + H | Al]).
decode_object_identifier(Tlv, Tags) ->
Val = match_tags(Tlv, Tags),
[AddedObjVal | ObjVals] = dec_subidentifiers(Val, 0, []),
{Val1, Val2} =
if
AddedObjVal < 40 ->
{0, AddedObjVal};
AddedObjVal < 80 ->
{1, AddedObjVal - 40};
true ->
{2, AddedObjVal - 80}
end,
list_to_tuple([Val1, Val2 | ObjVals]).
e_object_identifier({'OBJECT IDENTIFIER', V}) ->
e_object_identifier(V);
e_object_identifier(V) when is_tuple(V) ->
e_object_identifier(tuple_to_list(V));
e_object_identifier([E1, E2 | Tail]) ->
Head = 40 * E1 + E2,
{H, Lh} = mk_object_val(Head),
{R, Lr} = lists:mapfoldl(fun enc_obj_id_tail/2, 0, Tail),
{[H | R], Lh + Lr}.
enc_obj_id_tail(H, Len) ->
{B, L} = mk_object_val(H),
{B, Len + L}.
encode_length(L) when L =< 127 ->
{[L], 1};
encode_length(L) ->
Oct = minimum_octets(L),
Len = length(Oct),
if
Len =< 126 ->
{[128 bor Len | Oct], Len + 1};
true ->
exit({error, {asn1, too_long_length_oct, Len}})
end.
encode_object_identifier(Val, TagIn) ->
encode_tags(TagIn, e_object_identifier(Val)).
encode_tags(TagIn, {BytesSoFar, LenSoFar}) ->
encode_tags(TagIn, BytesSoFar, LenSoFar).
encode_tags([Tag | Trest], BytesSoFar, LenSoFar) ->
{Bytes2, L2} = encode_length(LenSoFar),
encode_tags(Trest,
[Tag, Bytes2 | BytesSoFar],
LenSoFar + byte_size(Tag) + L2);
encode_tags([], BytesSoFar, LenSoFar) ->
{BytesSoFar, LenSoFar}.
match_tags({T, V}, [T]) ->
V;
match_tags({T, V}, [T | Tt]) ->
match_tags(V, Tt);
match_tags([{T, V}], [T | Tt]) ->
match_tags(V, Tt);
match_tags([{T, _V} | _] = Vlist, [T]) ->
Vlist;
match_tags(Tlv, []) ->
Tlv;
match_tags({Tag, _V} = Tlv, [T | _Tt]) ->
exit({error, {asn1, {wrong_tag, {{expected, T}, {got, Tag, Tlv}}}}}).
minimum_octets(0, Acc) ->
Acc;
minimum_octets(Val, Acc) ->
minimum_octets(Val bsr 8, [Val band 255 | Acc]).
minimum_octets(Val) ->
minimum_octets(Val, []).
mk_object_val(0, Ack, Len) ->
{Ack, Len};
mk_object_val(Val, Ack, Len) ->
mk_object_val(Val bsr 7, [Val band 127 bor 128 | Ack], Len + 1).
mk_object_val(Val) when Val =< 127 ->
{[255 band Val], 1};
mk_object_val(Val) ->
mk_object_val(Val bsr 7, [Val band 127], 1).