Current section
Files
Jump to
Current section
Files
src/android_key_description.erl
%% Generated by the Erlang ASN.1 BER compiler. Version: 5.0.9
%% Purpose: Encoding and decoding of the types in AndroidKeyDescription.
-module(android_key_description).
-compile(nowarn_unused_vars).
-dialyzer(no_improper_lists).
-include("android_key_description.hrl").
-asn1_info([{vsn,'5.0.9'},
{module,'AndroidKeyDescription'},
{options,[{i,"src"},
noobj,
{outdir,"src"},
{i,"."},
{i,"asn1"}]}]).
-export([encoding_rule/0,maps/0,bit_string_format/0,
legacy_erlang_types/0]).
-export(['dialyzer-suppressions'/1]).
-export([
enc_AndroidKeyDescription/2,
enc_AuthorizationList/2,
enc_RootOfTrust/2
]).
-export([
dec_AndroidKeyDescription/2,
dec_AuthorizationList/2,
dec_RootOfTrust/2
]).
-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('AndroidKeyDescription', Data) -> enc_AndroidKeyDescription(Data);
encode_disp('AuthorizationList', Data) -> enc_AuthorizationList(Data);
encode_disp('RootOfTrust', Data) -> enc_RootOfTrust(Data);
encode_disp(Type, _Data) -> exit({error,{asn1,{undefined_type,Type}}}).
decode_disp('AndroidKeyDescription', Data) -> dec_AndroidKeyDescription(Data);
decode_disp('AuthorizationList', Data) -> dec_AuthorizationList(Data);
decode_disp('RootOfTrust', Data) -> dec_RootOfTrust(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.
%%================================
%% AndroidKeyDescription
%%================================
enc_AndroidKeyDescription(Val) ->
enc_AndroidKeyDescription(Val, [<<48>>]).
enc_AndroidKeyDescription(Val, TagIn) ->
{_,Cindex1,Cindex2,Cindex3,Cindex4,Cindex5} = Val,
%%-------------------------------------------------
%% attribute keymasterVersion(1) with type INTEGER
%%-------------------------------------------------
{EncBytes1,EncLen1} = encode_integer(Cindex1, [<<2>>]),
%%-------------------------------------------------
%% attribute attestationChallenge(2) with type OCTET STRING
%%-------------------------------------------------
{EncBytes2,EncLen2} = encode_restricted_string(Cindex2, [<<4>>]),
%%-------------------------------------------------
%% attribute softwareEnforced(3) External AndroidKeyDescription:AuthorizationList
%%-------------------------------------------------
{EncBytes3,EncLen3} = 'enc_AuthorizationList'(Cindex3, [<<48>>]),
%%-------------------------------------------------
%% attribute teeEnforced(4) External AndroidKeyDescription:AuthorizationList
%%-------------------------------------------------
{EncBytes4,EncLen4} = 'enc_AuthorizationList'(Cindex4, [<<48>>]),
%%-------------------------------------------------
%% attribute uniqueId(5) with type OCTET STRING OPTIONAL
%%-------------------------------------------------
{EncBytes5,EncLen5} = case Cindex5 of
asn1_NOVALUE -> {<<>>,0};
_ ->
encode_restricted_string(Cindex5, [<<4>>])
end,
BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4, EncBytes5],
LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4 + EncLen5,
encode_tags(TagIn, BytesSoFar, LenSoFar).
dec_AndroidKeyDescription(Tlv) ->
dec_AndroidKeyDescription(Tlv, [16]).
dec_AndroidKeyDescription(Tlv, TagIn) ->
%%-------------------------------------------------
%% decode tag and length
%%-------------------------------------------------
Tlv1 = match_tags(Tlv, TagIn),
%%-------------------------------------------------
%% attribute keymasterVersion(1) with type INTEGER
%%-------------------------------------------------
[V1|Tlv2] = Tlv1,
Term1 = decode_integer(V1, [2]),
%%-------------------------------------------------
%% attribute attestationChallenge(2) with type OCTET STRING
%%-------------------------------------------------
[V2|Tlv3] = Tlv2,
Term2 = decode_octet_string(V2, [4]),
%%-------------------------------------------------
%% attribute softwareEnforced(3) External AndroidKeyDescription:AuthorizationList
%%-------------------------------------------------
[V3|Tlv4] = Tlv3,
Term3 = 'dec_AuthorizationList'(V3, [16]),
%%-------------------------------------------------
%% attribute teeEnforced(4) External AndroidKeyDescription:AuthorizationList
%%-------------------------------------------------
[V4|Tlv5] = Tlv4,
Term4 = 'dec_AuthorizationList'(V4, [16]),
%%-------------------------------------------------
%% attribute uniqueId(5) with type OCTET STRING OPTIONAL
%%-------------------------------------------------
{Term5,Tlv6} = case Tlv5 of
[{4,V5}|TempTlv6] ->
{decode_octet_string(V5, []), TempTlv6};
_ ->
{ asn1_NOVALUE, Tlv5}
end,
case Tlv6 of
[] -> true;_ -> exit({error,{asn1, {unexpected,Tlv6}}}) % extra fields not allowed
end,
Res1 = {'AndroidKeyDescription',Term1,Term2,Term3,Term4,Term5},
Res1.
%%================================
%% AuthorizationList
%%================================
enc_AuthorizationList(Val) ->
enc_AuthorizationList(Val, [<<48>>]).
enc_AuthorizationList(Val, TagIn) ->
{_,Cindex1,Cindex2,Cindex3,Cindex4,Cindex5,Cindex6,Cindex7,Cindex8,Cindex9,Cindex10,Cindex11,Cindex12,Cindex13,Cindex14,Cindex15,Cindex16,Cindex17,Cindex18,Cindex19,Cindex20,Cindex21,Cindex22,Cindex23,Cindex24,Cindex25,Cindex26,Cindex27,Cindex28,Cindex29,Cindex30,Cindex31,Cindex32,Cindex33} = Val,
%%-------------------------------------------------
%% attribute purpose(1) with type SET OF OPTIONAL
%%-------------------------------------------------
{EncBytes1,EncLen1} = case Cindex1 of
asn1_NOVALUE -> {<<>>,0};
_ ->
'enc_AuthorizationList_purpose'(Cindex1, [<<49>>,<<161>>])
end,
%%-------------------------------------------------
%% attribute algorithm(2) with type INTEGER OPTIONAL
%%-------------------------------------------------
{EncBytes2,EncLen2} = case Cindex2 of
asn1_NOVALUE -> {<<>>,0};
_ ->
encode_integer(Cindex2, [<<2>>,<<162>>])
end,
%%-------------------------------------------------
%% attribute keySize(3) with type INTEGER OPTIONAL
%%-------------------------------------------------
{EncBytes3,EncLen3} = case Cindex3 of
asn1_NOVALUE -> {<<>>,0};
_ ->
encode_integer(Cindex3, [<<2>>,<<163>>])
end,
%%-------------------------------------------------
%% attribute blockMode(4) with type SET OF OPTIONAL
%%-------------------------------------------------
{EncBytes4,EncLen4} = case Cindex4 of
asn1_NOVALUE -> {<<>>,0};
_ ->
'enc_AuthorizationList_blockMode'(Cindex4, [<<49>>,<<164>>])
end,
%%-------------------------------------------------
%% attribute digest(5) with type SET OF OPTIONAL
%%-------------------------------------------------
{EncBytes5,EncLen5} = case Cindex5 of
asn1_NOVALUE -> {<<>>,0};
_ ->
'enc_AuthorizationList_digest'(Cindex5, [<<49>>,<<165>>])
end,
%%-------------------------------------------------
%% attribute padding(6) with type SET OF OPTIONAL
%%-------------------------------------------------
{EncBytes6,EncLen6} = case Cindex6 of
asn1_NOVALUE -> {<<>>,0};
_ ->
'enc_AuthorizationList_padding'(Cindex6, [<<49>>,<<166>>])
end,
%%-------------------------------------------------
%% attribute callerNonce(7) with type NULL OPTIONAL
%%-------------------------------------------------
{EncBytes7,EncLen7} = case Cindex7 of
asn1_NOVALUE -> {<<>>,0};
_ ->
encode_null(Cindex7, [<<5>>,<<167>>])
end,
%%-------------------------------------------------
%% attribute minMacLength(8) with type INTEGER OPTIONAL
%%-------------------------------------------------
{EncBytes8,EncLen8} = case Cindex8 of
asn1_NOVALUE -> {<<>>,0};
_ ->
encode_integer(Cindex8, [<<2>>,<<168>>])
end,
%%-------------------------------------------------
%% attribute kdf(9) with type SEQUENCE OF OPTIONAL
%%-------------------------------------------------
{EncBytes9,EncLen9} = case Cindex9 of
asn1_NOVALUE -> {<<>>,0};
_ ->
'enc_AuthorizationList_kdf'(Cindex9, [<<48>>,<<169>>])
end,
%%-------------------------------------------------
%% attribute ecCurve(10) with type INTEGER OPTIONAL
%%-------------------------------------------------
{EncBytes10,EncLen10} = case Cindex10 of
asn1_NOVALUE -> {<<>>,0};
_ ->
encode_integer(Cindex10, [<<2>>,<<170>>])
end,
%%-------------------------------------------------
%% attribute rsaPublicExponent(11) with type INTEGER OPTIONAL
%%-------------------------------------------------
{EncBytes11,EncLen11} = case Cindex11 of
asn1_NOVALUE -> {<<>>,0};
_ ->
encode_integer(Cindex11, [<<2>>,<<191,129,72>>])
end,
%%-------------------------------------------------
%% attribute eciesSingleHashMode(12) with type NULL OPTIONAL
%%-------------------------------------------------
{EncBytes12,EncLen12} = case Cindex12 of
asn1_NOVALUE -> {<<>>,0};
_ ->
encode_null(Cindex12, [<<5>>,<<191,129,73>>])
end,
%%-------------------------------------------------
%% attribute includeUniqueId(13) with type NULL OPTIONAL
%%-------------------------------------------------
{EncBytes13,EncLen13} = case Cindex13 of
asn1_NOVALUE -> {<<>>,0};
_ ->
encode_null(Cindex13, [<<5>>,<<191,129,74>>])
end,
%%-------------------------------------------------
%% attribute blobUsageRequirement(14) with type INTEGER OPTIONAL
%%-------------------------------------------------
{EncBytes14,EncLen14} = case Cindex14 of
asn1_NOVALUE -> {<<>>,0};
_ ->
encode_integer(Cindex14, [<<2>>,<<191,130,45>>])
end,
%%-------------------------------------------------
%% attribute bootloaderOnly(15) with type NULL OPTIONAL
%%-------------------------------------------------
{EncBytes15,EncLen15} = case Cindex15 of
asn1_NOVALUE -> {<<>>,0};
_ ->
encode_null(Cindex15, [<<5>>,<<191,130,46>>])
end,
%%-------------------------------------------------
%% attribute activeDateTime(16) with type INTEGER OPTIONAL
%%-------------------------------------------------
{EncBytes16,EncLen16} = case Cindex16 of
asn1_NOVALUE -> {<<>>,0};
_ ->
encode_integer(Cindex16, [<<2>>,<<191,131,16>>])
end,
%%-------------------------------------------------
%% attribute originationExpireDateTime(17) with type INTEGER OPTIONAL
%%-------------------------------------------------
{EncBytes17,EncLen17} = case Cindex17 of
asn1_NOVALUE -> {<<>>,0};
_ ->
encode_integer(Cindex17, [<<2>>,<<191,131,17>>])
end,
%%-------------------------------------------------
%% attribute usageExpireDateTime(18) with type INTEGER OPTIONAL
%%-------------------------------------------------
{EncBytes18,EncLen18} = case Cindex18 of
asn1_NOVALUE -> {<<>>,0};
_ ->
encode_integer(Cindex18, [<<2>>,<<191,131,18>>])
end,
%%-------------------------------------------------
%% attribute minSecondsBetweenOps(19) with type INTEGER OPTIONAL
%%-------------------------------------------------
{EncBytes19,EncLen19} = case Cindex19 of
asn1_NOVALUE -> {<<>>,0};
_ ->
encode_integer(Cindex19, [<<2>>,<<191,131,19>>])
end,
%%-------------------------------------------------
%% attribute maxUsesPerBoot(20) with type INTEGER OPTIONAL
%%-------------------------------------------------
{EncBytes20,EncLen20} = case Cindex20 of
asn1_NOVALUE -> {<<>>,0};
_ ->
encode_integer(Cindex20, [<<2>>,<<191,131,20>>])
end,
%%-------------------------------------------------
%% attribute noAuthRequired(21) with type NULL OPTIONAL
%%-------------------------------------------------
{EncBytes21,EncLen21} = case Cindex21 of
asn1_NOVALUE -> {<<>>,0};
_ ->
encode_null(Cindex21, [<<5>>,<<191,131,119>>])
end,
%%-------------------------------------------------
%% attribute userAuthType(22) with type INTEGER OPTIONAL
%%-------------------------------------------------
{EncBytes22,EncLen22} = case Cindex22 of
asn1_NOVALUE -> {<<>>,0};
_ ->
encode_integer(Cindex22, [<<2>>,<<191,131,120>>])
end,
%%-------------------------------------------------
%% attribute authTimeout(23) with type INTEGER OPTIONAL
%%-------------------------------------------------
{EncBytes23,EncLen23} = case Cindex23 of
asn1_NOVALUE -> {<<>>,0};
_ ->
encode_integer(Cindex23, [<<2>>,<<191,131,121>>])
end,
%%-------------------------------------------------
%% attribute allApplications(24) with type NULL OPTIONAL
%%-------------------------------------------------
{EncBytes24,EncLen24} = case Cindex24 of
asn1_NOVALUE -> {<<>>,0};
_ ->
encode_null(Cindex24, [<<5>>,<<191,132,88>>])
end,
%%-------------------------------------------------
%% attribute applicationId(25) with type OCTET STRING OPTIONAL
%%-------------------------------------------------
{EncBytes25,EncLen25} = case Cindex25 of
asn1_NOVALUE -> {<<>>,0};
_ ->
encode_restricted_string(Cindex25, [<<4>>,<<191,132,89>>])
end,
%%-------------------------------------------------
%% attribute applicationData(26) with type OCTET STRING OPTIONAL
%%-------------------------------------------------
{EncBytes26,EncLen26} = case Cindex26 of
asn1_NOVALUE -> {<<>>,0};
_ ->
encode_restricted_string(Cindex26, [<<4>>,<<191,133,60>>])
end,
%%-------------------------------------------------
%% attribute creationDateTime(27) with type INTEGER OPTIONAL
%%-------------------------------------------------
{EncBytes27,EncLen27} = case Cindex27 of
asn1_NOVALUE -> {<<>>,0};
_ ->
encode_integer(Cindex27, [<<2>>,<<191,133,61>>])
end,
%%-------------------------------------------------
%% attribute origin(28) with type INTEGER OPTIONAL
%%-------------------------------------------------
{EncBytes28,EncLen28} = case Cindex28 of
asn1_NOVALUE -> {<<>>,0};
_ ->
encode_integer(Cindex28, [<<2>>,<<191,133,62>>])
end,
%%-------------------------------------------------
%% attribute rollbackResistant(29) with type NULL OPTIONAL
%%-------------------------------------------------
{EncBytes29,EncLen29} = case Cindex29 of
asn1_NOVALUE -> {<<>>,0};
_ ->
encode_null(Cindex29, [<<5>>,<<191,133,63>>])
end,
%%-------------------------------------------------
%% attribute rootOfTrust(30) External AndroidKeyDescription:RootOfTrust OPTIONAL
%%-------------------------------------------------
{EncBytes30,EncLen30} = case Cindex30 of
asn1_NOVALUE -> {<<>>,0};
_ ->
'enc_RootOfTrust'(Cindex30, [<<48>>,<<191,133,64>>])
end,
%%-------------------------------------------------
%% attribute osVersion(31) with type INTEGER OPTIONAL
%%-------------------------------------------------
{EncBytes31,EncLen31} = case Cindex31 of
asn1_NOVALUE -> {<<>>,0};
_ ->
encode_integer(Cindex31, [<<2>>,<<191,133,65>>])
end,
%%-------------------------------------------------
%% attribute patchLevel(32) with type INTEGER OPTIONAL
%%-------------------------------------------------
{EncBytes32,EncLen32} = case Cindex32 of
asn1_NOVALUE -> {<<>>,0};
_ ->
encode_integer(Cindex32, [<<2>>,<<191,133,66>>])
end,
%%-------------------------------------------------
%% attribute uniqueId(33) with type NULL OPTIONAL
%%-------------------------------------------------
{EncBytes33,EncLen33} = case Cindex33 of
asn1_NOVALUE -> {<<>>,0};
_ ->
encode_null(Cindex33, [<<5>>,<<191,133,67>>])
end,
BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4, EncBytes5, EncBytes6, EncBytes7, EncBytes8, EncBytes9, EncBytes10, EncBytes11, EncBytes12, EncBytes13, EncBytes14, EncBytes15, EncBytes16, EncBytes17, EncBytes18, EncBytes19, EncBytes20, EncBytes21, EncBytes22, EncBytes23, EncBytes24, EncBytes25, EncBytes26, EncBytes27, EncBytes28, EncBytes29, EncBytes30, EncBytes31, EncBytes32, EncBytes33],
LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4 + EncLen5 + EncLen6 + EncLen7 + EncLen8 + EncLen9 + EncLen10 + EncLen11 + EncLen12 + EncLen13 + EncLen14 + EncLen15 + EncLen16 + EncLen17 + EncLen18 + EncLen19 + EncLen20 + EncLen21 + EncLen22 + EncLen23 + EncLen24 + EncLen25 + EncLen26 + EncLen27 + EncLen28 + EncLen29 + EncLen30 + EncLen31 + EncLen32 + EncLen33,
encode_tags(TagIn, BytesSoFar, LenSoFar).
%%================================
%% AuthorizationList_purpose
%%================================
enc_AuthorizationList_purpose(Val, TagIn) ->
{EncBytes,EncLen} = 'enc_AuthorizationList_purpose_components'(Val,[],0),
encode_tags(TagIn, EncBytes, EncLen).
'enc_AuthorizationList_purpose_components'([], AccBytes, AccLen) ->
{lists:reverse(AccBytes),AccLen};
'enc_AuthorizationList_purpose_components'([H|T],AccBytes, AccLen) ->
{EncBytes,EncLen} = encode_integer(H, [<<2>>]),
'enc_AuthorizationList_purpose_components'(T,[EncBytes|AccBytes], AccLen + EncLen).
%%================================
%% AuthorizationList_blockMode
%%================================
enc_AuthorizationList_blockMode(Val, TagIn) ->
{EncBytes,EncLen} = 'enc_AuthorizationList_blockMode_components'(Val,[],0),
encode_tags(TagIn, EncBytes, EncLen).
'enc_AuthorizationList_blockMode_components'([], AccBytes, AccLen) ->
{lists:reverse(AccBytes),AccLen};
'enc_AuthorizationList_blockMode_components'([H|T],AccBytes, AccLen) ->
{EncBytes,EncLen} = encode_integer(H, [<<2>>]),
'enc_AuthorizationList_blockMode_components'(T,[EncBytes|AccBytes], AccLen + EncLen).
%%================================
%% AuthorizationList_digest
%%================================
enc_AuthorizationList_digest(Val, TagIn) ->
{EncBytes,EncLen} = 'enc_AuthorizationList_digest_components'(Val,[],0),
encode_tags(TagIn, EncBytes, EncLen).
'enc_AuthorizationList_digest_components'([], AccBytes, AccLen) ->
{lists:reverse(AccBytes),AccLen};
'enc_AuthorizationList_digest_components'([H|T],AccBytes, AccLen) ->
{EncBytes,EncLen} = encode_integer(H, [<<2>>]),
'enc_AuthorizationList_digest_components'(T,[EncBytes|AccBytes], AccLen + EncLen).
%%================================
%% AuthorizationList_padding
%%================================
enc_AuthorizationList_padding(Val, TagIn) ->
{EncBytes,EncLen} = 'enc_AuthorizationList_padding_components'(Val,[],0),
encode_tags(TagIn, EncBytes, EncLen).
'enc_AuthorizationList_padding_components'([], AccBytes, AccLen) ->
{lists:reverse(AccBytes),AccLen};
'enc_AuthorizationList_padding_components'([H|T],AccBytes, AccLen) ->
{EncBytes,EncLen} = encode_integer(H, [<<2>>]),
'enc_AuthorizationList_padding_components'(T,[EncBytes|AccBytes], AccLen + EncLen).
%%================================
%% AuthorizationList_kdf
%%================================
enc_AuthorizationList_kdf(Val, TagIn) ->
{EncBytes,EncLen} = 'enc_AuthorizationList_kdf_components'(Val,[],0),
encode_tags(TagIn, EncBytes, EncLen).
'enc_AuthorizationList_kdf_components'([], AccBytes, AccLen) ->
{lists:reverse(AccBytes),AccLen};
'enc_AuthorizationList_kdf_components'([H|T],AccBytes, AccLen) ->
{EncBytes,EncLen} = encode_integer(H, [<<2>>]),
'enc_AuthorizationList_kdf_components'(T,[EncBytes|AccBytes], AccLen + EncLen).
dec_AuthorizationList(Tlv) ->
dec_AuthorizationList(Tlv, [16]).
dec_AuthorizationList(Tlv, TagIn) ->
%%-------------------------------------------------
%% decode tag and length
%%-------------------------------------------------
Tlv1 = match_tags(Tlv, TagIn),
%%-------------------------------------------------
%% attribute purpose(1) with type SET OF OPTIONAL
%%-------------------------------------------------
{Term1,Tlv2} = case Tlv1 of
[{131073,V1}|TempTlv2] ->
{'dec_AuthorizationList_purpose'(V1, [17]), TempTlv2};
_ ->
{ asn1_NOVALUE, Tlv1}
end,
%%-------------------------------------------------
%% attribute algorithm(2) with type INTEGER OPTIONAL
%%-------------------------------------------------
{Term2,Tlv3} = case Tlv2 of
[{131074,V2}|TempTlv3] ->
{decode_integer(V2, [2]), TempTlv3};
_ ->
{ asn1_NOVALUE, Tlv2}
end,
%%-------------------------------------------------
%% attribute keySize(3) with type INTEGER OPTIONAL
%%-------------------------------------------------
{Term3,Tlv4} = case Tlv3 of
[{131075,V3}|TempTlv4] ->
{decode_integer(V3, [2]), TempTlv4};
_ ->
{ asn1_NOVALUE, Tlv3}
end,
%%-------------------------------------------------
%% attribute blockMode(4) with type SET OF OPTIONAL
%%-------------------------------------------------
{Term4,Tlv5} = case Tlv4 of
[{131076,V4}|TempTlv5] ->
{'dec_AuthorizationList_blockMode'(V4, [17]), TempTlv5};
_ ->
{ asn1_NOVALUE, Tlv4}
end,
%%-------------------------------------------------
%% attribute digest(5) with type SET OF OPTIONAL
%%-------------------------------------------------
{Term5,Tlv6} = case Tlv5 of
[{131077,V5}|TempTlv6] ->
{'dec_AuthorizationList_digest'(V5, [17]), TempTlv6};
_ ->
{ asn1_NOVALUE, Tlv5}
end,
%%-------------------------------------------------
%% attribute padding(6) with type SET OF OPTIONAL
%%-------------------------------------------------
{Term6,Tlv7} = case Tlv6 of
[{131078,V6}|TempTlv7] ->
{'dec_AuthorizationList_padding'(V6, [17]), TempTlv7};
_ ->
{ asn1_NOVALUE, Tlv6}
end,
%%-------------------------------------------------
%% attribute callerNonce(7) with type NULL OPTIONAL
%%-------------------------------------------------
{Term7,Tlv8} = case Tlv7 of
[{131079,V7}|TempTlv8] ->
{decode_null(V7, [5]), TempTlv8};
_ ->
{ asn1_NOVALUE, Tlv7}
end,
%%-------------------------------------------------
%% attribute minMacLength(8) with type INTEGER OPTIONAL
%%-------------------------------------------------
{Term8,Tlv9} = case Tlv8 of
[{131080,V8}|TempTlv9] ->
{decode_integer(V8, [2]), TempTlv9};
_ ->
{ asn1_NOVALUE, Tlv8}
end,
%%-------------------------------------------------
%% attribute kdf(9) with type SEQUENCE OF OPTIONAL
%%-------------------------------------------------
{Term9,Tlv10} = case Tlv9 of
[{131081,V9}|TempTlv10] ->
{'dec_AuthorizationList_kdf'(V9, [16]), TempTlv10};
_ ->
{ asn1_NOVALUE, Tlv9}
end,
%%-------------------------------------------------
%% attribute ecCurve(10) with type INTEGER OPTIONAL
%%-------------------------------------------------
{Term10,Tlv11} = case Tlv10 of
[{131082,V10}|TempTlv11] ->
{decode_integer(V10, [2]), TempTlv11};
_ ->
{ asn1_NOVALUE, Tlv10}
end,
%%-------------------------------------------------
%% attribute rsaPublicExponent(11) with type INTEGER OPTIONAL
%%-------------------------------------------------
{Term11,Tlv12} = case Tlv11 of
[{131272,V11}|TempTlv12] ->
{decode_integer(V11, [2]), TempTlv12};
_ ->
{ asn1_NOVALUE, Tlv11}
end,
%%-------------------------------------------------
%% attribute eciesSingleHashMode(12) with type NULL OPTIONAL
%%-------------------------------------------------
{Term12,Tlv13} = case Tlv12 of
[{131273,V12}|TempTlv13] ->
{decode_null(V12, [5]), TempTlv13};
_ ->
{ asn1_NOVALUE, Tlv12}
end,
%%-------------------------------------------------
%% attribute includeUniqueId(13) with type NULL OPTIONAL
%%-------------------------------------------------
{Term13,Tlv14} = case Tlv13 of
[{131274,V13}|TempTlv14] ->
{decode_null(V13, [5]), TempTlv14};
_ ->
{ asn1_NOVALUE, Tlv13}
end,
%%-------------------------------------------------
%% attribute blobUsageRequirement(14) with type INTEGER OPTIONAL
%%-------------------------------------------------
{Term14,Tlv15} = case Tlv14 of
[{131373,V14}|TempTlv15] ->
{decode_integer(V14, [2]), TempTlv15};
_ ->
{ asn1_NOVALUE, Tlv14}
end,
%%-------------------------------------------------
%% attribute bootloaderOnly(15) with type NULL OPTIONAL
%%-------------------------------------------------
{Term15,Tlv16} = case Tlv15 of
[{131374,V15}|TempTlv16] ->
{decode_null(V15, [5]), TempTlv16};
_ ->
{ asn1_NOVALUE, Tlv15}
end,
%%-------------------------------------------------
%% attribute activeDateTime(16) with type INTEGER OPTIONAL
%%-------------------------------------------------
{Term16,Tlv17} = case Tlv16 of
[{131472,V16}|TempTlv17] ->
{decode_integer(V16, [2]), TempTlv17};
_ ->
{ asn1_NOVALUE, Tlv16}
end,
%%-------------------------------------------------
%% attribute originationExpireDateTime(17) with type INTEGER OPTIONAL
%%-------------------------------------------------
{Term17,Tlv18} = case Tlv17 of
[{131473,V17}|TempTlv18] ->
{decode_integer(V17, [2]), TempTlv18};
_ ->
{ asn1_NOVALUE, Tlv17}
end,
%%-------------------------------------------------
%% attribute usageExpireDateTime(18) with type INTEGER OPTIONAL
%%-------------------------------------------------
{Term18,Tlv19} = case Tlv18 of
[{131474,V18}|TempTlv19] ->
{decode_integer(V18, [2]), TempTlv19};
_ ->
{ asn1_NOVALUE, Tlv18}
end,
%%-------------------------------------------------
%% attribute minSecondsBetweenOps(19) with type INTEGER OPTIONAL
%%-------------------------------------------------
{Term19,Tlv20} = case Tlv19 of
[{131475,V19}|TempTlv20] ->
{decode_integer(V19, [2]), TempTlv20};
_ ->
{ asn1_NOVALUE, Tlv19}
end,
%%-------------------------------------------------
%% attribute maxUsesPerBoot(20) with type INTEGER OPTIONAL
%%-------------------------------------------------
{Term20,Tlv21} = case Tlv20 of
[{131476,V20}|TempTlv21] ->
{decode_integer(V20, [2]), TempTlv21};
_ ->
{ asn1_NOVALUE, Tlv20}
end,
%%-------------------------------------------------
%% attribute noAuthRequired(21) with type NULL OPTIONAL
%%-------------------------------------------------
{Term21,Tlv22} = case Tlv21 of
[{131575,V21}|TempTlv22] ->
{decode_null(V21, [5]), TempTlv22};
_ ->
{ asn1_NOVALUE, Tlv21}
end,
%%-------------------------------------------------
%% attribute userAuthType(22) with type INTEGER OPTIONAL
%%-------------------------------------------------
{Term22,Tlv23} = case Tlv22 of
[{131576,V22}|TempTlv23] ->
{decode_integer(V22, [2]), TempTlv23};
_ ->
{ asn1_NOVALUE, Tlv22}
end,
%%-------------------------------------------------
%% attribute authTimeout(23) with type INTEGER OPTIONAL
%%-------------------------------------------------
{Term23,Tlv24} = case Tlv23 of
[{131577,V23}|TempTlv24] ->
{decode_integer(V23, [2]), TempTlv24};
_ ->
{ asn1_NOVALUE, Tlv23}
end,
%%-------------------------------------------------
%% attribute allApplications(24) with type NULL OPTIONAL
%%-------------------------------------------------
{Term24,Tlv25} = case Tlv24 of
[{131672,V24}|TempTlv25] ->
{decode_null(V24, [5]), TempTlv25};
_ ->
{ asn1_NOVALUE, Tlv24}
end,
%%-------------------------------------------------
%% attribute applicationId(25) with type OCTET STRING OPTIONAL
%%-------------------------------------------------
{Term25,Tlv26} = case Tlv25 of
[{131673,V25}|TempTlv26] ->
{decode_octet_string(V25, [4]), TempTlv26};
_ ->
{ asn1_NOVALUE, Tlv25}
end,
%%-------------------------------------------------
%% attribute applicationData(26) with type OCTET STRING OPTIONAL
%%-------------------------------------------------
{Term26,Tlv27} = case Tlv26 of
[{131772,V26}|TempTlv27] ->
{decode_octet_string(V26, [4]), TempTlv27};
_ ->
{ asn1_NOVALUE, Tlv26}
end,
%%-------------------------------------------------
%% attribute creationDateTime(27) with type INTEGER OPTIONAL
%%-------------------------------------------------
{Term27,Tlv28} = case Tlv27 of
[{131773,V27}|TempTlv28] ->
{decode_integer(V27, [2]), TempTlv28};
_ ->
{ asn1_NOVALUE, Tlv27}
end,
%%-------------------------------------------------
%% attribute origin(28) with type INTEGER OPTIONAL
%%-------------------------------------------------
{Term28,Tlv29} = case Tlv28 of
[{131774,V28}|TempTlv29] ->
{decode_integer(V28, [2]), TempTlv29};
_ ->
{ asn1_NOVALUE, Tlv28}
end,
%%-------------------------------------------------
%% attribute rollbackResistant(29) with type NULL OPTIONAL
%%-------------------------------------------------
{Term29,Tlv30} = case Tlv29 of
[{131775,V29}|TempTlv30] ->
{decode_null(V29, [5]), TempTlv30};
_ ->
{ asn1_NOVALUE, Tlv29}
end,
%%-------------------------------------------------
%% attribute rootOfTrust(30) External AndroidKeyDescription:RootOfTrust OPTIONAL
%%-------------------------------------------------
{Term30,Tlv31} = case Tlv30 of
[{131776,V30}|TempTlv31] ->
{'dec_RootOfTrust'(V30, [16]), TempTlv31};
_ ->
{ asn1_NOVALUE, Tlv30}
end,
%%-------------------------------------------------
%% attribute osVersion(31) with type INTEGER OPTIONAL
%%-------------------------------------------------
{Term31,Tlv32} = case Tlv31 of
[{131777,V31}|TempTlv32] ->
{decode_integer(V31, [2]), TempTlv32};
_ ->
{ asn1_NOVALUE, Tlv31}
end,
%%-------------------------------------------------
%% attribute patchLevel(32) with type INTEGER OPTIONAL
%%-------------------------------------------------
{Term32,Tlv33} = case Tlv32 of
[{131778,V32}|TempTlv33] ->
{decode_integer(V32, [2]), TempTlv33};
_ ->
{ asn1_NOVALUE, Tlv32}
end,
%%-------------------------------------------------
%% attribute uniqueId(33) with type NULL OPTIONAL
%%-------------------------------------------------
{Term33,Tlv34} = case Tlv33 of
[{131779,V33}|TempTlv34] ->
{decode_null(V33, [5]), TempTlv34};
_ ->
{ asn1_NOVALUE, Tlv33}
end,
case Tlv34 of
[] -> true;_ -> exit({error,{asn1, {unexpected,Tlv34}}}) % extra fields not allowed
end,
Res1 = {'AuthorizationList',Term1,Term2,Term3,Term4,Term5,Term6,Term7,Term8,Term9,Term10,Term11,Term12,Term13,Term14,Term15,Term16,Term17,Term18,Term19,Term20,Term21,Term22,Term23,Term24,Term25,Term26,Term27,Term28,Term29,Term30,Term31,Term32,Term33},
Res1.
'dec_AuthorizationList_purpose'(Tlv, TagIn) ->
%%-------------------------------------------------
%% decode tag and length
%%-------------------------------------------------
Tlv1 = match_tags(Tlv, TagIn),
[decode_integer(V1, [2]) || V1 <- Tlv1].
'dec_AuthorizationList_blockMode'(Tlv, TagIn) ->
%%-------------------------------------------------
%% decode tag and length
%%-------------------------------------------------
Tlv1 = match_tags(Tlv, TagIn),
[decode_integer(V1, [2]) || V1 <- Tlv1].
'dec_AuthorizationList_digest'(Tlv, TagIn) ->
%%-------------------------------------------------
%% decode tag and length
%%-------------------------------------------------
Tlv1 = match_tags(Tlv, TagIn),
[decode_integer(V1, [2]) || V1 <- Tlv1].
'dec_AuthorizationList_padding'(Tlv, TagIn) ->
%%-------------------------------------------------
%% decode tag and length
%%-------------------------------------------------
Tlv1 = match_tags(Tlv, TagIn),
[decode_integer(V1, [2]) || V1 <- Tlv1].
'dec_AuthorizationList_kdf'(Tlv, TagIn) ->
%%-------------------------------------------------
%% decode tag and length
%%-------------------------------------------------
Tlv1 = match_tags(Tlv, TagIn),
[decode_integer(V1, [2]) || V1 <- Tlv1].
%%================================
%% RootOfTrust
%%================================
enc_RootOfTrust(Val) ->
enc_RootOfTrust(Val, [<<48>>]).
enc_RootOfTrust(Val, TagIn) ->
{_,Cindex1,Cindex2,Cindex3} = Val,
%%-------------------------------------------------
%% attribute verifiedBootKey(1) with type OCTET STRING
%%-------------------------------------------------
{EncBytes1,EncLen1} = encode_restricted_string(Cindex1, [<<4>>]),
%%-------------------------------------------------
%% attribute osVersion(2) with type INTEGER
%%-------------------------------------------------
{EncBytes2,EncLen2} = encode_integer(Cindex2, [<<2>>]),
%%-------------------------------------------------
%% attribute patchMonthYear(3) with type INTEGER
%%-------------------------------------------------
{EncBytes3,EncLen3} = encode_integer(Cindex3, [<<2>>]),
BytesSoFar = [EncBytes1, EncBytes2, EncBytes3],
LenSoFar = EncLen1 + EncLen2 + EncLen3,
encode_tags(TagIn, BytesSoFar, LenSoFar).
dec_RootOfTrust(Tlv) ->
dec_RootOfTrust(Tlv, [16]).
dec_RootOfTrust(Tlv, TagIn) ->
%%-------------------------------------------------
%% decode tag and length
%%-------------------------------------------------
Tlv1 = match_tags(Tlv, TagIn),
%%-------------------------------------------------
%% attribute verifiedBootKey(1) with type OCTET STRING
%%-------------------------------------------------
[V1|Tlv2] = Tlv1,
Term1 = decode_octet_string(V1, [4]),
%%-------------------------------------------------
%% attribute osVersion(2) with type INTEGER
%%-------------------------------------------------
[V2|Tlv3] = Tlv2,
Term2 = decode_integer(V2, [2]),
%%-------------------------------------------------
%% attribute patchMonthYear(3) with type INTEGER
%%-------------------------------------------------
[V3|Tlv4] = Tlv3,
Term3 = decode_integer(V3, [2]),
case Tlv4 of
[] -> true;_ -> exit({error,{asn1, {unexpected,Tlv4}}}) % extra fields not allowed
end,
Res1 = {'RootOfTrust',Term1,Term2,Term3},
Res1.
%%%
%%% Run-time functions.
%%%
'dialyzer-suppressions'(Arg) ->
ok.
ber_decode_nif(B) ->
asn1rt_nif:decode_ber_tlv(B).
collect_parts(TlvList) ->
collect_parts(TlvList, []).
collect_parts([{_, L} | Rest], Acc) when is_list(L) ->
collect_parts(Rest, [collect_parts(L) | Acc]);
collect_parts([{3, <<Unused,Bits/binary>>} | Rest], _Acc) ->
collect_parts_bit(Rest, [Bits], Unused);
collect_parts([{_T, V} | Rest], Acc) ->
collect_parts(Rest, [V | Acc]);
collect_parts([], Acc) ->
list_to_binary(lists:reverse(Acc)).
collect_parts_bit([{3, <<Unused,Bits/binary>>} | Rest], Acc, Uacc) ->
collect_parts_bit(Rest, [Bits | Acc], Unused + Uacc);
collect_parts_bit([], Acc, Uacc) ->
list_to_binary([Uacc | lists:reverse(Acc)]).
decode_integer(Tlv, TagIn) ->
Bin = match_tags(Tlv, TagIn),
Len = byte_size(Bin),
<<Int:Len/signed-unit:8>> = Bin,
Int.
decode_null(Tlv, Tags) ->
Val = match_tags(Tlv, Tags),
case Val of
<<>> ->
'NULL';
_ ->
exit({error, {asn1, {decode_null, Val}}})
end.
decode_octet_string(Tlv, TagsIn) ->
Bin = match_and_collect(Tlv, TagsIn),
binary:copy(Bin).
encode_integer(Val) ->
Bytes =
if
Val >= 0 ->
encode_integer_pos(Val, []);
true ->
encode_integer_neg(Val, [])
end,
{Bytes, length(Bytes)}.
encode_integer(Val, Tag) when is_integer(Val) ->
encode_tags(Tag, encode_integer(Val));
encode_integer(Val, _Tag) ->
exit({error, {asn1, {encode_integer, Val}}}).
encode_integer_neg(- 1, [B1 | _T] = L) when B1 > 127 ->
L;
encode_integer_neg(N, Acc) ->
encode_integer_neg(N bsr 8, [N band 255 | Acc]).
encode_integer_pos(0, [B | _Acc] = L) when B < 128 ->
L;
encode_integer_pos(N, Acc) ->
encode_integer_pos(N bsr 8, [N band 255 | Acc]).
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_null(_Val, TagIn) ->
encode_tags(TagIn, [], 0).
encode_restricted_string(OctetList, TagIn) when is_binary(OctetList) ->
encode_tags(TagIn, OctetList, byte_size(OctetList));
encode_restricted_string(OctetList, TagIn) when is_list(OctetList) ->
encode_tags(TagIn, OctetList, length(OctetList)).
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_and_collect(Tlv, TagsIn) ->
Val = match_tags(Tlv, TagsIn),
case Val of
[_ | _] = PartList ->
collect_parts(PartList);
Bin when is_binary(Bin) ->
Bin
end.
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, []).