%% Generated by the Erlang ASN.1 BER compiler. Version: 5.4.3 %% Purpose: Encoding and decoding of the types in KRB5. -module('KRB5'). -moduledoc false. -compile(nowarn_unused_vars). -dialyzer(no_improper_lists). -dialyzer(no_match). -include("KRB5.hrl"). -asn1_info([{vsn,'5.4.3'}, {module,'KRB5'}, {options,[{i,"/home/alex/dev/kerlberos/asngen"}, ber, {outdir,"/home/alex/dev/kerlberos/asngen"}, ber,der,undec_rest, {i,"."}, {i,"/home/alex/dev/kerlberos/asn1"}]}]). -export([encoding_rule/0,maps/0,bit_string_format/0, legacy_erlang_types/0]). -export(['dialyzer-suppressions'/1]). -export([ enc_Int32/2, enc_UInt32/2, enc_Microseconds/2, enc_KerberosString/2, enc_Realm/2, enc_PrincipalName/2, enc_KerberosTime/2, enc_HostAddress/2, enc_HostAddresses/2, enc_AuthorizationData/2, 'enc_PA-DATA'/2, enc_KerberosFlags/2, enc_EncryptedData/2, enc_EncryptionKey/2, enc_Checksum/2, enc_Ticket/2, enc_EncTicketPart/2, enc_TransitedEncoding/2, enc_TicketFlags/2, 'enc_AS-REQ'/2, 'enc_TGS-REQ'/2, 'enc_KDC-REQ'/2, 'enc_KDC-REQ-BODY'/2, enc_KDCOptions/2, 'enc_AS-REP'/2, 'enc_TGS-REP'/2, 'enc_KDC-REP'/2, enc_EncASRepPart/2, enc_EncTGSRepPart/2, enc_EncKDCRepPart/2, enc_LastReq/2, 'enc_AP-REQ'/2, enc_APOptions/2, enc_Authenticator/2, 'enc_AP-REP'/2, enc_EncAPRepPart/2, 'enc_KRB-SAFE'/2, 'enc_KRB-SAFE-BODY'/2, 'enc_KRB-PRIV'/2, enc_EncKrbPrivPart/2, 'enc_KRB-CRED'/2, enc_EncKrbCredPart/2, enc_KrbCredInfo/2, 'enc_KRB-ERROR'/2, 'enc_METHOD-DATA'/2, 'enc_TYPED-DATA'/2, 'enc_PA-ENC-TIMESTAMP'/2, 'enc_PA-ENC-TS-ENC'/2, 'enc_ETYPE-INFO-ENTRY'/2, 'enc_ETYPE-INFO'/2, 'enc_ETYPE-INFO2-ENTRY'/2, 'enc_ETYPE-INFO2'/2, 'enc_AD-IF-RELEVANT'/2, 'enc_AD-KDCIssued'/2, 'enc_AD-AND-OR'/2, 'enc_AD-MANDATORY-FOR-KDC'/2, 'enc_PA-PAC-REQUEST'/2 ]). -export([ dec_Int32/2, dec_UInt32/2, dec_Microseconds/2, dec_KerberosString/2, dec_Realm/2, dec_PrincipalName/2, dec_KerberosTime/2, dec_HostAddress/2, dec_HostAddresses/2, dec_AuthorizationData/2, 'dec_PA-DATA'/2, dec_KerberosFlags/2, dec_EncryptedData/2, dec_EncryptionKey/2, dec_Checksum/2, dec_Ticket/2, dec_EncTicketPart/2, dec_TransitedEncoding/2, dec_TicketFlags/2, 'dec_AS-REQ'/2, 'dec_TGS-REQ'/2, 'dec_KDC-REQ'/2, 'dec_KDC-REQ-BODY'/2, dec_KDCOptions/2, 'dec_AS-REP'/2, 'dec_TGS-REP'/2, 'dec_KDC-REP'/2, dec_EncASRepPart/2, dec_EncTGSRepPart/2, dec_EncKDCRepPart/2, dec_LastReq/2, 'dec_AP-REQ'/2, dec_APOptions/2, dec_Authenticator/2, 'dec_AP-REP'/2, dec_EncAPRepPart/2, 'dec_KRB-SAFE'/2, 'dec_KRB-SAFE-BODY'/2, 'dec_KRB-PRIV'/2, dec_EncKrbPrivPart/2, 'dec_KRB-CRED'/2, dec_EncKrbCredPart/2, dec_KrbCredInfo/2, 'dec_KRB-ERROR'/2, 'dec_METHOD-DATA'/2, 'dec_TYPED-DATA'/2, 'dec_PA-ENC-TIMESTAMP'/2, 'dec_PA-ENC-TS-ENC'/2, 'dec_ETYPE-INFO-ENTRY'/2, 'dec_ETYPE-INFO'/2, 'dec_ETYPE-INFO2-ENTRY'/2, 'dec_ETYPE-INFO2'/2, 'dec_AD-IF-RELEVANT'/2, 'dec_AD-KDCIssued'/2, 'dec_AD-AND-OR'/2, 'dec_AD-MANDATORY-FOR-KDC'/2, 'dec_PA-PAC-REQUEST'/2 ]). -export([ 'id-krb5'/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, Data0) -> try {Data,Rest} = ber_decode_nif(Data0), Result = decode_disp(Type, Data), {ok,Result,Rest} 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('Int32', Data) -> enc_Int32(Data); encode_disp('UInt32', Data) -> enc_UInt32(Data); encode_disp('Microseconds', Data) -> enc_Microseconds(Data); encode_disp('KerberosString', Data) -> enc_KerberosString(Data); encode_disp('Realm', Data) -> enc_Realm(Data); encode_disp('PrincipalName', Data) -> enc_PrincipalName(Data); encode_disp('KerberosTime', Data) -> enc_KerberosTime(Data); encode_disp('HostAddress', Data) -> enc_HostAddress(Data); encode_disp('HostAddresses', Data) -> enc_HostAddresses(Data); encode_disp('AuthorizationData', Data) -> enc_AuthorizationData(Data); encode_disp('PA-DATA', Data) -> 'enc_PA-DATA'(Data); encode_disp('KerberosFlags', Data) -> enc_KerberosFlags(Data); encode_disp('EncryptedData', Data) -> enc_EncryptedData(Data); encode_disp('EncryptionKey', Data) -> enc_EncryptionKey(Data); encode_disp('Checksum', Data) -> enc_Checksum(Data); encode_disp('Ticket', Data) -> enc_Ticket(Data); encode_disp('EncTicketPart', Data) -> enc_EncTicketPart(Data); encode_disp('TransitedEncoding', Data) -> enc_TransitedEncoding(Data); encode_disp('TicketFlags', Data) -> enc_TicketFlags(Data); encode_disp('AS-REQ', Data) -> 'enc_AS-REQ'(Data); encode_disp('TGS-REQ', Data) -> 'enc_TGS-REQ'(Data); encode_disp('KDC-REQ', Data) -> 'enc_KDC-REQ'(Data); encode_disp('KDC-REQ-BODY', Data) -> 'enc_KDC-REQ-BODY'(Data); encode_disp('KDCOptions', Data) -> enc_KDCOptions(Data); encode_disp('AS-REP', Data) -> 'enc_AS-REP'(Data); encode_disp('TGS-REP', Data) -> 'enc_TGS-REP'(Data); encode_disp('KDC-REP', Data) -> 'enc_KDC-REP'(Data); encode_disp('EncASRepPart', Data) -> enc_EncASRepPart(Data); encode_disp('EncTGSRepPart', Data) -> enc_EncTGSRepPart(Data); encode_disp('EncKDCRepPart', Data) -> enc_EncKDCRepPart(Data); encode_disp('LastReq', Data) -> enc_LastReq(Data); encode_disp('AP-REQ', Data) -> 'enc_AP-REQ'(Data); encode_disp('APOptions', Data) -> enc_APOptions(Data); encode_disp('Authenticator', Data) -> enc_Authenticator(Data); encode_disp('AP-REP', Data) -> 'enc_AP-REP'(Data); encode_disp('EncAPRepPart', Data) -> enc_EncAPRepPart(Data); encode_disp('KRB-SAFE', Data) -> 'enc_KRB-SAFE'(Data); encode_disp('KRB-SAFE-BODY', Data) -> 'enc_KRB-SAFE-BODY'(Data); encode_disp('KRB-PRIV', Data) -> 'enc_KRB-PRIV'(Data); encode_disp('EncKrbPrivPart', Data) -> enc_EncKrbPrivPart(Data); encode_disp('KRB-CRED', Data) -> 'enc_KRB-CRED'(Data); encode_disp('EncKrbCredPart', Data) -> enc_EncKrbCredPart(Data); encode_disp('KrbCredInfo', Data) -> enc_KrbCredInfo(Data); encode_disp('KRB-ERROR', Data) -> 'enc_KRB-ERROR'(Data); encode_disp('METHOD-DATA', Data) -> 'enc_METHOD-DATA'(Data); encode_disp('TYPED-DATA', Data) -> 'enc_TYPED-DATA'(Data); encode_disp('PA-ENC-TIMESTAMP', Data) -> 'enc_PA-ENC-TIMESTAMP'(Data); encode_disp('PA-ENC-TS-ENC', Data) -> 'enc_PA-ENC-TS-ENC'(Data); encode_disp('ETYPE-INFO-ENTRY', Data) -> 'enc_ETYPE-INFO-ENTRY'(Data); encode_disp('ETYPE-INFO', Data) -> 'enc_ETYPE-INFO'(Data); encode_disp('ETYPE-INFO2-ENTRY', Data) -> 'enc_ETYPE-INFO2-ENTRY'(Data); encode_disp('ETYPE-INFO2', Data) -> 'enc_ETYPE-INFO2'(Data); encode_disp('AD-IF-RELEVANT', Data) -> 'enc_AD-IF-RELEVANT'(Data); encode_disp('AD-KDCIssued', Data) -> 'enc_AD-KDCIssued'(Data); encode_disp('AD-AND-OR', Data) -> 'enc_AD-AND-OR'(Data); encode_disp('AD-MANDATORY-FOR-KDC', Data) -> 'enc_AD-MANDATORY-FOR-KDC'(Data); encode_disp('PA-PAC-REQUEST', Data) -> 'enc_PA-PAC-REQUEST'(Data); encode_disp(Type, _Data) -> exit({error,{asn1,{undefined_type,Type}}}). decode_disp('Int32', Data) -> dec_Int32(Data); decode_disp('UInt32', Data) -> dec_UInt32(Data); decode_disp('Microseconds', Data) -> dec_Microseconds(Data); decode_disp('KerberosString', Data) -> dec_KerberosString(Data); decode_disp('Realm', Data) -> dec_Realm(Data); decode_disp('PrincipalName', Data) -> dec_PrincipalName(Data); decode_disp('KerberosTime', Data) -> dec_KerberosTime(Data); decode_disp('HostAddress', Data) -> dec_HostAddress(Data); decode_disp('HostAddresses', Data) -> dec_HostAddresses(Data); decode_disp('AuthorizationData', Data) -> dec_AuthorizationData(Data); decode_disp('PA-DATA', Data) -> 'dec_PA-DATA'(Data); decode_disp('KerberosFlags', Data) -> dec_KerberosFlags(Data); decode_disp('EncryptedData', Data) -> dec_EncryptedData(Data); decode_disp('EncryptionKey', Data) -> dec_EncryptionKey(Data); decode_disp('Checksum', Data) -> dec_Checksum(Data); decode_disp('Ticket', Data) -> dec_Ticket(Data); decode_disp('EncTicketPart', Data) -> dec_EncTicketPart(Data); decode_disp('TransitedEncoding', Data) -> dec_TransitedEncoding(Data); decode_disp('TicketFlags', Data) -> dec_TicketFlags(Data); decode_disp('AS-REQ', Data) -> 'dec_AS-REQ'(Data); decode_disp('TGS-REQ', Data) -> 'dec_TGS-REQ'(Data); decode_disp('KDC-REQ', Data) -> 'dec_KDC-REQ'(Data); decode_disp('KDC-REQ-BODY', Data) -> 'dec_KDC-REQ-BODY'(Data); decode_disp('KDCOptions', Data) -> dec_KDCOptions(Data); decode_disp('AS-REP', Data) -> 'dec_AS-REP'(Data); decode_disp('TGS-REP', Data) -> 'dec_TGS-REP'(Data); decode_disp('KDC-REP', Data) -> 'dec_KDC-REP'(Data); decode_disp('EncASRepPart', Data) -> dec_EncASRepPart(Data); decode_disp('EncTGSRepPart', Data) -> dec_EncTGSRepPart(Data); decode_disp('EncKDCRepPart', Data) -> dec_EncKDCRepPart(Data); decode_disp('LastReq', Data) -> dec_LastReq(Data); decode_disp('AP-REQ', Data) -> 'dec_AP-REQ'(Data); decode_disp('APOptions', Data) -> dec_APOptions(Data); decode_disp('Authenticator', Data) -> dec_Authenticator(Data); decode_disp('AP-REP', Data) -> 'dec_AP-REP'(Data); decode_disp('EncAPRepPart', Data) -> dec_EncAPRepPart(Data); decode_disp('KRB-SAFE', Data) -> 'dec_KRB-SAFE'(Data); decode_disp('KRB-SAFE-BODY', Data) -> 'dec_KRB-SAFE-BODY'(Data); decode_disp('KRB-PRIV', Data) -> 'dec_KRB-PRIV'(Data); decode_disp('EncKrbPrivPart', Data) -> dec_EncKrbPrivPart(Data); decode_disp('KRB-CRED', Data) -> 'dec_KRB-CRED'(Data); decode_disp('EncKrbCredPart', Data) -> dec_EncKrbCredPart(Data); decode_disp('KrbCredInfo', Data) -> dec_KrbCredInfo(Data); decode_disp('KRB-ERROR', Data) -> 'dec_KRB-ERROR'(Data); decode_disp('METHOD-DATA', Data) -> 'dec_METHOD-DATA'(Data); decode_disp('TYPED-DATA', Data) -> 'dec_TYPED-DATA'(Data); decode_disp('PA-ENC-TIMESTAMP', Data) -> 'dec_PA-ENC-TIMESTAMP'(Data); decode_disp('PA-ENC-TS-ENC', Data) -> 'dec_PA-ENC-TS-ENC'(Data); decode_disp('ETYPE-INFO-ENTRY', Data) -> 'dec_ETYPE-INFO-ENTRY'(Data); decode_disp('ETYPE-INFO', Data) -> 'dec_ETYPE-INFO'(Data); decode_disp('ETYPE-INFO2-ENTRY', Data) -> 'dec_ETYPE-INFO2-ENTRY'(Data); decode_disp('ETYPE-INFO2', Data) -> 'dec_ETYPE-INFO2'(Data); decode_disp('AD-IF-RELEVANT', Data) -> 'dec_AD-IF-RELEVANT'(Data); decode_disp('AD-KDCIssued', Data) -> 'dec_AD-KDCIssued'(Data); decode_disp('AD-AND-OR', Data) -> 'dec_AD-AND-OR'(Data); decode_disp('AD-MANDATORY-FOR-KDC', Data) -> 'dec_AD-MANDATORY-FOR-KDC'(Data); decode_disp('PA-PAC-REQUEST', Data) -> 'dec_PA-PAC-REQUEST'(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. %%================================ %% Int32 %%================================ enc_Int32(Val) -> enc_Int32(Val, [<<2>>]). enc_Int32(Val, TagIn) -> encode_integer(Val, TagIn). dec_Int32(Tlv) -> dec_Int32(Tlv, [2]). dec_Int32(Tlv, TagIn) -> begin Val1 = decode_integer(Tlv, TagIn), if -2147483648 =< Val1, Val1 =< 2147483647 -> Val1; true -> exit({error,{asn1,bad_range}}) end end. %%================================ %% UInt32 %%================================ enc_UInt32(Val) -> enc_UInt32(Val, [<<2>>]). enc_UInt32(Val, TagIn) -> encode_integer(Val, TagIn). dec_UInt32(Tlv) -> dec_UInt32(Tlv, [2]). dec_UInt32(Tlv, TagIn) -> begin Val1 = decode_integer(Tlv, TagIn), if 0 =< Val1, Val1 =< 4294967295 -> Val1; true -> exit({error,{asn1,bad_range}}) end end. %%================================ %% Microseconds %%================================ enc_Microseconds(Val) -> enc_Microseconds(Val, [<<2>>]). enc_Microseconds(Val, TagIn) -> encode_integer(Val, TagIn). dec_Microseconds(Tlv) -> dec_Microseconds(Tlv, [2]). dec_Microseconds(Tlv, TagIn) -> begin Val1 = decode_integer(Tlv, TagIn), if 0 =< Val1, Val1 =< 999999 -> Val1; true -> exit({error,{asn1,bad_range}}) end end. %%================================ %% KerberosString %%================================ enc_KerberosString(Val) -> enc_KerberosString(Val, [<<27>>]). enc_KerberosString(Val, TagIn) -> encode_restricted_string(Val, TagIn). dec_KerberosString(Tlv) -> dec_KerberosString(Tlv, [27]). dec_KerberosString(Tlv, TagIn) -> begin binary_to_list(decode_restricted_string(Tlv, TagIn)) end . %%================================ %% Realm %%================================ enc_Realm(Val) -> enc_Realm(Val, [<<27>>]). enc_Realm(Val, TagIn) -> encode_restricted_string(Val, TagIn). dec_Realm(Tlv) -> dec_Realm(Tlv, [27]). dec_Realm(Tlv, TagIn) -> begin binary_to_list(decode_restricted_string(Tlv, TagIn)) end . %%================================ %% PrincipalName %%================================ enc_PrincipalName(Val) -> enc_PrincipalName(Val, [<<48>>]). enc_PrincipalName(Val, TagIn) -> {_,Cindex1,Cindex2} = Val, %%------------------------------------------------- %% attribute name-type(1) with type INTEGER %%------------------------------------------------- {EncBytes1,EncLen1} = encode_integer(Cindex1, [<<2>>,<<160>>]), %%------------------------------------------------- %% attribute name-string(2) with type SEQUENCE OF %%------------------------------------------------- {EncBytes2,EncLen2} = 'enc_PrincipalName_name-string'(Cindex2, [<<48>>,<<161>>]), BytesSoFar = [EncBytes1, EncBytes2], LenSoFar = EncLen1 + EncLen2, encode_tags(TagIn, BytesSoFar, LenSoFar). %%================================ %% PrincipalName_name-string %%================================ 'enc_PrincipalName_name-string'(Val, TagIn) -> {EncBytes,EncLen} = 'enc_PrincipalName_name-string_components'(Val,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_PrincipalName_name-string_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_PrincipalName_name-string_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = encode_restricted_string(H, [<<27>>]), 'enc_PrincipalName_name-string_components'(T,[EncBytes|AccBytes], AccLen + EncLen). dec_PrincipalName(Tlv) -> dec_PrincipalName(Tlv, [16]). dec_PrincipalName(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute name-type(1) with type INTEGER %%------------------------------------------------- [V1|Tlv2] = Tlv1, Term1 = begin Val1 = decode_integer(V1, [131072,2]), if -2147483648 =< Val1, Val1 =< 2147483647 -> Val1; true -> exit({error,{asn1,bad_range}}) end end, %%------------------------------------------------- %% attribute name-string(2) with type SEQUENCE OF %%------------------------------------------------- [V2|Tlv3] = Tlv2, Term2 = 'dec_PrincipalName_name-string'(V2, [131073,16]), case Tlv3 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv3}}}) % extra fields not allowed end, Res1 = {'PrincipalName',Term1,Term2}, Res1. 'dec_PrincipalName_name-string'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), [begin binary_to_list(decode_restricted_string(V1, [27])) end || V1 <- Tlv1]. %%================================ %% KerberosTime %%================================ enc_KerberosTime(Val) -> enc_KerberosTime(Val, [<<24>>]). enc_KerberosTime(Val, TagIn) -> encode_restricted_string(Val, TagIn). dec_KerberosTime(Tlv) -> dec_KerberosTime(Tlv, [24]). dec_KerberosTime(Tlv, TagIn) -> begin binary_to_list(decode_restricted_string(Tlv, TagIn)) end . %%================================ %% HostAddress %%================================ enc_HostAddress(Val) -> enc_HostAddress(Val, [<<48>>]). enc_HostAddress(Val, TagIn) -> {_,Cindex1,Cindex2} = Val, %%------------------------------------------------- %% attribute addr-type(1) with type INTEGER %%------------------------------------------------- {EncBytes1,EncLen1} = encode_integer(Cindex1, [<<2>>,<<160>>]), %%------------------------------------------------- %% attribute address(2) with type OCTET STRING %%------------------------------------------------- {EncBytes2,EncLen2} = encode_restricted_string(Cindex2, [<<4>>,<<161>>]), BytesSoFar = [EncBytes1, EncBytes2], LenSoFar = EncLen1 + EncLen2, encode_tags(TagIn, BytesSoFar, LenSoFar). dec_HostAddress(Tlv) -> dec_HostAddress(Tlv, [16]). dec_HostAddress(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute addr-type(1) with type INTEGER %%------------------------------------------------- [V1|Tlv2] = Tlv1, Term1 = begin Val1 = decode_integer(V1, [131072,2]), if -2147483648 =< Val1, Val1 =< 2147483647 -> Val1; true -> exit({error,{asn1,bad_range}}) end end, %%------------------------------------------------- %% attribute address(2) with type OCTET STRING %%------------------------------------------------- [V2|Tlv3] = Tlv2, Term2 = decode_octet_string(V2, [131073,4]), case Tlv3 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv3}}}) % extra fields not allowed end, Res1 = {'HostAddress',Term1,Term2}, Res1. %%================================ %% HostAddresses %%================================ enc_HostAddresses(Val) -> enc_HostAddresses(Val, [<<48>>]). enc_HostAddresses(Val, TagIn) -> {EncBytes,EncLen} = 'enc_HostAddresses_components'(Val,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_HostAddresses_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_HostAddresses_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = 'enc_HostAddress'(H, [<<48>>]), 'enc_HostAddresses_components'(T,[EncBytes|AccBytes], AccLen + EncLen). dec_HostAddresses(Tlv) -> dec_HostAddresses(Tlv, [16]). dec_HostAddresses(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), ['dec_HostAddress'(V1, [16]) || V1 <- Tlv1]. %%================================ %% AuthorizationData %%================================ enc_AuthorizationData(Val) -> enc_AuthorizationData(Val, [<<48>>]). enc_AuthorizationData(Val, TagIn) -> {EncBytes,EncLen} = 'enc_AuthorizationData_components'(Val,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_AuthorizationData_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_AuthorizationData_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = 'enc_AuthorizationData_SEQOF'(H, [<<48>>]), 'enc_AuthorizationData_components'(T,[EncBytes|AccBytes], AccLen + EncLen). %%================================ %% AuthorizationData_SEQOF %%================================ enc_AuthorizationData_SEQOF(Val, TagIn) -> {_,Cindex1,Cindex2} = Val, %%------------------------------------------------- %% attribute ad-type(1) with type INTEGER %%------------------------------------------------- {EncBytes1,EncLen1} = encode_integer(Cindex1, [<<2>>,<<160>>]), %%------------------------------------------------- %% attribute ad-data(2) with type OCTET STRING %%------------------------------------------------- {EncBytes2,EncLen2} = encode_restricted_string(Cindex2, [<<4>>,<<161>>]), BytesSoFar = [EncBytes1, EncBytes2], LenSoFar = EncLen1 + EncLen2, encode_tags(TagIn, BytesSoFar, LenSoFar). dec_AuthorizationData(Tlv) -> dec_AuthorizationData(Tlv, [16]). dec_AuthorizationData(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), ['dec_AuthorizationData_SEQOF'(V1, [16]) || V1 <- Tlv1]. 'dec_AuthorizationData_SEQOF'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute ad-type(1) with type INTEGER %%------------------------------------------------- [V1|Tlv2] = Tlv1, Term1 = begin Val1 = decode_integer(V1, [131072,2]), if -2147483648 =< Val1, Val1 =< 2147483647 -> Val1; true -> exit({error,{asn1,bad_range}}) end end, %%------------------------------------------------- %% attribute ad-data(2) with type OCTET STRING %%------------------------------------------------- [V2|Tlv3] = Tlv2, Term2 = decode_octet_string(V2, [131073,4]), case Tlv3 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv3}}}) % extra fields not allowed end, Res1 = {'AuthorizationData_SEQOF',Term1,Term2}, Res1. %%================================ %% PA-DATA %%================================ 'enc_PA-DATA'(Val) -> 'enc_PA-DATA'(Val, [<<48>>]). 'enc_PA-DATA'(Val, TagIn) -> {_,Cindex1,Cindex2} = Val, %%------------------------------------------------- %% attribute padata-type(1) with type INTEGER %%------------------------------------------------- {EncBytes1,EncLen1} = encode_integer(Cindex1, [<<2>>,<<161>>]), %%------------------------------------------------- %% attribute padata-value(2) with type OCTET STRING %%------------------------------------------------- {EncBytes2,EncLen2} = encode_restricted_string(Cindex2, [<<4>>,<<162>>]), BytesSoFar = [EncBytes1, EncBytes2], LenSoFar = EncLen1 + EncLen2, encode_tags(TagIn, BytesSoFar, LenSoFar). 'dec_PA-DATA'(Tlv) -> 'dec_PA-DATA'(Tlv, [16]). 'dec_PA-DATA'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute padata-type(1) with type INTEGER %%------------------------------------------------- [V1|Tlv2] = Tlv1, Term1 = begin Val1 = decode_integer(V1, [131073,2]), if -2147483648 =< Val1, Val1 =< 2147483647 -> Val1; true -> exit({error,{asn1,bad_range}}) end end, %%------------------------------------------------- %% attribute padata-value(2) with type OCTET STRING %%------------------------------------------------- [V2|Tlv3] = Tlv2, Term2 = decode_octet_string(V2, [131074,4]), case Tlv3 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv3}}}) % extra fields not allowed end, Res1 = {'PA-DATA',Term1,Term2}, Res1. %%================================ %% KerberosFlags %%================================ enc_KerberosFlags(Val) -> enc_KerberosFlags(Val, [<<3>>]). enc_KerberosFlags(Val, TagIn) -> encode_unnamed_bit_string(Val, TagIn). dec_KerberosFlags(Tlv) -> dec_KerberosFlags(Tlv, [3]). dec_KerberosFlags(Tlv, TagIn) -> begin Val1 = decode_native_bit_string(Tlv, TagIn), C1 = bit_size(Val1), if 32 =< C1, C1 =< 'MAX' -> Val1; true -> exit({error,{asn1,bad_range}}) end end. %%================================ %% EncryptedData %%================================ enc_EncryptedData(Val) -> enc_EncryptedData(Val, [<<48>>]). enc_EncryptedData(Val, TagIn) -> {_,Cindex1,Cindex2,Cindex3} = Val, %%------------------------------------------------- %% attribute etype(1) with type INTEGER %%------------------------------------------------- {EncBytes1,EncLen1} = encode_integer(Cindex1, [<<2>>,<<160>>]), %%------------------------------------------------- %% attribute kvno(2) with type INTEGER OPTIONAL %%------------------------------------------------- {EncBytes2,EncLen2} = case Cindex2 of asn1_NOVALUE -> {<<>>,0}; _ -> encode_integer(Cindex2, [<<2>>,<<161>>]) end, %%------------------------------------------------- %% attribute cipher(3) with type OCTET STRING %%------------------------------------------------- {EncBytes3,EncLen3} = encode_restricted_string(Cindex3, [<<4>>,<<162>>]), BytesSoFar = [EncBytes1, EncBytes2, EncBytes3], LenSoFar = EncLen1 + EncLen2 + EncLen3, encode_tags(TagIn, BytesSoFar, LenSoFar). dec_EncryptedData(Tlv) -> dec_EncryptedData(Tlv, [16]). dec_EncryptedData(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute etype(1) with type INTEGER %%------------------------------------------------- [V1|Tlv2] = Tlv1, Term1 = begin Val1 = decode_integer(V1, [131072,2]), if -2147483648 =< Val1, Val1 =< 2147483647 -> Val1; true -> exit({error,{asn1,bad_range}}) end end, %%------------------------------------------------- %% attribute kvno(2) with type INTEGER OPTIONAL %%------------------------------------------------- {Term2,Tlv3} = case Tlv2 of [{131073,V2}|TempTlv3] -> {begin Val2 = decode_integer(V2, [2]), if 0 =< Val2, Val2 =< 4294967295 -> Val2; true -> exit({error,{asn1,bad_range}}) end end, TempTlv3}; _ -> { asn1_NOVALUE, Tlv2} end, %%------------------------------------------------- %% attribute cipher(3) with type OCTET STRING %%------------------------------------------------- [V3|Tlv4] = Tlv3, Term3 = decode_octet_string(V3, [131074,4]), case Tlv4 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv4}}}) % extra fields not allowed end, Res1 = {'EncryptedData',Term1,Term2,Term3}, Res1. %%================================ %% EncryptionKey %%================================ enc_EncryptionKey(Val) -> enc_EncryptionKey(Val, [<<48>>]). enc_EncryptionKey(Val, TagIn) -> {_,Cindex1,Cindex2} = Val, %%------------------------------------------------- %% attribute keytype(1) with type INTEGER %%------------------------------------------------- {EncBytes1,EncLen1} = encode_integer(Cindex1, [<<2>>,<<160>>]), %%------------------------------------------------- %% attribute keyvalue(2) with type OCTET STRING %%------------------------------------------------- {EncBytes2,EncLen2} = encode_restricted_string(Cindex2, [<<4>>,<<161>>]), BytesSoFar = [EncBytes1, EncBytes2], LenSoFar = EncLen1 + EncLen2, encode_tags(TagIn, BytesSoFar, LenSoFar). dec_EncryptionKey(Tlv) -> dec_EncryptionKey(Tlv, [16]). dec_EncryptionKey(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute keytype(1) with type INTEGER %%------------------------------------------------- [V1|Tlv2] = Tlv1, Term1 = begin Val1 = decode_integer(V1, [131072,2]), if -2147483648 =< Val1, Val1 =< 2147483647 -> Val1; true -> exit({error,{asn1,bad_range}}) end end, %%------------------------------------------------- %% attribute keyvalue(2) with type OCTET STRING %%------------------------------------------------- [V2|Tlv3] = Tlv2, Term2 = decode_octet_string(V2, [131073,4]), case Tlv3 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv3}}}) % extra fields not allowed end, Res1 = {'EncryptionKey',Term1,Term2}, Res1. %%================================ %% Checksum %%================================ enc_Checksum(Val) -> enc_Checksum(Val, [<<48>>]). enc_Checksum(Val, TagIn) -> {_,Cindex1,Cindex2} = Val, %%------------------------------------------------- %% attribute cksumtype(1) with type INTEGER %%------------------------------------------------- {EncBytes1,EncLen1} = encode_integer(Cindex1, [<<2>>,<<160>>]), %%------------------------------------------------- %% attribute checksum(2) with type OCTET STRING %%------------------------------------------------- {EncBytes2,EncLen2} = encode_restricted_string(Cindex2, [<<4>>,<<161>>]), BytesSoFar = [EncBytes1, EncBytes2], LenSoFar = EncLen1 + EncLen2, encode_tags(TagIn, BytesSoFar, LenSoFar). dec_Checksum(Tlv) -> dec_Checksum(Tlv, [16]). dec_Checksum(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute cksumtype(1) with type INTEGER %%------------------------------------------------- [V1|Tlv2] = Tlv1, Term1 = begin Val1 = decode_integer(V1, [131072,2]), if -2147483648 =< Val1, Val1 =< 2147483647 -> Val1; true -> exit({error,{asn1,bad_range}}) end end, %%------------------------------------------------- %% attribute checksum(2) with type OCTET STRING %%------------------------------------------------- [V2|Tlv3] = Tlv2, Term2 = decode_octet_string(V2, [131073,4]), case Tlv3 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv3}}}) % extra fields not allowed end, Res1 = {'Checksum',Term1,Term2}, Res1. %%================================ %% Ticket %%================================ enc_Ticket(Val) -> enc_Ticket(Val, [<<48>>,<<97>>]). enc_Ticket(Val, TagIn) -> {_,Cindex1,Cindex2,Cindex3,Cindex4} = Val, %%------------------------------------------------- %% attribute tkt-vno(1) with type INTEGER %%------------------------------------------------- {EncBytes1,EncLen1} = encode_integer(Cindex1, [<<2>>,<<160>>]), %%------------------------------------------------- %% attribute realm(2) with type GeneralString %%------------------------------------------------- {EncBytes2,EncLen2} = encode_restricted_string(Cindex2, [<<27>>,<<161>>]), %%------------------------------------------------- %% attribute sname(3) External KRB5:PrincipalName %%------------------------------------------------- {EncBytes3,EncLen3} = 'enc_PrincipalName'(Cindex3, [<<48>>,<<162>>]), %%------------------------------------------------- %% attribute enc-part(4) External KRB5:EncryptedData %%------------------------------------------------- {EncBytes4,EncLen4} = 'enc_EncryptedData'(Cindex4, [<<48>>,<<163>>]), BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4], LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4, encode_tags(TagIn, BytesSoFar, LenSoFar). dec_Ticket(Tlv) -> dec_Ticket(Tlv, [65537,16]). dec_Ticket(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute tkt-vno(1) with type INTEGER %%------------------------------------------------- [V1|Tlv2] = Tlv1, Term1 = begin Val1 = decode_integer(V1, [131072,2]), if 5 =< Val1, Val1 =< 5 -> Val1; true -> exit({error,{asn1,bad_range}}) end end, %%------------------------------------------------- %% attribute realm(2) with type GeneralString %%------------------------------------------------- [V2|Tlv3] = Tlv2, Term2 = begin binary_to_list(decode_restricted_string(V2, [131073,27])) end , %%------------------------------------------------- %% attribute sname(3) External KRB5:PrincipalName %%------------------------------------------------- [V3|Tlv4] = Tlv3, Term3 = 'dec_PrincipalName'(V3, [131074,16]), %%------------------------------------------------- %% attribute enc-part(4) External KRB5:EncryptedData %%------------------------------------------------- [V4|Tlv5] = Tlv4, Term4 = 'dec_EncryptedData'(V4, [131075,16]), case Tlv5 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv5}}}) % extra fields not allowed end, Res1 = {'Ticket',Term1,Term2,Term3,Term4}, Res1. %%================================ %% EncTicketPart %%================================ enc_EncTicketPart(Val) -> enc_EncTicketPart(Val, [<<48>>,<<99>>]). enc_EncTicketPart(Val, TagIn) -> {_,Cindex1,Cindex2,Cindex3,Cindex4,Cindex5,Cindex6,Cindex7,Cindex8,Cindex9,Cindex10,Cindex11} = Val, %%------------------------------------------------- %% attribute flags(1) with type BIT STRING %%------------------------------------------------- {EncBytes1,EncLen1} = encode_unnamed_bit_string(Cindex1, [<<3>>,<<160>>]), %%------------------------------------------------- %% attribute key(2) External KRB5:EncryptionKey %%------------------------------------------------- {EncBytes2,EncLen2} = 'enc_EncryptionKey'(Cindex2, [<<48>>,<<161>>]), %%------------------------------------------------- %% attribute crealm(3) with type GeneralString %%------------------------------------------------- {EncBytes3,EncLen3} = encode_restricted_string(Cindex3, [<<27>>,<<162>>]), %%------------------------------------------------- %% attribute cname(4) External KRB5:PrincipalName %%------------------------------------------------- {EncBytes4,EncLen4} = 'enc_PrincipalName'(Cindex4, [<<48>>,<<163>>]), %%------------------------------------------------- %% attribute transited(5) External KRB5:TransitedEncoding %%------------------------------------------------- {EncBytes5,EncLen5} = 'enc_TransitedEncoding'(Cindex5, [<<48>>,<<164>>]), %%------------------------------------------------- %% attribute authtime(6) with type GeneralizedTime %%------------------------------------------------- {EncBytes6,EncLen6} = encode_restricted_string(Cindex6, [<<24>>,<<165>>]), %%------------------------------------------------- %% attribute starttime(7) with type GeneralizedTime OPTIONAL %%------------------------------------------------- {EncBytes7,EncLen7} = case Cindex7 of asn1_NOVALUE -> {<<>>,0}; _ -> encode_restricted_string(Cindex7, [<<24>>,<<166>>]) end, %%------------------------------------------------- %% attribute endtime(8) with type GeneralizedTime %%------------------------------------------------- {EncBytes8,EncLen8} = encode_restricted_string(Cindex8, [<<24>>,<<167>>]), %%------------------------------------------------- %% attribute renew-till(9) with type GeneralizedTime OPTIONAL %%------------------------------------------------- {EncBytes9,EncLen9} = case Cindex9 of asn1_NOVALUE -> {<<>>,0}; _ -> encode_restricted_string(Cindex9, [<<24>>,<<168>>]) end, %%------------------------------------------------- %% attribute caddr(10) External KRB5:HostAddresses OPTIONAL %%------------------------------------------------- {EncBytes10,EncLen10} = case Cindex10 of asn1_NOVALUE -> {<<>>,0}; _ -> 'enc_HostAddresses'(Cindex10, [<<48>>,<<169>>]) end, %%------------------------------------------------- %% attribute authorization-data(11) External KRB5:AuthorizationData OPTIONAL %%------------------------------------------------- {EncBytes11,EncLen11} = case Cindex11 of asn1_NOVALUE -> {<<>>,0}; _ -> 'enc_AuthorizationData'(Cindex11, [<<48>>,<<170>>]) end, BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4, EncBytes5, EncBytes6, EncBytes7, EncBytes8, EncBytes9, EncBytes10, EncBytes11], LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4 + EncLen5 + EncLen6 + EncLen7 + EncLen8 + EncLen9 + EncLen10 + EncLen11, encode_tags(TagIn, BytesSoFar, LenSoFar). dec_EncTicketPart(Tlv) -> dec_EncTicketPart(Tlv, [65539,16]). dec_EncTicketPart(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute flags(1) with type BIT STRING %%------------------------------------------------- [V1|Tlv2] = Tlv1, Term1 = begin Val1 = decode_native_bit_string(V1, [131072,3]), C1 = bit_size(Val1), if 32 =< C1, C1 =< 'MAX' -> Val1; true -> exit({error,{asn1,bad_range}}) end end, %%------------------------------------------------- %% attribute key(2) External KRB5:EncryptionKey %%------------------------------------------------- [V2|Tlv3] = Tlv2, Term2 = 'dec_EncryptionKey'(V2, [131073,16]), %%------------------------------------------------- %% attribute crealm(3) with type GeneralString %%------------------------------------------------- [V3|Tlv4] = Tlv3, Term3 = begin binary_to_list(decode_restricted_string(V3, [131074,27])) end , %%------------------------------------------------- %% attribute cname(4) External KRB5:PrincipalName %%------------------------------------------------- [V4|Tlv5] = Tlv4, Term4 = 'dec_PrincipalName'(V4, [131075,16]), %%------------------------------------------------- %% attribute transited(5) External KRB5:TransitedEncoding %%------------------------------------------------- [V5|Tlv6] = Tlv5, Term5 = 'dec_TransitedEncoding'(V5, [131076,16]), %%------------------------------------------------- %% attribute authtime(6) with type GeneralizedTime %%------------------------------------------------- [V6|Tlv7] = Tlv6, Term6 = begin binary_to_list(decode_restricted_string(V6, [131077,24])) end , %%------------------------------------------------- %% attribute starttime(7) with type GeneralizedTime OPTIONAL %%------------------------------------------------- {Term7,Tlv8} = case Tlv7 of [{131078,V7}|TempTlv8] -> {begin binary_to_list(decode_restricted_string(V7, [24])) end , TempTlv8}; _ -> { asn1_NOVALUE, Tlv7} end, %%------------------------------------------------- %% attribute endtime(8) with type GeneralizedTime %%------------------------------------------------- [V8|Tlv9] = Tlv8, Term8 = begin binary_to_list(decode_restricted_string(V8, [131079,24])) end , %%------------------------------------------------- %% attribute renew-till(9) with type GeneralizedTime OPTIONAL %%------------------------------------------------- {Term9,Tlv10} = case Tlv9 of [{131080,V9}|TempTlv10] -> {begin binary_to_list(decode_restricted_string(V9, [24])) end , TempTlv10}; _ -> { asn1_NOVALUE, Tlv9} end, %%------------------------------------------------- %% attribute caddr(10) External KRB5:HostAddresses OPTIONAL %%------------------------------------------------- {Term10,Tlv11} = case Tlv10 of [{131081,V10}|TempTlv11] -> {'dec_HostAddresses'(V10, [16]), TempTlv11}; _ -> { asn1_NOVALUE, Tlv10} end, %%------------------------------------------------- %% attribute authorization-data(11) External KRB5:AuthorizationData OPTIONAL %%------------------------------------------------- {Term11,Tlv12} = case Tlv11 of [{131082,V11}|TempTlv12] -> {'dec_AuthorizationData'(V11, [16]), TempTlv12}; _ -> { asn1_NOVALUE, Tlv11} end, case Tlv12 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv12}}}) % extra fields not allowed end, Res1 = {'EncTicketPart',Term1,Term2,Term3,Term4,Term5,Term6,Term7,Term8,Term9,Term10,Term11}, Res1. %%================================ %% TransitedEncoding %%================================ enc_TransitedEncoding(Val) -> enc_TransitedEncoding(Val, [<<48>>]). enc_TransitedEncoding(Val, TagIn) -> {_,Cindex1,Cindex2} = Val, %%------------------------------------------------- %% attribute tr-type(1) with type INTEGER %%------------------------------------------------- {EncBytes1,EncLen1} = encode_integer(Cindex1, [<<2>>,<<160>>]), %%------------------------------------------------- %% attribute contents(2) with type OCTET STRING %%------------------------------------------------- {EncBytes2,EncLen2} = encode_restricted_string(Cindex2, [<<4>>,<<161>>]), BytesSoFar = [EncBytes1, EncBytes2], LenSoFar = EncLen1 + EncLen2, encode_tags(TagIn, BytesSoFar, LenSoFar). dec_TransitedEncoding(Tlv) -> dec_TransitedEncoding(Tlv, [16]). dec_TransitedEncoding(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute tr-type(1) with type INTEGER %%------------------------------------------------- [V1|Tlv2] = Tlv1, Term1 = begin Val1 = decode_integer(V1, [131072,2]), if -2147483648 =< Val1, Val1 =< 2147483647 -> Val1; true -> exit({error,{asn1,bad_range}}) end end, %%------------------------------------------------- %% attribute contents(2) with type OCTET STRING %%------------------------------------------------- [V2|Tlv3] = Tlv2, Term2 = decode_octet_string(V2, [131073,4]), case Tlv3 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv3}}}) % extra fields not allowed end, Res1 = {'TransitedEncoding',Term1,Term2}, Res1. %%================================ %% TicketFlags %%================================ enc_TicketFlags(Val) -> enc_TicketFlags(Val, [<<3>>]). enc_TicketFlags(Val, TagIn) -> encode_unnamed_bit_string(Val, TagIn). dec_TicketFlags(Tlv) -> dec_TicketFlags(Tlv, [3]). dec_TicketFlags(Tlv, TagIn) -> begin Val1 = decode_native_bit_string(Tlv, TagIn), C1 = bit_size(Val1), if 32 =< C1, C1 =< 'MAX' -> Val1; true -> exit({error,{asn1,bad_range}}) end end. %%================================ %% AS-REQ %%================================ 'enc_AS-REQ'(Val) -> 'enc_AS-REQ'(Val, [<<48>>,<<106>>]). 'enc_AS-REQ'(Val, TagIn) -> 'enc_KDC-REQ'(Val, TagIn). 'dec_AS-REQ'(Tlv) -> 'dec_AS-REQ'(Tlv, [65546,16]). 'dec_AS-REQ'(Tlv, TagIn) -> 'dec_KDC-REQ'(Tlv, TagIn). %%================================ %% TGS-REQ %%================================ 'enc_TGS-REQ'(Val) -> 'enc_TGS-REQ'(Val, [<<48>>,<<108>>]). 'enc_TGS-REQ'(Val, TagIn) -> 'enc_KDC-REQ'(Val, TagIn). 'dec_TGS-REQ'(Tlv) -> 'dec_TGS-REQ'(Tlv, [65548,16]). 'dec_TGS-REQ'(Tlv, TagIn) -> 'dec_KDC-REQ'(Tlv, TagIn). %%================================ %% KDC-REQ %%================================ 'enc_KDC-REQ'(Val) -> 'enc_KDC-REQ'(Val, [<<48>>]). 'enc_KDC-REQ'(Val, TagIn) -> {_,Cindex1,Cindex2,Cindex3,Cindex4} = Val, %%------------------------------------------------- %% attribute pvno(1) with type INTEGER %%------------------------------------------------- {EncBytes1,EncLen1} = encode_integer(Cindex1, [<<2>>,<<161>>]), %%------------------------------------------------- %% attribute msg-type(2) with type INTEGER %%------------------------------------------------- {EncBytes2,EncLen2} = encode_integer(Cindex2, [<<2>>,<<162>>]), %%------------------------------------------------- %% attribute padata(3) with type SEQUENCE OF OPTIONAL %%------------------------------------------------- {EncBytes3,EncLen3} = case Cindex3 of asn1_NOVALUE -> {<<>>,0}; _ -> 'enc_KDC-REQ_padata'(Cindex3, [<<48>>,<<163>>]) end, %%------------------------------------------------- %% attribute req-body(4) External KRB5:KDC-REQ-BODY %%------------------------------------------------- {EncBytes4,EncLen4} = 'enc_KDC-REQ-BODY'(Cindex4, [<<48>>,<<164>>]), BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4], LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4, encode_tags(TagIn, BytesSoFar, LenSoFar). %%================================ %% KDC-REQ_padata %%================================ 'enc_KDC-REQ_padata'(Val, TagIn) -> {EncBytes,EncLen} = 'enc_KDC-REQ_padata_components'(Val,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_KDC-REQ_padata_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_KDC-REQ_padata_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = 'enc_PA-DATA'(H, [<<48>>]), 'enc_KDC-REQ_padata_components'(T,[EncBytes|AccBytes], AccLen + EncLen). 'dec_KDC-REQ'(Tlv) -> 'dec_KDC-REQ'(Tlv, [16]). 'dec_KDC-REQ'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute pvno(1) with type INTEGER %%------------------------------------------------- [V1|Tlv2] = Tlv1, Term1 = begin Val1 = decode_integer(V1, [131073,2]), if 5 =< Val1, Val1 =< 5 -> Val1; true -> exit({error,{asn1,bad_range}}) end end, %%------------------------------------------------- %% attribute msg-type(2) with type INTEGER %%------------------------------------------------- [V2|Tlv3] = Tlv2, Term2 = begin Val2 = decode_integer(V2, [131074,2]), if 10 =< Val2, Val2 =< 12 -> Val2; true -> exit({error,{asn1,bad_range}}) end end, %%------------------------------------------------- %% attribute padata(3) with type SEQUENCE OF OPTIONAL %%------------------------------------------------- {Term3,Tlv4} = case Tlv3 of [{131075,V3}|TempTlv4] -> {'dec_KDC-REQ_padata'(V3, [16]), TempTlv4}; _ -> { asn1_NOVALUE, Tlv3} end, %%------------------------------------------------- %% attribute req-body(4) External KRB5:KDC-REQ-BODY %%------------------------------------------------- [V4|Tlv5] = Tlv4, Term4 = 'dec_KDC-REQ-BODY'(V4, [131076,16]), case Tlv5 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv5}}}) % extra fields not allowed end, Res1 = {'KDC-REQ',Term1,Term2,Term3,Term4}, Res1. 'dec_KDC-REQ_padata'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), ['dec_PA-DATA'(V1, [16]) || V1 <- Tlv1]. %%================================ %% KDC-REQ-BODY %%================================ 'enc_KDC-REQ-BODY'(Val) -> 'enc_KDC-REQ-BODY'(Val, [<<48>>]). 'enc_KDC-REQ-BODY'(Val, TagIn) -> {_,Cindex1,Cindex2,Cindex3,Cindex4,Cindex5,Cindex6,Cindex7,Cindex8,Cindex9,Cindex10,Cindex11,Cindex12} = Val, %%------------------------------------------------- %% attribute kdc-options(1) with type BIT STRING %%------------------------------------------------- {EncBytes1,EncLen1} = encode_unnamed_bit_string(Cindex1, [<<3>>,<<160>>]), %%------------------------------------------------- %% attribute cname(2) External KRB5:PrincipalName OPTIONAL %%------------------------------------------------- {EncBytes2,EncLen2} = case Cindex2 of asn1_NOVALUE -> {<<>>,0}; _ -> 'enc_PrincipalName'(Cindex2, [<<48>>,<<161>>]) end, %%------------------------------------------------- %% attribute realm(3) with type GeneralString %%------------------------------------------------- {EncBytes3,EncLen3} = encode_restricted_string(Cindex3, [<<27>>,<<162>>]), %%------------------------------------------------- %% attribute sname(4) External KRB5:PrincipalName OPTIONAL %%------------------------------------------------- {EncBytes4,EncLen4} = case Cindex4 of asn1_NOVALUE -> {<<>>,0}; _ -> 'enc_PrincipalName'(Cindex4, [<<48>>,<<163>>]) end, %%------------------------------------------------- %% attribute from(5) with type GeneralizedTime OPTIONAL %%------------------------------------------------- {EncBytes5,EncLen5} = case Cindex5 of asn1_NOVALUE -> {<<>>,0}; _ -> encode_restricted_string(Cindex5, [<<24>>,<<164>>]) end, %%------------------------------------------------- %% attribute till(6) with type GeneralizedTime %%------------------------------------------------- {EncBytes6,EncLen6} = encode_restricted_string(Cindex6, [<<24>>,<<165>>]), %%------------------------------------------------- %% attribute rtime(7) with type GeneralizedTime OPTIONAL %%------------------------------------------------- {EncBytes7,EncLen7} = case Cindex7 of asn1_NOVALUE -> {<<>>,0}; _ -> encode_restricted_string(Cindex7, [<<24>>,<<166>>]) end, %%------------------------------------------------- %% attribute nonce(8) with type INTEGER %%------------------------------------------------- {EncBytes8,EncLen8} = encode_integer(Cindex8, [<<2>>,<<167>>]), %%------------------------------------------------- %% attribute etype(9) with type SEQUENCE OF %%------------------------------------------------- {EncBytes9,EncLen9} = 'enc_KDC-REQ-BODY_etype'(Cindex9, [<<48>>,<<168>>]), %%------------------------------------------------- %% attribute addresses(10) External KRB5:HostAddresses OPTIONAL %%------------------------------------------------- {EncBytes10,EncLen10} = case Cindex10 of asn1_NOVALUE -> {<<>>,0}; _ -> 'enc_HostAddresses'(Cindex10, [<<48>>,<<169>>]) end, %%------------------------------------------------- %% attribute enc-authorization-data(11) External KRB5:EncryptedData OPTIONAL %%------------------------------------------------- {EncBytes11,EncLen11} = case Cindex11 of asn1_NOVALUE -> {<<>>,0}; _ -> 'enc_EncryptedData'(Cindex11, [<<48>>,<<170>>]) end, %%------------------------------------------------- %% attribute additional-tickets(12) with type SEQUENCE OF OPTIONAL %%------------------------------------------------- {EncBytes12,EncLen12} = case Cindex12 of asn1_NOVALUE -> {<<>>,0}; _ -> 'enc_KDC-REQ-BODY_additional-tickets'(Cindex12, [<<48>>,<<171>>]) end, BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4, EncBytes5, EncBytes6, EncBytes7, EncBytes8, EncBytes9, EncBytes10, EncBytes11, EncBytes12], LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4 + EncLen5 + EncLen6 + EncLen7 + EncLen8 + EncLen9 + EncLen10 + EncLen11 + EncLen12, encode_tags(TagIn, BytesSoFar, LenSoFar). %%================================ %% KDC-REQ-BODY_etype %%================================ 'enc_KDC-REQ-BODY_etype'(Val, TagIn) -> {EncBytes,EncLen} = 'enc_KDC-REQ-BODY_etype_components'(Val,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_KDC-REQ-BODY_etype_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_KDC-REQ-BODY_etype_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = encode_integer(H, [<<2>>]), 'enc_KDC-REQ-BODY_etype_components'(T,[EncBytes|AccBytes], AccLen + EncLen). %%================================ %% KDC-REQ-BODY_additional-tickets %%================================ 'enc_KDC-REQ-BODY_additional-tickets'(Val, TagIn) -> {EncBytes,EncLen} = 'enc_KDC-REQ-BODY_additional-tickets_components'(Val,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_KDC-REQ-BODY_additional-tickets_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_KDC-REQ-BODY_additional-tickets_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = 'enc_Ticket'(H, [<<48>>,<<97>>]), 'enc_KDC-REQ-BODY_additional-tickets_components'(T,[EncBytes|AccBytes], AccLen + EncLen). 'dec_KDC-REQ-BODY'(Tlv) -> 'dec_KDC-REQ-BODY'(Tlv, [16]). 'dec_KDC-REQ-BODY'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute kdc-options(1) with type BIT STRING %%------------------------------------------------- [V1|Tlv2] = Tlv1, Term1 = begin Val1 = decode_native_bit_string(V1, [131072,3]), C1 = bit_size(Val1), if 32 =< C1, C1 =< 'MAX' -> Val1; true -> exit({error,{asn1,bad_range}}) end end, %%------------------------------------------------- %% attribute cname(2) External KRB5:PrincipalName OPTIONAL %%------------------------------------------------- {Term2,Tlv3} = case Tlv2 of [{131073,V2}|TempTlv3] -> {'dec_PrincipalName'(V2, [16]), TempTlv3}; _ -> { asn1_NOVALUE, Tlv2} end, %%------------------------------------------------- %% attribute realm(3) with type GeneralString %%------------------------------------------------- [V3|Tlv4] = Tlv3, Term3 = begin binary_to_list(decode_restricted_string(V3, [131074,27])) end , %%------------------------------------------------- %% attribute sname(4) External KRB5:PrincipalName OPTIONAL %%------------------------------------------------- {Term4,Tlv5} = case Tlv4 of [{131075,V4}|TempTlv5] -> {'dec_PrincipalName'(V4, [16]), TempTlv5}; _ -> { asn1_NOVALUE, Tlv4} end, %%------------------------------------------------- %% attribute from(5) with type GeneralizedTime OPTIONAL %%------------------------------------------------- {Term5,Tlv6} = case Tlv5 of [{131076,V5}|TempTlv6] -> {begin binary_to_list(decode_restricted_string(V5, [24])) end , TempTlv6}; _ -> { asn1_NOVALUE, Tlv5} end, %%------------------------------------------------- %% attribute till(6) with type GeneralizedTime %%------------------------------------------------- [V6|Tlv7] = Tlv6, Term6 = begin binary_to_list(decode_restricted_string(V6, [131077,24])) end , %%------------------------------------------------- %% attribute rtime(7) with type GeneralizedTime OPTIONAL %%------------------------------------------------- {Term7,Tlv8} = case Tlv7 of [{131078,V7}|TempTlv8] -> {begin binary_to_list(decode_restricted_string(V7, [24])) end , TempTlv8}; _ -> { asn1_NOVALUE, Tlv7} end, %%------------------------------------------------- %% attribute nonce(8) with type INTEGER %%------------------------------------------------- [V8|Tlv9] = Tlv8, Term8 = begin Val2 = decode_integer(V8, [131079,2]), if 0 =< Val2, Val2 =< 4294967295 -> Val2; true -> exit({error,{asn1,bad_range}}) end end, %%------------------------------------------------- %% attribute etype(9) with type SEQUENCE OF %%------------------------------------------------- [V9|Tlv10] = Tlv9, Term9 = 'dec_KDC-REQ-BODY_etype'(V9, [131080,16]), %%------------------------------------------------- %% attribute addresses(10) External KRB5:HostAddresses OPTIONAL %%------------------------------------------------- {Term10,Tlv11} = case Tlv10 of [{131081,V10}|TempTlv11] -> {'dec_HostAddresses'(V10, [16]), TempTlv11}; _ -> { asn1_NOVALUE, Tlv10} end, %%------------------------------------------------- %% attribute enc-authorization-data(11) External KRB5:EncryptedData OPTIONAL %%------------------------------------------------- {Term11,Tlv12} = case Tlv11 of [{131082,V11}|TempTlv12] -> {'dec_EncryptedData'(V11, [16]), TempTlv12}; _ -> { asn1_NOVALUE, Tlv11} end, %%------------------------------------------------- %% attribute additional-tickets(12) with type SEQUENCE OF OPTIONAL %%------------------------------------------------- {Term12,Tlv13} = case Tlv12 of [{131083,V12}|TempTlv13] -> {'dec_KDC-REQ-BODY_additional-tickets'(V12, [16]), TempTlv13}; _ -> { asn1_NOVALUE, Tlv12} end, case Tlv13 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv13}}}) % extra fields not allowed end, Res1 = {'KDC-REQ-BODY',Term1,Term2,Term3,Term4,Term5,Term6,Term7,Term8,Term9,Term10,Term11,Term12}, Res1. 'dec_KDC-REQ-BODY_etype'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), [begin Val1 = decode_integer(V1, [2]), if -2147483648 =< Val1, Val1 =< 2147483647 -> Val1; true -> exit({error,{asn1,bad_range}}) end end || V1 <- Tlv1]. 'dec_KDC-REQ-BODY_additional-tickets'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), ['dec_Ticket'(V1, [65537,16]) || V1 <- Tlv1]. %%================================ %% KDCOptions %%================================ enc_KDCOptions(Val) -> enc_KDCOptions(Val, [<<3>>]). enc_KDCOptions(Val, TagIn) -> encode_unnamed_bit_string(Val, TagIn). dec_KDCOptions(Tlv) -> dec_KDCOptions(Tlv, [3]). dec_KDCOptions(Tlv, TagIn) -> begin Val1 = decode_native_bit_string(Tlv, TagIn), C1 = bit_size(Val1), if 32 =< C1, C1 =< 'MAX' -> Val1; true -> exit({error,{asn1,bad_range}}) end end. %%================================ %% AS-REP %%================================ 'enc_AS-REP'(Val) -> 'enc_AS-REP'(Val, [<<48>>,<<107>>]). 'enc_AS-REP'(Val, TagIn) -> 'enc_KDC-REP'(Val, TagIn). 'dec_AS-REP'(Tlv) -> 'dec_AS-REP'(Tlv, [65547,16]). 'dec_AS-REP'(Tlv, TagIn) -> 'dec_KDC-REP'(Tlv, TagIn). %%================================ %% TGS-REP %%================================ 'enc_TGS-REP'(Val) -> 'enc_TGS-REP'(Val, [<<48>>,<<109>>]). 'enc_TGS-REP'(Val, TagIn) -> 'enc_KDC-REP'(Val, TagIn). 'dec_TGS-REP'(Tlv) -> 'dec_TGS-REP'(Tlv, [65549,16]). 'dec_TGS-REP'(Tlv, TagIn) -> 'dec_KDC-REP'(Tlv, TagIn). %%================================ %% KDC-REP %%================================ 'enc_KDC-REP'(Val) -> 'enc_KDC-REP'(Val, [<<48>>]). 'enc_KDC-REP'(Val, TagIn) -> {_,Cindex1,Cindex2,Cindex3,Cindex4,Cindex5,Cindex6,Cindex7} = Val, %%------------------------------------------------- %% attribute pvno(1) with type INTEGER %%------------------------------------------------- {EncBytes1,EncLen1} = encode_integer(Cindex1, [<<2>>,<<160>>]), %%------------------------------------------------- %% attribute msg-type(2) with type INTEGER %%------------------------------------------------- {EncBytes2,EncLen2} = encode_integer(Cindex2, [<<2>>,<<161>>]), %%------------------------------------------------- %% attribute padata(3) with type SEQUENCE OF OPTIONAL %%------------------------------------------------- {EncBytes3,EncLen3} = case Cindex3 of asn1_NOVALUE -> {<<>>,0}; _ -> 'enc_KDC-REP_padata'(Cindex3, [<<48>>,<<162>>]) end, %%------------------------------------------------- %% attribute crealm(4) with type GeneralString %%------------------------------------------------- {EncBytes4,EncLen4} = encode_restricted_string(Cindex4, [<<27>>,<<163>>]), %%------------------------------------------------- %% attribute cname(5) External KRB5:PrincipalName %%------------------------------------------------- {EncBytes5,EncLen5} = 'enc_PrincipalName'(Cindex5, [<<48>>,<<164>>]), %%------------------------------------------------- %% attribute ticket(6) External KRB5:Ticket %%------------------------------------------------- {EncBytes6,EncLen6} = 'enc_Ticket'(Cindex6, [<<48>>,<<97>>,<<165>>]), %%------------------------------------------------- %% attribute enc-part(7) External KRB5:EncryptedData %%------------------------------------------------- {EncBytes7,EncLen7} = 'enc_EncryptedData'(Cindex7, [<<48>>,<<166>>]), BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4, EncBytes5, EncBytes6, EncBytes7], LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4 + EncLen5 + EncLen6 + EncLen7, encode_tags(TagIn, BytesSoFar, LenSoFar). %%================================ %% KDC-REP_padata %%================================ 'enc_KDC-REP_padata'(Val, TagIn) -> {EncBytes,EncLen} = 'enc_KDC-REP_padata_components'(Val,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_KDC-REP_padata_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_KDC-REP_padata_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = 'enc_PA-DATA'(H, [<<48>>]), 'enc_KDC-REP_padata_components'(T,[EncBytes|AccBytes], AccLen + EncLen). 'dec_KDC-REP'(Tlv) -> 'dec_KDC-REP'(Tlv, [16]). 'dec_KDC-REP'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute pvno(1) with type INTEGER %%------------------------------------------------- [V1|Tlv2] = Tlv1, Term1 = begin Val1 = decode_integer(V1, [131072,2]), if 5 =< Val1, Val1 =< 5 -> Val1; true -> exit({error,{asn1,bad_range}}) end end, %%------------------------------------------------- %% attribute msg-type(2) with type INTEGER %%------------------------------------------------- [V2|Tlv3] = Tlv2, Term2 = begin Val2 = decode_integer(V2, [131073,2]), if 11 =< Val2, Val2 =< 13 -> Val2; true -> exit({error,{asn1,bad_range}}) end end, %%------------------------------------------------- %% attribute padata(3) with type SEQUENCE OF OPTIONAL %%------------------------------------------------- {Term3,Tlv4} = case Tlv3 of [{131074,V3}|TempTlv4] -> {'dec_KDC-REP_padata'(V3, [16]), TempTlv4}; _ -> { asn1_NOVALUE, Tlv3} end, %%------------------------------------------------- %% attribute crealm(4) with type GeneralString %%------------------------------------------------- [V4|Tlv5] = Tlv4, Term4 = begin binary_to_list(decode_restricted_string(V4, [131075,27])) end , %%------------------------------------------------- %% attribute cname(5) External KRB5:PrincipalName %%------------------------------------------------- [V5|Tlv6] = Tlv5, Term5 = 'dec_PrincipalName'(V5, [131076,16]), %%------------------------------------------------- %% attribute ticket(6) External KRB5:Ticket %%------------------------------------------------- [V6|Tlv7] = Tlv6, Term6 = 'dec_Ticket'(V6, [131077,65537,16]), %%------------------------------------------------- %% attribute enc-part(7) External KRB5:EncryptedData %%------------------------------------------------- [V7|Tlv8] = Tlv7, Term7 = 'dec_EncryptedData'(V7, [131078,16]), case Tlv8 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv8}}}) % extra fields not allowed end, Res1 = {'KDC-REP',Term1,Term2,Term3,Term4,Term5,Term6,Term7}, Res1. 'dec_KDC-REP_padata'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), ['dec_PA-DATA'(V1, [16]) || V1 <- Tlv1]. %%================================ %% EncASRepPart %%================================ enc_EncASRepPart(Val) -> enc_EncASRepPart(Val, [<<48>>,<<121>>]). enc_EncASRepPart(Val, TagIn) -> enc_EncKDCRepPart(Val, TagIn). dec_EncASRepPart(Tlv) -> dec_EncASRepPart(Tlv, [65561,16]). dec_EncASRepPart(Tlv, TagIn) -> 'dec_EncKDCRepPart'(Tlv, TagIn). %%================================ %% EncTGSRepPart %%================================ enc_EncTGSRepPart(Val) -> enc_EncTGSRepPart(Val, [<<48>>,<<122>>]). enc_EncTGSRepPart(Val, TagIn) -> enc_EncKDCRepPart(Val, TagIn). dec_EncTGSRepPart(Tlv) -> dec_EncTGSRepPart(Tlv, [65562,16]). dec_EncTGSRepPart(Tlv, TagIn) -> 'dec_EncKDCRepPart'(Tlv, TagIn). %%================================ %% EncKDCRepPart %%================================ enc_EncKDCRepPart(Val) -> enc_EncKDCRepPart(Val, [<<48>>]). enc_EncKDCRepPart(Val, TagIn) -> {_,Cindex1,Cindex2,Cindex3,Cindex4,Cindex5,Cindex6,Cindex7,Cindex8,Cindex9,Cindex10,Cindex11,Cindex12,Cindex13} = Val, %%------------------------------------------------- %% attribute key(1) External KRB5:EncryptionKey %%------------------------------------------------- {EncBytes1,EncLen1} = 'enc_EncryptionKey'(Cindex1, [<<48>>,<<160>>]), %%------------------------------------------------- %% attribute last-req(2) External KRB5:LastReq %%------------------------------------------------- {EncBytes2,EncLen2} = 'enc_LastReq'(Cindex2, [<<48>>,<<161>>]), %%------------------------------------------------- %% attribute nonce(3) with type INTEGER %%------------------------------------------------- {EncBytes3,EncLen3} = encode_integer(Cindex3, [<<2>>,<<162>>]), %%------------------------------------------------- %% attribute key-expiration(4) with type GeneralizedTime OPTIONAL %%------------------------------------------------- {EncBytes4,EncLen4} = case Cindex4 of asn1_NOVALUE -> {<<>>,0}; _ -> encode_restricted_string(Cindex4, [<<24>>,<<163>>]) end, %%------------------------------------------------- %% attribute flags(5) with type BIT STRING %%------------------------------------------------- {EncBytes5,EncLen5} = encode_unnamed_bit_string(Cindex5, [<<3>>,<<164>>]), %%------------------------------------------------- %% attribute authtime(6) with type GeneralizedTime %%------------------------------------------------- {EncBytes6,EncLen6} = encode_restricted_string(Cindex6, [<<24>>,<<165>>]), %%------------------------------------------------- %% attribute starttime(7) with type GeneralizedTime OPTIONAL %%------------------------------------------------- {EncBytes7,EncLen7} = case Cindex7 of asn1_NOVALUE -> {<<>>,0}; _ -> encode_restricted_string(Cindex7, [<<24>>,<<166>>]) end, %%------------------------------------------------- %% attribute endtime(8) with type GeneralizedTime %%------------------------------------------------- {EncBytes8,EncLen8} = encode_restricted_string(Cindex8, [<<24>>,<<167>>]), %%------------------------------------------------- %% attribute renew-till(9) with type GeneralizedTime OPTIONAL %%------------------------------------------------- {EncBytes9,EncLen9} = case Cindex9 of asn1_NOVALUE -> {<<>>,0}; _ -> encode_restricted_string(Cindex9, [<<24>>,<<168>>]) end, %%------------------------------------------------- %% attribute srealm(10) with type GeneralString %%------------------------------------------------- {EncBytes10,EncLen10} = encode_restricted_string(Cindex10, [<<27>>,<<169>>]), %%------------------------------------------------- %% attribute sname(11) External KRB5:PrincipalName %%------------------------------------------------- {EncBytes11,EncLen11} = 'enc_PrincipalName'(Cindex11, [<<48>>,<<170>>]), %%------------------------------------------------- %% attribute caddr(12) External KRB5:HostAddresses OPTIONAL %%------------------------------------------------- {EncBytes12,EncLen12} = case Cindex12 of asn1_NOVALUE -> {<<>>,0}; _ -> 'enc_HostAddresses'(Cindex12, [<<48>>,<<171>>]) end, %%------------------------------------------------- %% attribute encrypted-pa-data(13) with type SEQUENCE OF OPTIONAL %%------------------------------------------------- {EncBytes13,EncLen13} = case Cindex13 of asn1_NOVALUE -> {<<>>,0}; _ -> 'enc_EncKDCRepPart_encrypted-pa-data'(Cindex13, [<<48>>,<<172>>]) end, BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4, EncBytes5, EncBytes6, EncBytes7, EncBytes8, EncBytes9, EncBytes10, EncBytes11, EncBytes12, EncBytes13], LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4 + EncLen5 + EncLen6 + EncLen7 + EncLen8 + EncLen9 + EncLen10 + EncLen11 + EncLen12 + EncLen13, encode_tags(TagIn, BytesSoFar, LenSoFar). %%================================ %% EncKDCRepPart_encrypted-pa-data %%================================ 'enc_EncKDCRepPart_encrypted-pa-data'(Val, TagIn) -> {EncBytes,EncLen} = 'enc_EncKDCRepPart_encrypted-pa-data_components'(Val,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_EncKDCRepPart_encrypted-pa-data_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_EncKDCRepPart_encrypted-pa-data_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = 'enc_PA-DATA'(H, [<<48>>]), 'enc_EncKDCRepPart_encrypted-pa-data_components'(T,[EncBytes|AccBytes], AccLen + EncLen). dec_EncKDCRepPart(Tlv) -> dec_EncKDCRepPart(Tlv, [16]). dec_EncKDCRepPart(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute key(1) External KRB5:EncryptionKey %%------------------------------------------------- [V1|Tlv2] = Tlv1, Term1 = 'dec_EncryptionKey'(V1, [131072,16]), %%------------------------------------------------- %% attribute last-req(2) External KRB5:LastReq %%------------------------------------------------- [V2|Tlv3] = Tlv2, Term2 = 'dec_LastReq'(V2, [131073,16]), %%------------------------------------------------- %% attribute nonce(3) with type INTEGER %%------------------------------------------------- [V3|Tlv4] = Tlv3, Term3 = begin Val1 = decode_integer(V3, [131074,2]), if 0 =< Val1, Val1 =< 4294967295 -> Val1; true -> exit({error,{asn1,bad_range}}) end end, %%------------------------------------------------- %% attribute key-expiration(4) with type GeneralizedTime OPTIONAL %%------------------------------------------------- {Term4,Tlv5} = case Tlv4 of [{131075,V4}|TempTlv5] -> {begin binary_to_list(decode_restricted_string(V4, [24])) end , TempTlv5}; _ -> { asn1_NOVALUE, Tlv4} end, %%------------------------------------------------- %% attribute flags(5) with type BIT STRING %%------------------------------------------------- [V5|Tlv6] = Tlv5, Term5 = begin Val2 = decode_native_bit_string(V5, [131076,3]), C1 = bit_size(Val2), if 32 =< C1, C1 =< 'MAX' -> Val2; true -> exit({error,{asn1,bad_range}}) end end, %%------------------------------------------------- %% attribute authtime(6) with type GeneralizedTime %%------------------------------------------------- [V6|Tlv7] = Tlv6, Term6 = begin binary_to_list(decode_restricted_string(V6, [131077,24])) end , %%------------------------------------------------- %% attribute starttime(7) with type GeneralizedTime OPTIONAL %%------------------------------------------------- {Term7,Tlv8} = case Tlv7 of [{131078,V7}|TempTlv8] -> {begin binary_to_list(decode_restricted_string(V7, [24])) end , TempTlv8}; _ -> { asn1_NOVALUE, Tlv7} end, %%------------------------------------------------- %% attribute endtime(8) with type GeneralizedTime %%------------------------------------------------- [V8|Tlv9] = Tlv8, Term8 = begin binary_to_list(decode_restricted_string(V8, [131079,24])) end , %%------------------------------------------------- %% attribute renew-till(9) with type GeneralizedTime OPTIONAL %%------------------------------------------------- {Term9,Tlv10} = case Tlv9 of [{131080,V9}|TempTlv10] -> {begin binary_to_list(decode_restricted_string(V9, [24])) end , TempTlv10}; _ -> { asn1_NOVALUE, Tlv9} end, %%------------------------------------------------- %% attribute srealm(10) with type GeneralString %%------------------------------------------------- [V10|Tlv11] = Tlv10, Term10 = begin binary_to_list(decode_restricted_string(V10, [131081,27])) end , %%------------------------------------------------- %% attribute sname(11) External KRB5:PrincipalName %%------------------------------------------------- [V11|Tlv12] = Tlv11, Term11 = 'dec_PrincipalName'(V11, [131082,16]), %%------------------------------------------------- %% attribute caddr(12) External KRB5:HostAddresses OPTIONAL %%------------------------------------------------- {Term12,Tlv13} = case Tlv12 of [{131083,V12}|TempTlv13] -> {'dec_HostAddresses'(V12, [16]), TempTlv13}; _ -> { asn1_NOVALUE, Tlv12} end, %%------------------------------------------------- %% attribute encrypted-pa-data(13) with type SEQUENCE OF OPTIONAL %%------------------------------------------------- {Term13,Tlv14} = case Tlv13 of [{131084,V13}|TempTlv14] -> {'dec_EncKDCRepPart_encrypted-pa-data'(V13, [16]), TempTlv14}; _ -> { asn1_NOVALUE, Tlv13} end, case Tlv14 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv14}}}) % extra fields not allowed end, Res1 = {'EncKDCRepPart',Term1,Term2,Term3,Term4,Term5,Term6,Term7,Term8,Term9,Term10,Term11,Term12,Term13}, Res1. 'dec_EncKDCRepPart_encrypted-pa-data'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), ['dec_PA-DATA'(V1, [16]) || V1 <- Tlv1]. %%================================ %% LastReq %%================================ enc_LastReq(Val) -> enc_LastReq(Val, [<<48>>]). enc_LastReq(Val, TagIn) -> {EncBytes,EncLen} = 'enc_LastReq_components'(Val,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_LastReq_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_LastReq_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = 'enc_LastReq_SEQOF'(H, [<<48>>]), 'enc_LastReq_components'(T,[EncBytes|AccBytes], AccLen + EncLen). %%================================ %% LastReq_SEQOF %%================================ enc_LastReq_SEQOF(Val, TagIn) -> {_,Cindex1,Cindex2} = Val, %%------------------------------------------------- %% attribute lr-type(1) with type INTEGER %%------------------------------------------------- {EncBytes1,EncLen1} = encode_integer(Cindex1, [<<2>>,<<160>>]), %%------------------------------------------------- %% attribute lr-value(2) with type GeneralizedTime %%------------------------------------------------- {EncBytes2,EncLen2} = encode_restricted_string(Cindex2, [<<24>>,<<161>>]), BytesSoFar = [EncBytes1, EncBytes2], LenSoFar = EncLen1 + EncLen2, encode_tags(TagIn, BytesSoFar, LenSoFar). dec_LastReq(Tlv) -> dec_LastReq(Tlv, [16]). dec_LastReq(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), ['dec_LastReq_SEQOF'(V1, [16]) || V1 <- Tlv1]. 'dec_LastReq_SEQOF'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute lr-type(1) with type INTEGER %%------------------------------------------------- [V1|Tlv2] = Tlv1, Term1 = begin Val1 = decode_integer(V1, [131072,2]), if -2147483648 =< Val1, Val1 =< 2147483647 -> Val1; true -> exit({error,{asn1,bad_range}}) end end, %%------------------------------------------------- %% attribute lr-value(2) with type GeneralizedTime %%------------------------------------------------- [V2|Tlv3] = Tlv2, Term2 = begin binary_to_list(decode_restricted_string(V2, [131073,24])) end , case Tlv3 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv3}}}) % extra fields not allowed end, Res1 = {'LastReq_SEQOF',Term1,Term2}, Res1. %%================================ %% AP-REQ %%================================ 'enc_AP-REQ'(Val) -> 'enc_AP-REQ'(Val, [<<48>>,<<110>>]). 'enc_AP-REQ'(Val, TagIn) -> {_,Cindex1,Cindex2,Cindex3,Cindex4,Cindex5} = Val, %%------------------------------------------------- %% attribute pvno(1) with type INTEGER %%------------------------------------------------- {EncBytes1,EncLen1} = encode_integer(Cindex1, [<<2>>,<<160>>]), %%------------------------------------------------- %% attribute msg-type(2) with type INTEGER %%------------------------------------------------- {EncBytes2,EncLen2} = encode_integer(Cindex2, [<<2>>,<<161>>]), %%------------------------------------------------- %% attribute ap-options(3) with type BIT STRING %%------------------------------------------------- {EncBytes3,EncLen3} = encode_unnamed_bit_string(Cindex3, [<<3>>,<<162>>]), %%------------------------------------------------- %% attribute ticket(4) External KRB5:Ticket %%------------------------------------------------- {EncBytes4,EncLen4} = 'enc_Ticket'(Cindex4, [<<48>>,<<97>>,<<163>>]), %%------------------------------------------------- %% attribute authenticator(5) External KRB5:EncryptedData %%------------------------------------------------- {EncBytes5,EncLen5} = 'enc_EncryptedData'(Cindex5, [<<48>>,<<164>>]), BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4, EncBytes5], LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4 + EncLen5, encode_tags(TagIn, BytesSoFar, LenSoFar). 'dec_AP-REQ'(Tlv) -> 'dec_AP-REQ'(Tlv, [65550,16]). 'dec_AP-REQ'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute pvno(1) with type INTEGER %%------------------------------------------------- [V1|Tlv2] = Tlv1, Term1 = begin Val1 = decode_integer(V1, [131072,2]), if 5 =< Val1, Val1 =< 5 -> Val1; true -> exit({error,{asn1,bad_range}}) end end, %%------------------------------------------------- %% attribute msg-type(2) with type INTEGER %%------------------------------------------------- [V2|Tlv3] = Tlv2, Term2 = begin Val2 = decode_integer(V2, [131073,2]), if 14 =< Val2, Val2 =< 14 -> Val2; true -> exit({error,{asn1,bad_range}}) end end, %%------------------------------------------------- %% attribute ap-options(3) with type BIT STRING %%------------------------------------------------- [V3|Tlv4] = Tlv3, Term3 = begin Val3 = decode_native_bit_string(V3, [131074,3]), C1 = bit_size(Val3), if 32 =< C1, C1 =< 'MAX' -> Val3; true -> exit({error,{asn1,bad_range}}) end end, %%------------------------------------------------- %% attribute ticket(4) External KRB5:Ticket %%------------------------------------------------- [V4|Tlv5] = Tlv4, Term4 = 'dec_Ticket'(V4, [131075,65537,16]), %%------------------------------------------------- %% attribute authenticator(5) External KRB5:EncryptedData %%------------------------------------------------- [V5|Tlv6] = Tlv5, Term5 = 'dec_EncryptedData'(V5, [131076,16]), case Tlv6 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv6}}}) % extra fields not allowed end, Res1 = {'AP-REQ',Term1,Term2,Term3,Term4,Term5}, Res1. %%================================ %% APOptions %%================================ enc_APOptions(Val) -> enc_APOptions(Val, [<<3>>]). enc_APOptions(Val, TagIn) -> encode_unnamed_bit_string(Val, TagIn). dec_APOptions(Tlv) -> dec_APOptions(Tlv, [3]). dec_APOptions(Tlv, TagIn) -> begin Val1 = decode_native_bit_string(Tlv, TagIn), C1 = bit_size(Val1), if 32 =< C1, C1 =< 'MAX' -> Val1; true -> exit({error,{asn1,bad_range}}) end end. %%================================ %% Authenticator %%================================ enc_Authenticator(Val) -> enc_Authenticator(Val, [<<48>>,<<98>>]). enc_Authenticator(Val, TagIn) -> {_,Cindex1,Cindex2,Cindex3,Cindex4,Cindex5,Cindex6,Cindex7,Cindex8,Cindex9} = Val, %%------------------------------------------------- %% attribute authenticator-vno(1) with type INTEGER %%------------------------------------------------- {EncBytes1,EncLen1} = encode_integer(Cindex1, [<<2>>,<<160>>]), %%------------------------------------------------- %% attribute crealm(2) with type GeneralString %%------------------------------------------------- {EncBytes2,EncLen2} = encode_restricted_string(Cindex2, [<<27>>,<<161>>]), %%------------------------------------------------- %% attribute cname(3) External KRB5:PrincipalName %%------------------------------------------------- {EncBytes3,EncLen3} = 'enc_PrincipalName'(Cindex3, [<<48>>,<<162>>]), %%------------------------------------------------- %% attribute cksum(4) External KRB5:Checksum OPTIONAL %%------------------------------------------------- {EncBytes4,EncLen4} = case Cindex4 of asn1_NOVALUE -> {<<>>,0}; _ -> 'enc_Checksum'(Cindex4, [<<48>>,<<163>>]) end, %%------------------------------------------------- %% attribute cusec(5) with type INTEGER %%------------------------------------------------- {EncBytes5,EncLen5} = encode_integer(Cindex5, [<<2>>,<<164>>]), %%------------------------------------------------- %% attribute ctime(6) with type GeneralizedTime %%------------------------------------------------- {EncBytes6,EncLen6} = encode_restricted_string(Cindex6, [<<24>>,<<165>>]), %%------------------------------------------------- %% attribute subkey(7) External KRB5:EncryptionKey OPTIONAL %%------------------------------------------------- {EncBytes7,EncLen7} = case Cindex7 of asn1_NOVALUE -> {<<>>,0}; _ -> 'enc_EncryptionKey'(Cindex7, [<<48>>,<<166>>]) end, %%------------------------------------------------- %% attribute seq-number(8) with type INTEGER OPTIONAL %%------------------------------------------------- {EncBytes8,EncLen8} = case Cindex8 of asn1_NOVALUE -> {<<>>,0}; _ -> encode_integer(Cindex8, [<<2>>,<<167>>]) end, %%------------------------------------------------- %% attribute authorization-data(9) External KRB5:AuthorizationData OPTIONAL %%------------------------------------------------- {EncBytes9,EncLen9} = case Cindex9 of asn1_NOVALUE -> {<<>>,0}; _ -> 'enc_AuthorizationData'(Cindex9, [<<48>>,<<168>>]) end, BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4, EncBytes5, EncBytes6, EncBytes7, EncBytes8, EncBytes9], LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4 + EncLen5 + EncLen6 + EncLen7 + EncLen8 + EncLen9, encode_tags(TagIn, BytesSoFar, LenSoFar). dec_Authenticator(Tlv) -> dec_Authenticator(Tlv, [65538,16]). dec_Authenticator(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute authenticator-vno(1) with type INTEGER %%------------------------------------------------- [V1|Tlv2] = Tlv1, Term1 = begin Val1 = decode_integer(V1, [131072,2]), if 5 =< Val1, Val1 =< 5 -> Val1; true -> exit({error,{asn1,bad_range}}) end end, %%------------------------------------------------- %% attribute crealm(2) with type GeneralString %%------------------------------------------------- [V2|Tlv3] = Tlv2, Term2 = begin binary_to_list(decode_restricted_string(V2, [131073,27])) end , %%------------------------------------------------- %% attribute cname(3) External KRB5:PrincipalName %%------------------------------------------------- [V3|Tlv4] = Tlv3, Term3 = 'dec_PrincipalName'(V3, [131074,16]), %%------------------------------------------------- %% attribute cksum(4) External KRB5:Checksum OPTIONAL %%------------------------------------------------- {Term4,Tlv5} = case Tlv4 of [{131075,V4}|TempTlv5] -> {'dec_Checksum'(V4, [16]), TempTlv5}; _ -> { asn1_NOVALUE, Tlv4} end, %%------------------------------------------------- %% attribute cusec(5) with type INTEGER %%------------------------------------------------- [V5|Tlv6] = Tlv5, Term5 = begin Val2 = decode_integer(V5, [131076,2]), if 0 =< Val2, Val2 =< 999999 -> Val2; true -> exit({error,{asn1,bad_range}}) end end, %%------------------------------------------------- %% attribute ctime(6) with type GeneralizedTime %%------------------------------------------------- [V6|Tlv7] = Tlv6, Term6 = begin binary_to_list(decode_restricted_string(V6, [131077,24])) end , %%------------------------------------------------- %% attribute subkey(7) External KRB5:EncryptionKey OPTIONAL %%------------------------------------------------- {Term7,Tlv8} = case Tlv7 of [{131078,V7}|TempTlv8] -> {'dec_EncryptionKey'(V7, [16]), TempTlv8}; _ -> { asn1_NOVALUE, Tlv7} end, %%------------------------------------------------- %% attribute seq-number(8) with type INTEGER OPTIONAL %%------------------------------------------------- {Term8,Tlv9} = case Tlv8 of [{131079,V8}|TempTlv9] -> {begin Val3 = decode_integer(V8, [2]), if 0 =< Val3, Val3 =< 4294967295 -> Val3; true -> exit({error,{asn1,bad_range}}) end end, TempTlv9}; _ -> { asn1_NOVALUE, Tlv8} end, %%------------------------------------------------- %% attribute authorization-data(9) External KRB5:AuthorizationData OPTIONAL %%------------------------------------------------- {Term9,Tlv10} = case Tlv9 of [{131080,V9}|TempTlv10] -> {'dec_AuthorizationData'(V9, [16]), TempTlv10}; _ -> { asn1_NOVALUE, Tlv9} end, case Tlv10 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv10}}}) % extra fields not allowed end, Res1 = {'Authenticator',Term1,Term2,Term3,Term4,Term5,Term6,Term7,Term8,Term9}, Res1. %%================================ %% AP-REP %%================================ 'enc_AP-REP'(Val) -> 'enc_AP-REP'(Val, [<<48>>,<<111>>]). 'enc_AP-REP'(Val, TagIn) -> {_,Cindex1,Cindex2,Cindex3} = Val, %%------------------------------------------------- %% attribute pvno(1) with type INTEGER %%------------------------------------------------- {EncBytes1,EncLen1} = encode_integer(Cindex1, [<<2>>,<<160>>]), %%------------------------------------------------- %% attribute msg-type(2) with type INTEGER %%------------------------------------------------- {EncBytes2,EncLen2} = encode_integer(Cindex2, [<<2>>,<<161>>]), %%------------------------------------------------- %% attribute enc-part(3) External KRB5:EncryptedData %%------------------------------------------------- {EncBytes3,EncLen3} = 'enc_EncryptedData'(Cindex3, [<<48>>,<<162>>]), BytesSoFar = [EncBytes1, EncBytes2, EncBytes3], LenSoFar = EncLen1 + EncLen2 + EncLen3, encode_tags(TagIn, BytesSoFar, LenSoFar). 'dec_AP-REP'(Tlv) -> 'dec_AP-REP'(Tlv, [65551,16]). 'dec_AP-REP'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute pvno(1) with type INTEGER %%------------------------------------------------- [V1|Tlv2] = Tlv1, Term1 = begin Val1 = decode_integer(V1, [131072,2]), if 5 =< Val1, Val1 =< 5 -> Val1; true -> exit({error,{asn1,bad_range}}) end end, %%------------------------------------------------- %% attribute msg-type(2) with type INTEGER %%------------------------------------------------- [V2|Tlv3] = Tlv2, Term2 = begin Val2 = decode_integer(V2, [131073,2]), if 15 =< Val2, Val2 =< 15 -> Val2; true -> exit({error,{asn1,bad_range}}) end end, %%------------------------------------------------- %% attribute enc-part(3) External KRB5:EncryptedData %%------------------------------------------------- [V3|Tlv4] = Tlv3, Term3 = 'dec_EncryptedData'(V3, [131074,16]), case Tlv4 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv4}}}) % extra fields not allowed end, Res1 = {'AP-REP',Term1,Term2,Term3}, Res1. %%================================ %% EncAPRepPart %%================================ enc_EncAPRepPart(Val) -> enc_EncAPRepPart(Val, [<<48>>,<<123>>]). enc_EncAPRepPart(Val, TagIn) -> {_,Cindex1,Cindex2,Cindex3,Cindex4} = Val, %%------------------------------------------------- %% attribute ctime(1) with type GeneralizedTime %%------------------------------------------------- {EncBytes1,EncLen1} = encode_restricted_string(Cindex1, [<<24>>,<<160>>]), %%------------------------------------------------- %% attribute cusec(2) with type INTEGER %%------------------------------------------------- {EncBytes2,EncLen2} = encode_integer(Cindex2, [<<2>>,<<161>>]), %%------------------------------------------------- %% attribute subkey(3) External KRB5:EncryptionKey OPTIONAL %%------------------------------------------------- {EncBytes3,EncLen3} = case Cindex3 of asn1_NOVALUE -> {<<>>,0}; _ -> 'enc_EncryptionKey'(Cindex3, [<<48>>,<<162>>]) end, %%------------------------------------------------- %% attribute seq-number(4) with type INTEGER OPTIONAL %%------------------------------------------------- {EncBytes4,EncLen4} = case Cindex4 of asn1_NOVALUE -> {<<>>,0}; _ -> encode_integer(Cindex4, [<<2>>,<<163>>]) end, BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4], LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4, encode_tags(TagIn, BytesSoFar, LenSoFar). dec_EncAPRepPart(Tlv) -> dec_EncAPRepPart(Tlv, [65563,16]). dec_EncAPRepPart(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute ctime(1) with type GeneralizedTime %%------------------------------------------------- [V1|Tlv2] = Tlv1, Term1 = begin binary_to_list(decode_restricted_string(V1, [131072,24])) end , %%------------------------------------------------- %% attribute cusec(2) with type INTEGER %%------------------------------------------------- [V2|Tlv3] = Tlv2, Term2 = begin Val1 = decode_integer(V2, [131073,2]), if 0 =< Val1, Val1 =< 999999 -> Val1; true -> exit({error,{asn1,bad_range}}) end end, %%------------------------------------------------- %% attribute subkey(3) External KRB5:EncryptionKey OPTIONAL %%------------------------------------------------- {Term3,Tlv4} = case Tlv3 of [{131074,V3}|TempTlv4] -> {'dec_EncryptionKey'(V3, [16]), TempTlv4}; _ -> { asn1_NOVALUE, Tlv3} end, %%------------------------------------------------- %% attribute seq-number(4) with type INTEGER OPTIONAL %%------------------------------------------------- {Term4,Tlv5} = case Tlv4 of [{131075,V4}|TempTlv5] -> {begin Val2 = decode_integer(V4, [2]), if 0 =< Val2, Val2 =< 4294967295 -> Val2; true -> exit({error,{asn1,bad_range}}) end end, TempTlv5}; _ -> { asn1_NOVALUE, Tlv4} end, case Tlv5 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv5}}}) % extra fields not allowed end, Res1 = {'EncAPRepPart',Term1,Term2,Term3,Term4}, Res1. %%================================ %% KRB-SAFE %%================================ 'enc_KRB-SAFE'(Val) -> 'enc_KRB-SAFE'(Val, [<<48>>,<<116>>]). 'enc_KRB-SAFE'(Val, TagIn) -> {_,Cindex1,Cindex2,Cindex3,Cindex4} = Val, %%------------------------------------------------- %% attribute pvno(1) with type INTEGER %%------------------------------------------------- {EncBytes1,EncLen1} = encode_integer(Cindex1, [<<2>>,<<160>>]), %%------------------------------------------------- %% attribute msg-type(2) with type INTEGER %%------------------------------------------------- {EncBytes2,EncLen2} = encode_integer(Cindex2, [<<2>>,<<161>>]), %%------------------------------------------------- %% attribute safe-body(3) External KRB5:KRB-SAFE-BODY %%------------------------------------------------- {EncBytes3,EncLen3} = 'enc_KRB-SAFE-BODY'(Cindex3, [<<48>>,<<162>>]), %%------------------------------------------------- %% attribute cksum(4) External KRB5:Checksum %%------------------------------------------------- {EncBytes4,EncLen4} = 'enc_Checksum'(Cindex4, [<<48>>,<<163>>]), BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4], LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4, encode_tags(TagIn, BytesSoFar, LenSoFar). 'dec_KRB-SAFE'(Tlv) -> 'dec_KRB-SAFE'(Tlv, [65556,16]). 'dec_KRB-SAFE'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute pvno(1) with type INTEGER %%------------------------------------------------- [V1|Tlv2] = Tlv1, Term1 = begin Val1 = decode_integer(V1, [131072,2]), if 5 =< Val1, Val1 =< 5 -> Val1; true -> exit({error,{asn1,bad_range}}) end end, %%------------------------------------------------- %% attribute msg-type(2) with type INTEGER %%------------------------------------------------- [V2|Tlv3] = Tlv2, Term2 = begin Val2 = decode_integer(V2, [131073,2]), if 20 =< Val2, Val2 =< 20 -> Val2; true -> exit({error,{asn1,bad_range}}) end end, %%------------------------------------------------- %% attribute safe-body(3) External KRB5:KRB-SAFE-BODY %%------------------------------------------------- [V3|Tlv4] = Tlv3, Term3 = 'dec_KRB-SAFE-BODY'(V3, [131074,16]), %%------------------------------------------------- %% attribute cksum(4) External KRB5:Checksum %%------------------------------------------------- [V4|Tlv5] = Tlv4, Term4 = 'dec_Checksum'(V4, [131075,16]), case Tlv5 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv5}}}) % extra fields not allowed end, Res1 = {'KRB-SAFE',Term1,Term2,Term3,Term4}, Res1. %%================================ %% KRB-SAFE-BODY %%================================ 'enc_KRB-SAFE-BODY'(Val) -> 'enc_KRB-SAFE-BODY'(Val, [<<48>>]). 'enc_KRB-SAFE-BODY'(Val, TagIn) -> {_,Cindex1,Cindex2,Cindex3,Cindex4,Cindex5,Cindex6} = Val, %%------------------------------------------------- %% attribute user-data(1) with type OCTET STRING %%------------------------------------------------- {EncBytes1,EncLen1} = encode_restricted_string(Cindex1, [<<4>>,<<160>>]), %%------------------------------------------------- %% attribute timestamp(2) with type GeneralizedTime OPTIONAL %%------------------------------------------------- {EncBytes2,EncLen2} = case Cindex2 of asn1_NOVALUE -> {<<>>,0}; _ -> encode_restricted_string(Cindex2, [<<24>>,<<161>>]) end, %%------------------------------------------------- %% attribute usec(3) with type INTEGER OPTIONAL %%------------------------------------------------- {EncBytes3,EncLen3} = case Cindex3 of asn1_NOVALUE -> {<<>>,0}; _ -> encode_integer(Cindex3, [<<2>>,<<162>>]) end, %%------------------------------------------------- %% attribute seq-number(4) with type INTEGER OPTIONAL %%------------------------------------------------- {EncBytes4,EncLen4} = case Cindex4 of asn1_NOVALUE -> {<<>>,0}; _ -> encode_integer(Cindex4, [<<2>>,<<163>>]) end, %%------------------------------------------------- %% attribute s-address(5) External KRB5:HostAddress %%------------------------------------------------- {EncBytes5,EncLen5} = 'enc_HostAddress'(Cindex5, [<<48>>,<<164>>]), %%------------------------------------------------- %% attribute r-address(6) External KRB5:HostAddress OPTIONAL %%------------------------------------------------- {EncBytes6,EncLen6} = case Cindex6 of asn1_NOVALUE -> {<<>>,0}; _ -> 'enc_HostAddress'(Cindex6, [<<48>>,<<165>>]) end, BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4, EncBytes5, EncBytes6], LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4 + EncLen5 + EncLen6, encode_tags(TagIn, BytesSoFar, LenSoFar). 'dec_KRB-SAFE-BODY'(Tlv) -> 'dec_KRB-SAFE-BODY'(Tlv, [16]). 'dec_KRB-SAFE-BODY'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute user-data(1) with type OCTET STRING %%------------------------------------------------- [V1|Tlv2] = Tlv1, Term1 = decode_octet_string(V1, [131072,4]), %%------------------------------------------------- %% attribute timestamp(2) with type GeneralizedTime OPTIONAL %%------------------------------------------------- {Term2,Tlv3} = case Tlv2 of [{131073,V2}|TempTlv3] -> {begin binary_to_list(decode_restricted_string(V2, [24])) end , TempTlv3}; _ -> { asn1_NOVALUE, Tlv2} end, %%------------------------------------------------- %% attribute usec(3) with type INTEGER OPTIONAL %%------------------------------------------------- {Term3,Tlv4} = case Tlv3 of [{131074,V3}|TempTlv4] -> {begin Val1 = decode_integer(V3, [2]), if 0 =< Val1, Val1 =< 999999 -> Val1; true -> exit({error,{asn1,bad_range}}) end end, TempTlv4}; _ -> { asn1_NOVALUE, Tlv3} end, %%------------------------------------------------- %% attribute seq-number(4) with type INTEGER OPTIONAL %%------------------------------------------------- {Term4,Tlv5} = case Tlv4 of [{131075,V4}|TempTlv5] -> {begin Val2 = decode_integer(V4, [2]), if 0 =< Val2, Val2 =< 4294967295 -> Val2; true -> exit({error,{asn1,bad_range}}) end end, TempTlv5}; _ -> { asn1_NOVALUE, Tlv4} end, %%------------------------------------------------- %% attribute s-address(5) External KRB5:HostAddress %%------------------------------------------------- [V5|Tlv6] = Tlv5, Term5 = 'dec_HostAddress'(V5, [131076,16]), %%------------------------------------------------- %% attribute r-address(6) External KRB5:HostAddress OPTIONAL %%------------------------------------------------- {Term6,Tlv7} = case Tlv6 of [{131077,V6}|TempTlv7] -> {'dec_HostAddress'(V6, [16]), TempTlv7}; _ -> { asn1_NOVALUE, Tlv6} end, case Tlv7 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv7}}}) % extra fields not allowed end, Res1 = {'KRB-SAFE-BODY',Term1,Term2,Term3,Term4,Term5,Term6}, Res1. %%================================ %% KRB-PRIV %%================================ 'enc_KRB-PRIV'(Val) -> 'enc_KRB-PRIV'(Val, [<<48>>,<<117>>]). 'enc_KRB-PRIV'(Val, TagIn) -> {_,Cindex1,Cindex2,Cindex3} = Val, %%------------------------------------------------- %% attribute pvno(1) with type INTEGER %%------------------------------------------------- {EncBytes1,EncLen1} = encode_integer(Cindex1, [<<2>>,<<160>>]), %%------------------------------------------------- %% attribute msg-type(2) with type INTEGER %%------------------------------------------------- {EncBytes2,EncLen2} = encode_integer(Cindex2, [<<2>>,<<161>>]), %%------------------------------------------------- %% attribute enc-part(3) External KRB5:EncryptedData %%------------------------------------------------- {EncBytes3,EncLen3} = 'enc_EncryptedData'(Cindex3, [<<48>>,<<163>>]), BytesSoFar = [EncBytes1, EncBytes2, EncBytes3], LenSoFar = EncLen1 + EncLen2 + EncLen3, encode_tags(TagIn, BytesSoFar, LenSoFar). 'dec_KRB-PRIV'(Tlv) -> 'dec_KRB-PRIV'(Tlv, [65557,16]). 'dec_KRB-PRIV'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute pvno(1) with type INTEGER %%------------------------------------------------- [V1|Tlv2] = Tlv1, Term1 = begin Val1 = decode_integer(V1, [131072,2]), if 5 =< Val1, Val1 =< 5 -> Val1; true -> exit({error,{asn1,bad_range}}) end end, %%------------------------------------------------- %% attribute msg-type(2) with type INTEGER %%------------------------------------------------- [V2|Tlv3] = Tlv2, Term2 = begin Val2 = decode_integer(V2, [131073,2]), if 21 =< Val2, Val2 =< 21 -> Val2; true -> exit({error,{asn1,bad_range}}) end end, %%------------------------------------------------- %% attribute enc-part(3) External KRB5:EncryptedData %%------------------------------------------------- [V3|Tlv4] = Tlv3, Term3 = 'dec_EncryptedData'(V3, [131075,16]), case Tlv4 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv4}}}) % extra fields not allowed end, Res1 = {'KRB-PRIV',Term1,Term2,Term3}, Res1. %%================================ %% EncKrbPrivPart %%================================ enc_EncKrbPrivPart(Val) -> enc_EncKrbPrivPart(Val, [<<48>>,<<124>>]). enc_EncKrbPrivPart(Val, TagIn) -> {_,Cindex1,Cindex2,Cindex3,Cindex4,Cindex5,Cindex6} = Val, %%------------------------------------------------- %% attribute user-data(1) with type OCTET STRING %%------------------------------------------------- {EncBytes1,EncLen1} = encode_restricted_string(Cindex1, [<<4>>,<<160>>]), %%------------------------------------------------- %% attribute timestamp(2) with type GeneralizedTime OPTIONAL %%------------------------------------------------- {EncBytes2,EncLen2} = case Cindex2 of asn1_NOVALUE -> {<<>>,0}; _ -> encode_restricted_string(Cindex2, [<<24>>,<<161>>]) end, %%------------------------------------------------- %% attribute usec(3) with type INTEGER OPTIONAL %%------------------------------------------------- {EncBytes3,EncLen3} = case Cindex3 of asn1_NOVALUE -> {<<>>,0}; _ -> encode_integer(Cindex3, [<<2>>,<<162>>]) end, %%------------------------------------------------- %% attribute seq-number(4) with type INTEGER OPTIONAL %%------------------------------------------------- {EncBytes4,EncLen4} = case Cindex4 of asn1_NOVALUE -> {<<>>,0}; _ -> encode_integer(Cindex4, [<<2>>,<<163>>]) end, %%------------------------------------------------- %% attribute s-address(5) External KRB5:HostAddress %%------------------------------------------------- {EncBytes5,EncLen5} = 'enc_HostAddress'(Cindex5, [<<48>>,<<164>>]), %%------------------------------------------------- %% attribute r-address(6) External KRB5:HostAddress OPTIONAL %%------------------------------------------------- {EncBytes6,EncLen6} = case Cindex6 of asn1_NOVALUE -> {<<>>,0}; _ -> 'enc_HostAddress'(Cindex6, [<<48>>,<<165>>]) end, BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4, EncBytes5, EncBytes6], LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4 + EncLen5 + EncLen6, encode_tags(TagIn, BytesSoFar, LenSoFar). dec_EncKrbPrivPart(Tlv) -> dec_EncKrbPrivPart(Tlv, [65564,16]). dec_EncKrbPrivPart(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute user-data(1) with type OCTET STRING %%------------------------------------------------- [V1|Tlv2] = Tlv1, Term1 = decode_octet_string(V1, [131072,4]), %%------------------------------------------------- %% attribute timestamp(2) with type GeneralizedTime OPTIONAL %%------------------------------------------------- {Term2,Tlv3} = case Tlv2 of [{131073,V2}|TempTlv3] -> {begin binary_to_list(decode_restricted_string(V2, [24])) end , TempTlv3}; _ -> { asn1_NOVALUE, Tlv2} end, %%------------------------------------------------- %% attribute usec(3) with type INTEGER OPTIONAL %%------------------------------------------------- {Term3,Tlv4} = case Tlv3 of [{131074,V3}|TempTlv4] -> {begin Val1 = decode_integer(V3, [2]), if 0 =< Val1, Val1 =< 999999 -> Val1; true -> exit({error,{asn1,bad_range}}) end end, TempTlv4}; _ -> { asn1_NOVALUE, Tlv3} end, %%------------------------------------------------- %% attribute seq-number(4) with type INTEGER OPTIONAL %%------------------------------------------------- {Term4,Tlv5} = case Tlv4 of [{131075,V4}|TempTlv5] -> {begin Val2 = decode_integer(V4, [2]), if 0 =< Val2, Val2 =< 4294967295 -> Val2; true -> exit({error,{asn1,bad_range}}) end end, TempTlv5}; _ -> { asn1_NOVALUE, Tlv4} end, %%------------------------------------------------- %% attribute s-address(5) External KRB5:HostAddress %%------------------------------------------------- [V5|Tlv6] = Tlv5, Term5 = 'dec_HostAddress'(V5, [131076,16]), %%------------------------------------------------- %% attribute r-address(6) External KRB5:HostAddress OPTIONAL %%------------------------------------------------- {Term6,Tlv7} = case Tlv6 of [{131077,V6}|TempTlv7] -> {'dec_HostAddress'(V6, [16]), TempTlv7}; _ -> { asn1_NOVALUE, Tlv6} end, case Tlv7 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv7}}}) % extra fields not allowed end, Res1 = {'EncKrbPrivPart',Term1,Term2,Term3,Term4,Term5,Term6}, Res1. %%================================ %% KRB-CRED %%================================ 'enc_KRB-CRED'(Val) -> 'enc_KRB-CRED'(Val, [<<48>>,<<118>>]). 'enc_KRB-CRED'(Val, TagIn) -> {_,Cindex1,Cindex2,Cindex3,Cindex4} = Val, %%------------------------------------------------- %% attribute pvno(1) with type INTEGER %%------------------------------------------------- {EncBytes1,EncLen1} = encode_integer(Cindex1, [<<2>>,<<160>>]), %%------------------------------------------------- %% attribute msg-type(2) with type INTEGER %%------------------------------------------------- {EncBytes2,EncLen2} = encode_integer(Cindex2, [<<2>>,<<161>>]), %%------------------------------------------------- %% attribute tickets(3) with type SEQUENCE OF %%------------------------------------------------- {EncBytes3,EncLen3} = 'enc_KRB-CRED_tickets'(Cindex3, [<<48>>,<<162>>]), %%------------------------------------------------- %% attribute enc-part(4) External KRB5:EncryptedData %%------------------------------------------------- {EncBytes4,EncLen4} = 'enc_EncryptedData'(Cindex4, [<<48>>,<<163>>]), BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4], LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4, encode_tags(TagIn, BytesSoFar, LenSoFar). %%================================ %% KRB-CRED_tickets %%================================ 'enc_KRB-CRED_tickets'(Val, TagIn) -> {EncBytes,EncLen} = 'enc_KRB-CRED_tickets_components'(Val,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_KRB-CRED_tickets_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_KRB-CRED_tickets_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = 'enc_Ticket'(H, [<<48>>,<<97>>]), 'enc_KRB-CRED_tickets_components'(T,[EncBytes|AccBytes], AccLen + EncLen). 'dec_KRB-CRED'(Tlv) -> 'dec_KRB-CRED'(Tlv, [65558,16]). 'dec_KRB-CRED'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute pvno(1) with type INTEGER %%------------------------------------------------- [V1|Tlv2] = Tlv1, Term1 = begin Val1 = decode_integer(V1, [131072,2]), if 5 =< Val1, Val1 =< 5 -> Val1; true -> exit({error,{asn1,bad_range}}) end end, %%------------------------------------------------- %% attribute msg-type(2) with type INTEGER %%------------------------------------------------- [V2|Tlv3] = Tlv2, Term2 = begin Val2 = decode_integer(V2, [131073,2]), if 22 =< Val2, Val2 =< 22 -> Val2; true -> exit({error,{asn1,bad_range}}) end end, %%------------------------------------------------- %% attribute tickets(3) with type SEQUENCE OF %%------------------------------------------------- [V3|Tlv4] = Tlv3, Term3 = 'dec_KRB-CRED_tickets'(V3, [131074,16]), %%------------------------------------------------- %% attribute enc-part(4) External KRB5:EncryptedData %%------------------------------------------------- [V4|Tlv5] = Tlv4, Term4 = 'dec_EncryptedData'(V4, [131075,16]), case Tlv5 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv5}}}) % extra fields not allowed end, Res1 = {'KRB-CRED',Term1,Term2,Term3,Term4}, Res1. 'dec_KRB-CRED_tickets'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), ['dec_Ticket'(V1, [65537,16]) || V1 <- Tlv1]. %%================================ %% EncKrbCredPart %%================================ enc_EncKrbCredPart(Val) -> enc_EncKrbCredPart(Val, [<<48>>,<<125>>]). enc_EncKrbCredPart(Val, TagIn) -> {_,Cindex1,Cindex2,Cindex3,Cindex4,Cindex5,Cindex6} = Val, %%------------------------------------------------- %% attribute ticket-info(1) with type SEQUENCE OF %%------------------------------------------------- {EncBytes1,EncLen1} = 'enc_EncKrbCredPart_ticket-info'(Cindex1, [<<48>>,<<160>>]), %%------------------------------------------------- %% attribute nonce(2) with type INTEGER OPTIONAL %%------------------------------------------------- {EncBytes2,EncLen2} = case Cindex2 of asn1_NOVALUE -> {<<>>,0}; _ -> encode_integer(Cindex2, [<<2>>,<<161>>]) end, %%------------------------------------------------- %% attribute timestamp(3) with type GeneralizedTime OPTIONAL %%------------------------------------------------- {EncBytes3,EncLen3} = case Cindex3 of asn1_NOVALUE -> {<<>>,0}; _ -> encode_restricted_string(Cindex3, [<<24>>,<<162>>]) end, %%------------------------------------------------- %% attribute usec(4) with type INTEGER OPTIONAL %%------------------------------------------------- {EncBytes4,EncLen4} = case Cindex4 of asn1_NOVALUE -> {<<>>,0}; _ -> encode_integer(Cindex4, [<<2>>,<<163>>]) end, %%------------------------------------------------- %% attribute s-address(5) External KRB5:HostAddress OPTIONAL %%------------------------------------------------- {EncBytes5,EncLen5} = case Cindex5 of asn1_NOVALUE -> {<<>>,0}; _ -> 'enc_HostAddress'(Cindex5, [<<48>>,<<164>>]) end, %%------------------------------------------------- %% attribute r-address(6) External KRB5:HostAddress OPTIONAL %%------------------------------------------------- {EncBytes6,EncLen6} = case Cindex6 of asn1_NOVALUE -> {<<>>,0}; _ -> 'enc_HostAddress'(Cindex6, [<<48>>,<<165>>]) end, BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4, EncBytes5, EncBytes6], LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4 + EncLen5 + EncLen6, encode_tags(TagIn, BytesSoFar, LenSoFar). %%================================ %% EncKrbCredPart_ticket-info %%================================ 'enc_EncKrbCredPart_ticket-info'(Val, TagIn) -> {EncBytes,EncLen} = 'enc_EncKrbCredPart_ticket-info_components'(Val,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_EncKrbCredPart_ticket-info_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_EncKrbCredPart_ticket-info_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = 'enc_KrbCredInfo'(H, [<<48>>]), 'enc_EncKrbCredPart_ticket-info_components'(T,[EncBytes|AccBytes], AccLen + EncLen). dec_EncKrbCredPart(Tlv) -> dec_EncKrbCredPart(Tlv, [65565,16]). dec_EncKrbCredPart(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute ticket-info(1) with type SEQUENCE OF %%------------------------------------------------- [V1|Tlv2] = Tlv1, Term1 = 'dec_EncKrbCredPart_ticket-info'(V1, [131072,16]), %%------------------------------------------------- %% attribute nonce(2) with type INTEGER OPTIONAL %%------------------------------------------------- {Term2,Tlv3} = case Tlv2 of [{131073,V2}|TempTlv3] -> {begin Val1 = decode_integer(V2, [2]), if 0 =< Val1, Val1 =< 4294967295 -> Val1; true -> exit({error,{asn1,bad_range}}) end end, TempTlv3}; _ -> { asn1_NOVALUE, Tlv2} end, %%------------------------------------------------- %% attribute timestamp(3) with type GeneralizedTime OPTIONAL %%------------------------------------------------- {Term3,Tlv4} = case Tlv3 of [{131074,V3}|TempTlv4] -> {begin binary_to_list(decode_restricted_string(V3, [24])) end , TempTlv4}; _ -> { asn1_NOVALUE, Tlv3} end, %%------------------------------------------------- %% attribute usec(4) with type INTEGER OPTIONAL %%------------------------------------------------- {Term4,Tlv5} = case Tlv4 of [{131075,V4}|TempTlv5] -> {begin Val2 = decode_integer(V4, [2]), if 0 =< Val2, Val2 =< 999999 -> Val2; true -> exit({error,{asn1,bad_range}}) end end, TempTlv5}; _ -> { asn1_NOVALUE, Tlv4} end, %%------------------------------------------------- %% attribute s-address(5) External KRB5:HostAddress OPTIONAL %%------------------------------------------------- {Term5,Tlv6} = case Tlv5 of [{131076,V5}|TempTlv6] -> {'dec_HostAddress'(V5, [16]), TempTlv6}; _ -> { asn1_NOVALUE, Tlv5} end, %%------------------------------------------------- %% attribute r-address(6) External KRB5:HostAddress OPTIONAL %%------------------------------------------------- {Term6,Tlv7} = case Tlv6 of [{131077,V6}|TempTlv7] -> {'dec_HostAddress'(V6, [16]), TempTlv7}; _ -> { asn1_NOVALUE, Tlv6} end, case Tlv7 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv7}}}) % extra fields not allowed end, Res1 = {'EncKrbCredPart',Term1,Term2,Term3,Term4,Term5,Term6}, Res1. 'dec_EncKrbCredPart_ticket-info'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), ['dec_KrbCredInfo'(V1, [16]) || V1 <- Tlv1]. %%================================ %% KrbCredInfo %%================================ enc_KrbCredInfo(Val) -> enc_KrbCredInfo(Val, [<<48>>]). enc_KrbCredInfo(Val, TagIn) -> {_,Cindex1,Cindex2,Cindex3,Cindex4,Cindex5,Cindex6,Cindex7,Cindex8,Cindex9,Cindex10,Cindex11} = Val, %%------------------------------------------------- %% attribute key(1) External KRB5:EncryptionKey %%------------------------------------------------- {EncBytes1,EncLen1} = 'enc_EncryptionKey'(Cindex1, [<<48>>,<<160>>]), %%------------------------------------------------- %% attribute prealm(2) with type GeneralString OPTIONAL %%------------------------------------------------- {EncBytes2,EncLen2} = case Cindex2 of asn1_NOVALUE -> {<<>>,0}; _ -> encode_restricted_string(Cindex2, [<<27>>,<<161>>]) end, %%------------------------------------------------- %% attribute pname(3) External KRB5:PrincipalName OPTIONAL %%------------------------------------------------- {EncBytes3,EncLen3} = case Cindex3 of asn1_NOVALUE -> {<<>>,0}; _ -> 'enc_PrincipalName'(Cindex3, [<<48>>,<<162>>]) end, %%------------------------------------------------- %% attribute flags(4) with type BIT STRING OPTIONAL %%------------------------------------------------- {EncBytes4,EncLen4} = case Cindex4 of asn1_NOVALUE -> {<<>>,0}; _ -> encode_unnamed_bit_string(Cindex4, [<<3>>,<<163>>]) end, %%------------------------------------------------- %% attribute authtime(5) with type GeneralizedTime OPTIONAL %%------------------------------------------------- {EncBytes5,EncLen5} = case Cindex5 of asn1_NOVALUE -> {<<>>,0}; _ -> encode_restricted_string(Cindex5, [<<24>>,<<164>>]) end, %%------------------------------------------------- %% attribute starttime(6) with type GeneralizedTime OPTIONAL %%------------------------------------------------- {EncBytes6,EncLen6} = case Cindex6 of asn1_NOVALUE -> {<<>>,0}; _ -> encode_restricted_string(Cindex6, [<<24>>,<<165>>]) end, %%------------------------------------------------- %% attribute endtime(7) with type GeneralizedTime OPTIONAL %%------------------------------------------------- {EncBytes7,EncLen7} = case Cindex7 of asn1_NOVALUE -> {<<>>,0}; _ -> encode_restricted_string(Cindex7, [<<24>>,<<166>>]) end, %%------------------------------------------------- %% attribute renew-till(8) with type GeneralizedTime OPTIONAL %%------------------------------------------------- {EncBytes8,EncLen8} = case Cindex8 of asn1_NOVALUE -> {<<>>,0}; _ -> encode_restricted_string(Cindex8, [<<24>>,<<167>>]) end, %%------------------------------------------------- %% attribute srealm(9) with type GeneralString OPTIONAL %%------------------------------------------------- {EncBytes9,EncLen9} = case Cindex9 of asn1_NOVALUE -> {<<>>,0}; _ -> encode_restricted_string(Cindex9, [<<27>>,<<168>>]) end, %%------------------------------------------------- %% attribute sname(10) External KRB5:PrincipalName OPTIONAL %%------------------------------------------------- {EncBytes10,EncLen10} = case Cindex10 of asn1_NOVALUE -> {<<>>,0}; _ -> 'enc_PrincipalName'(Cindex10, [<<48>>,<<169>>]) end, %%------------------------------------------------- %% attribute caddr(11) External KRB5:HostAddresses OPTIONAL %%------------------------------------------------- {EncBytes11,EncLen11} = case Cindex11 of asn1_NOVALUE -> {<<>>,0}; _ -> 'enc_HostAddresses'(Cindex11, [<<48>>,<<170>>]) end, BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4, EncBytes5, EncBytes6, EncBytes7, EncBytes8, EncBytes9, EncBytes10, EncBytes11], LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4 + EncLen5 + EncLen6 + EncLen7 + EncLen8 + EncLen9 + EncLen10 + EncLen11, encode_tags(TagIn, BytesSoFar, LenSoFar). dec_KrbCredInfo(Tlv) -> dec_KrbCredInfo(Tlv, [16]). dec_KrbCredInfo(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute key(1) External KRB5:EncryptionKey %%------------------------------------------------- [V1|Tlv2] = Tlv1, Term1 = 'dec_EncryptionKey'(V1, [131072,16]), %%------------------------------------------------- %% attribute prealm(2) with type GeneralString OPTIONAL %%------------------------------------------------- {Term2,Tlv3} = case Tlv2 of [{131073,V2}|TempTlv3] -> {begin binary_to_list(decode_restricted_string(V2, [27])) end , TempTlv3}; _ -> { asn1_NOVALUE, Tlv2} end, %%------------------------------------------------- %% attribute pname(3) External KRB5:PrincipalName OPTIONAL %%------------------------------------------------- {Term3,Tlv4} = case Tlv3 of [{131074,V3}|TempTlv4] -> {'dec_PrincipalName'(V3, [16]), TempTlv4}; _ -> { asn1_NOVALUE, Tlv3} end, %%------------------------------------------------- %% attribute flags(4) with type BIT STRING OPTIONAL %%------------------------------------------------- {Term4,Tlv5} = case Tlv4 of [{131075,V4}|TempTlv5] -> {begin Val1 = decode_native_bit_string(V4, [3]), C1 = bit_size(Val1), if 32 =< C1, C1 =< 'MAX' -> Val1; true -> exit({error,{asn1,bad_range}}) end end, TempTlv5}; _ -> { asn1_NOVALUE, Tlv4} end, %%------------------------------------------------- %% attribute authtime(5) with type GeneralizedTime OPTIONAL %%------------------------------------------------- {Term5,Tlv6} = case Tlv5 of [{131076,V5}|TempTlv6] -> {begin binary_to_list(decode_restricted_string(V5, [24])) end , TempTlv6}; _ -> { asn1_NOVALUE, Tlv5} end, %%------------------------------------------------- %% attribute starttime(6) with type GeneralizedTime OPTIONAL %%------------------------------------------------- {Term6,Tlv7} = case Tlv6 of [{131077,V6}|TempTlv7] -> {begin binary_to_list(decode_restricted_string(V6, [24])) end , TempTlv7}; _ -> { asn1_NOVALUE, Tlv6} end, %%------------------------------------------------- %% attribute endtime(7) with type GeneralizedTime OPTIONAL %%------------------------------------------------- {Term7,Tlv8} = case Tlv7 of [{131078,V7}|TempTlv8] -> {begin binary_to_list(decode_restricted_string(V7, [24])) end , TempTlv8}; _ -> { asn1_NOVALUE, Tlv7} end, %%------------------------------------------------- %% attribute renew-till(8) with type GeneralizedTime OPTIONAL %%------------------------------------------------- {Term8,Tlv9} = case Tlv8 of [{131079,V8}|TempTlv9] -> {begin binary_to_list(decode_restricted_string(V8, [24])) end , TempTlv9}; _ -> { asn1_NOVALUE, Tlv8} end, %%------------------------------------------------- %% attribute srealm(9) with type GeneralString OPTIONAL %%------------------------------------------------- {Term9,Tlv10} = case Tlv9 of [{131080,V9}|TempTlv10] -> {begin binary_to_list(decode_restricted_string(V9, [27])) end , TempTlv10}; _ -> { asn1_NOVALUE, Tlv9} end, %%------------------------------------------------- %% attribute sname(10) External KRB5:PrincipalName OPTIONAL %%------------------------------------------------- {Term10,Tlv11} = case Tlv10 of [{131081,V10}|TempTlv11] -> {'dec_PrincipalName'(V10, [16]), TempTlv11}; _ -> { asn1_NOVALUE, Tlv10} end, %%------------------------------------------------- %% attribute caddr(11) External KRB5:HostAddresses OPTIONAL %%------------------------------------------------- {Term11,Tlv12} = case Tlv11 of [{131082,V11}|TempTlv12] -> {'dec_HostAddresses'(V11, [16]), TempTlv12}; _ -> { asn1_NOVALUE, Tlv11} end, case Tlv12 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv12}}}) % extra fields not allowed end, Res1 = {'KrbCredInfo',Term1,Term2,Term3,Term4,Term5,Term6,Term7,Term8,Term9,Term10,Term11}, Res1. %%================================ %% KRB-ERROR %%================================ 'enc_KRB-ERROR'(Val) -> 'enc_KRB-ERROR'(Val, [<<48>>,<<126>>]). 'enc_KRB-ERROR'(Val, TagIn) -> {_,Cindex1,Cindex2,Cindex3,Cindex4,Cindex5,Cindex6,Cindex7,Cindex8,Cindex9,Cindex10,Cindex11,Cindex12,Cindex13} = Val, %%------------------------------------------------- %% attribute pvno(1) with type INTEGER %%------------------------------------------------- {EncBytes1,EncLen1} = encode_integer(Cindex1, [<<2>>,<<160>>]), %%------------------------------------------------- %% attribute msg-type(2) with type INTEGER %%------------------------------------------------- {EncBytes2,EncLen2} = encode_integer(Cindex2, [<<2>>,<<161>>]), %%------------------------------------------------- %% attribute ctime(3) with type GeneralizedTime OPTIONAL %%------------------------------------------------- {EncBytes3,EncLen3} = case Cindex3 of asn1_NOVALUE -> {<<>>,0}; _ -> encode_restricted_string(Cindex3, [<<24>>,<<162>>]) end, %%------------------------------------------------- %% attribute cusec(4) with type INTEGER OPTIONAL %%------------------------------------------------- {EncBytes4,EncLen4} = case Cindex4 of asn1_NOVALUE -> {<<>>,0}; _ -> encode_integer(Cindex4, [<<2>>,<<163>>]) end, %%------------------------------------------------- %% attribute stime(5) with type GeneralizedTime %%------------------------------------------------- {EncBytes5,EncLen5} = encode_restricted_string(Cindex5, [<<24>>,<<164>>]), %%------------------------------------------------- %% attribute susec(6) with type INTEGER %%------------------------------------------------- {EncBytes6,EncLen6} = encode_integer(Cindex6, [<<2>>,<<165>>]), %%------------------------------------------------- %% attribute error-code(7) with type INTEGER %%------------------------------------------------- {EncBytes7,EncLen7} = encode_integer(Cindex7, [<<2>>,<<166>>]), %%------------------------------------------------- %% attribute crealm(8) with type GeneralString OPTIONAL %%------------------------------------------------- {EncBytes8,EncLen8} = case Cindex8 of asn1_NOVALUE -> {<<>>,0}; _ -> encode_restricted_string(Cindex8, [<<27>>,<<167>>]) end, %%------------------------------------------------- %% attribute cname(9) External KRB5:PrincipalName OPTIONAL %%------------------------------------------------- {EncBytes9,EncLen9} = case Cindex9 of asn1_NOVALUE -> {<<>>,0}; _ -> 'enc_PrincipalName'(Cindex9, [<<48>>,<<168>>]) end, %%------------------------------------------------- %% attribute realm(10) with type GeneralString %%------------------------------------------------- {EncBytes10,EncLen10} = encode_restricted_string(Cindex10, [<<27>>,<<169>>]), %%------------------------------------------------- %% attribute sname(11) External KRB5:PrincipalName %%------------------------------------------------- {EncBytes11,EncLen11} = 'enc_PrincipalName'(Cindex11, [<<48>>,<<170>>]), %%------------------------------------------------- %% attribute e-text(12) with type GeneralString OPTIONAL %%------------------------------------------------- {EncBytes12,EncLen12} = case Cindex12 of asn1_NOVALUE -> {<<>>,0}; _ -> encode_restricted_string(Cindex12, [<<27>>,<<171>>]) end, %%------------------------------------------------- %% attribute e-data(13) with type OCTET STRING OPTIONAL %%------------------------------------------------- {EncBytes13,EncLen13} = case Cindex13 of asn1_NOVALUE -> {<<>>,0}; _ -> encode_restricted_string(Cindex13, [<<4>>,<<172>>]) end, BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4, EncBytes5, EncBytes6, EncBytes7, EncBytes8, EncBytes9, EncBytes10, EncBytes11, EncBytes12, EncBytes13], LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4 + EncLen5 + EncLen6 + EncLen7 + EncLen8 + EncLen9 + EncLen10 + EncLen11 + EncLen12 + EncLen13, encode_tags(TagIn, BytesSoFar, LenSoFar). 'dec_KRB-ERROR'(Tlv) -> 'dec_KRB-ERROR'(Tlv, [65566,16]). 'dec_KRB-ERROR'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute pvno(1) with type INTEGER %%------------------------------------------------- [V1|Tlv2] = Tlv1, Term1 = begin Val1 = decode_integer(V1, [131072,2]), if 5 =< Val1, Val1 =< 5 -> Val1; true -> exit({error,{asn1,bad_range}}) end end, %%------------------------------------------------- %% attribute msg-type(2) with type INTEGER %%------------------------------------------------- [V2|Tlv3] = Tlv2, Term2 = begin Val2 = decode_integer(V2, [131073,2]), if 30 =< Val2, Val2 =< 30 -> Val2; true -> exit({error,{asn1,bad_range}}) end end, %%------------------------------------------------- %% attribute ctime(3) with type GeneralizedTime OPTIONAL %%------------------------------------------------- {Term3,Tlv4} = case Tlv3 of [{131074,V3}|TempTlv4] -> {begin binary_to_list(decode_restricted_string(V3, [24])) end , TempTlv4}; _ -> { asn1_NOVALUE, Tlv3} end, %%------------------------------------------------- %% attribute cusec(4) with type INTEGER OPTIONAL %%------------------------------------------------- {Term4,Tlv5} = case Tlv4 of [{131075,V4}|TempTlv5] -> {begin Val3 = decode_integer(V4, [2]), if 0 =< Val3, Val3 =< 999999 -> Val3; true -> exit({error,{asn1,bad_range}}) end end, TempTlv5}; _ -> { asn1_NOVALUE, Tlv4} end, %%------------------------------------------------- %% attribute stime(5) with type GeneralizedTime %%------------------------------------------------- [V5|Tlv6] = Tlv5, Term5 = begin binary_to_list(decode_restricted_string(V5, [131076,24])) end , %%------------------------------------------------- %% attribute susec(6) with type INTEGER %%------------------------------------------------- [V6|Tlv7] = Tlv6, Term6 = begin Val4 = decode_integer(V6, [131077,2]), if 0 =< Val4, Val4 =< 999999 -> Val4; true -> exit({error,{asn1,bad_range}}) end end, %%------------------------------------------------- %% attribute error-code(7) with type INTEGER %%------------------------------------------------- [V7|Tlv8] = Tlv7, Term7 = begin Val5 = decode_integer(V7, [131078,2]), if -2147483648 =< Val5, Val5 =< 2147483647 -> Val5; true -> exit({error,{asn1,bad_range}}) end end, %%------------------------------------------------- %% attribute crealm(8) with type GeneralString OPTIONAL %%------------------------------------------------- {Term8,Tlv9} = case Tlv8 of [{131079,V8}|TempTlv9] -> {begin binary_to_list(decode_restricted_string(V8, [27])) end , TempTlv9}; _ -> { asn1_NOVALUE, Tlv8} end, %%------------------------------------------------- %% attribute cname(9) External KRB5:PrincipalName OPTIONAL %%------------------------------------------------- {Term9,Tlv10} = case Tlv9 of [{131080,V9}|TempTlv10] -> {'dec_PrincipalName'(V9, [16]), TempTlv10}; _ -> { asn1_NOVALUE, Tlv9} end, %%------------------------------------------------- %% attribute realm(10) with type GeneralString %%------------------------------------------------- [V10|Tlv11] = Tlv10, Term10 = begin binary_to_list(decode_restricted_string(V10, [131081,27])) end , %%------------------------------------------------- %% attribute sname(11) External KRB5:PrincipalName %%------------------------------------------------- [V11|Tlv12] = Tlv11, Term11 = 'dec_PrincipalName'(V11, [131082,16]), %%------------------------------------------------- %% attribute e-text(12) with type GeneralString OPTIONAL %%------------------------------------------------- {Term12,Tlv13} = case Tlv12 of [{131083,V12}|TempTlv13] -> {begin binary_to_list(decode_restricted_string(V12, [27])) end , TempTlv13}; _ -> { asn1_NOVALUE, Tlv12} end, %%------------------------------------------------- %% attribute e-data(13) with type OCTET STRING OPTIONAL %%------------------------------------------------- {Term13,Tlv14} = case Tlv13 of [{131084,V13}|TempTlv14] -> {decode_octet_string(V13, [4]), TempTlv14}; _ -> { asn1_NOVALUE, Tlv13} end, case Tlv14 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv14}}}) % extra fields not allowed end, Res1 = {'KRB-ERROR',Term1,Term2,Term3,Term4,Term5,Term6,Term7,Term8,Term9,Term10,Term11,Term12,Term13}, Res1. %%================================ %% METHOD-DATA %%================================ 'enc_METHOD-DATA'(Val) -> 'enc_METHOD-DATA'(Val, [<<48>>]). 'enc_METHOD-DATA'(Val, TagIn) -> {EncBytes,EncLen} = 'enc_METHOD-DATA_components'(Val,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_METHOD-DATA_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_METHOD-DATA_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = 'enc_PA-DATA'(H, [<<48>>]), 'enc_METHOD-DATA_components'(T,[EncBytes|AccBytes], AccLen + EncLen). 'dec_METHOD-DATA'(Tlv) -> 'dec_METHOD-DATA'(Tlv, [16]). 'dec_METHOD-DATA'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), ['dec_PA-DATA'(V1, [16]) || V1 <- Tlv1]. %%================================ %% TYPED-DATA %%================================ 'enc_TYPED-DATA'(Val) -> 'enc_TYPED-DATA'(Val, [<<48>>]). 'enc_TYPED-DATA'(Val, TagIn) -> {EncBytes,EncLen} = 'enc_TYPED-DATA_components'(Val,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_TYPED-DATA_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_TYPED-DATA_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = 'enc_TYPED-DATA_SEQOF'(H, [<<48>>]), 'enc_TYPED-DATA_components'(T,[EncBytes|AccBytes], AccLen + EncLen). %%================================ %% TYPED-DATA_SEQOF %%================================ 'enc_TYPED-DATA_SEQOF'(Val, TagIn) -> {_,Cindex1,Cindex2} = Val, %%------------------------------------------------- %% attribute data-type(1) with type INTEGER %%------------------------------------------------- {EncBytes1,EncLen1} = encode_integer(Cindex1, [<<2>>,<<160>>]), %%------------------------------------------------- %% attribute data-value(2) with type OCTET STRING OPTIONAL %%------------------------------------------------- {EncBytes2,EncLen2} = case Cindex2 of asn1_NOVALUE -> {<<>>,0}; _ -> encode_restricted_string(Cindex2, [<<4>>,<<161>>]) end, BytesSoFar = [EncBytes1, EncBytes2], LenSoFar = EncLen1 + EncLen2, encode_tags(TagIn, BytesSoFar, LenSoFar). 'dec_TYPED-DATA'(Tlv) -> 'dec_TYPED-DATA'(Tlv, [16]). 'dec_TYPED-DATA'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), ['dec_TYPED-DATA_SEQOF'(V1, [16]) || V1 <- Tlv1]. 'dec_TYPED-DATA_SEQOF'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute data-type(1) with type INTEGER %%------------------------------------------------- [V1|Tlv2] = Tlv1, Term1 = begin Val1 = decode_integer(V1, [131072,2]), if -2147483648 =< Val1, Val1 =< 2147483647 -> Val1; true -> exit({error,{asn1,bad_range}}) end end, %%------------------------------------------------- %% attribute data-value(2) with type OCTET STRING OPTIONAL %%------------------------------------------------- {Term2,Tlv3} = case Tlv2 of [{131073,V2}|TempTlv3] -> {decode_octet_string(V2, [4]), TempTlv3}; _ -> { asn1_NOVALUE, Tlv2} end, case Tlv3 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv3}}}) % extra fields not allowed end, Res1 = {'TYPED-DATA_SEQOF',Term1,Term2}, Res1. %%================================ %% PA-ENC-TIMESTAMP %%================================ 'enc_PA-ENC-TIMESTAMP'(Val) -> 'enc_PA-ENC-TIMESTAMP'(Val, [<<48>>]). 'enc_PA-ENC-TIMESTAMP'(Val, TagIn) -> enc_EncryptedData(Val, TagIn). 'dec_PA-ENC-TIMESTAMP'(Tlv) -> 'dec_PA-ENC-TIMESTAMP'(Tlv, [16]). 'dec_PA-ENC-TIMESTAMP'(Tlv, TagIn) -> 'dec_EncryptedData'(Tlv, TagIn). %%================================ %% PA-ENC-TS-ENC %%================================ 'enc_PA-ENC-TS-ENC'(Val) -> 'enc_PA-ENC-TS-ENC'(Val, [<<48>>]). 'enc_PA-ENC-TS-ENC'(Val, TagIn) -> {_,Cindex1,Cindex2} = Val, %%------------------------------------------------- %% attribute patimestamp(1) with type GeneralizedTime %%------------------------------------------------- {EncBytes1,EncLen1} = encode_restricted_string(Cindex1, [<<24>>,<<160>>]), %%------------------------------------------------- %% attribute pausec(2) with type INTEGER OPTIONAL %%------------------------------------------------- {EncBytes2,EncLen2} = case Cindex2 of asn1_NOVALUE -> {<<>>,0}; _ -> encode_integer(Cindex2, [<<2>>,<<161>>]) end, BytesSoFar = [EncBytes1, EncBytes2], LenSoFar = EncLen1 + EncLen2, encode_tags(TagIn, BytesSoFar, LenSoFar). 'dec_PA-ENC-TS-ENC'(Tlv) -> 'dec_PA-ENC-TS-ENC'(Tlv, [16]). 'dec_PA-ENC-TS-ENC'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute patimestamp(1) with type GeneralizedTime %%------------------------------------------------- [V1|Tlv2] = Tlv1, Term1 = begin binary_to_list(decode_restricted_string(V1, [131072,24])) end , %%------------------------------------------------- %% attribute pausec(2) with type INTEGER OPTIONAL %%------------------------------------------------- {Term2,Tlv3} = case Tlv2 of [{131073,V2}|TempTlv3] -> {begin Val1 = decode_integer(V2, [2]), if 0 =< Val1, Val1 =< 999999 -> Val1; true -> exit({error,{asn1,bad_range}}) end end, TempTlv3}; _ -> { asn1_NOVALUE, Tlv2} end, case Tlv3 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv3}}}) % extra fields not allowed end, Res1 = {'PA-ENC-TS-ENC',Term1,Term2}, Res1. %%================================ %% ETYPE-INFO-ENTRY %%================================ 'enc_ETYPE-INFO-ENTRY'(Val) -> 'enc_ETYPE-INFO-ENTRY'(Val, [<<48>>]). 'enc_ETYPE-INFO-ENTRY'(Val, TagIn) -> {_,Cindex1,Cindex2} = Val, %%------------------------------------------------- %% attribute etype(1) with type INTEGER %%------------------------------------------------- {EncBytes1,EncLen1} = encode_integer(Cindex1, [<<2>>,<<160>>]), %%------------------------------------------------- %% attribute salt(2) with type OCTET STRING OPTIONAL %%------------------------------------------------- {EncBytes2,EncLen2} = case Cindex2 of asn1_NOVALUE -> {<<>>,0}; _ -> encode_restricted_string(Cindex2, [<<4>>,<<161>>]) end, BytesSoFar = [EncBytes1, EncBytes2], LenSoFar = EncLen1 + EncLen2, encode_tags(TagIn, BytesSoFar, LenSoFar). 'dec_ETYPE-INFO-ENTRY'(Tlv) -> 'dec_ETYPE-INFO-ENTRY'(Tlv, [16]). 'dec_ETYPE-INFO-ENTRY'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute etype(1) with type INTEGER %%------------------------------------------------- [V1|Tlv2] = Tlv1, Term1 = begin Val1 = decode_integer(V1, [131072,2]), if -2147483648 =< Val1, Val1 =< 2147483647 -> Val1; true -> exit({error,{asn1,bad_range}}) end end, %%------------------------------------------------- %% attribute salt(2) with type OCTET STRING OPTIONAL %%------------------------------------------------- {Term2,Tlv3} = case Tlv2 of [{131073,V2}|TempTlv3] -> {decode_octet_string(V2, [4]), TempTlv3}; _ -> { asn1_NOVALUE, Tlv2} end, case Tlv3 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv3}}}) % extra fields not allowed end, Res1 = {'ETYPE-INFO-ENTRY',Term1,Term2}, Res1. %%================================ %% ETYPE-INFO %%================================ 'enc_ETYPE-INFO'(Val) -> 'enc_ETYPE-INFO'(Val, [<<48>>]). 'enc_ETYPE-INFO'(Val, TagIn) -> {EncBytes,EncLen} = 'enc_ETYPE-INFO_components'(Val,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_ETYPE-INFO_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_ETYPE-INFO_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = 'enc_ETYPE-INFO-ENTRY'(H, [<<48>>]), 'enc_ETYPE-INFO_components'(T,[EncBytes|AccBytes], AccLen + EncLen). 'dec_ETYPE-INFO'(Tlv) -> 'dec_ETYPE-INFO'(Tlv, [16]). 'dec_ETYPE-INFO'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), ['dec_ETYPE-INFO-ENTRY'(V1, [16]) || V1 <- Tlv1]. %%================================ %% ETYPE-INFO2-ENTRY %%================================ 'enc_ETYPE-INFO2-ENTRY'(Val) -> 'enc_ETYPE-INFO2-ENTRY'(Val, [<<48>>]). 'enc_ETYPE-INFO2-ENTRY'(Val, TagIn) -> {_,Cindex1,Cindex2,Cindex3} = Val, %%------------------------------------------------- %% attribute etype(1) with type INTEGER %%------------------------------------------------- {EncBytes1,EncLen1} = encode_integer(Cindex1, [<<2>>,<<160>>]), %%------------------------------------------------- %% attribute salt(2) with type GeneralString OPTIONAL %%------------------------------------------------- {EncBytes2,EncLen2} = case Cindex2 of asn1_NOVALUE -> {<<>>,0}; _ -> encode_restricted_string(Cindex2, [<<27>>,<<161>>]) end, %%------------------------------------------------- %% attribute s2kparams(3) with type OCTET STRING OPTIONAL %%------------------------------------------------- {EncBytes3,EncLen3} = case Cindex3 of asn1_NOVALUE -> {<<>>,0}; _ -> encode_restricted_string(Cindex3, [<<4>>,<<162>>]) end, BytesSoFar = [EncBytes1, EncBytes2, EncBytes3], LenSoFar = EncLen1 + EncLen2 + EncLen3, encode_tags(TagIn, BytesSoFar, LenSoFar). 'dec_ETYPE-INFO2-ENTRY'(Tlv) -> 'dec_ETYPE-INFO2-ENTRY'(Tlv, [16]). 'dec_ETYPE-INFO2-ENTRY'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute etype(1) with type INTEGER %%------------------------------------------------- [V1|Tlv2] = Tlv1, Term1 = begin Val1 = decode_integer(V1, [131072,2]), if -2147483648 =< Val1, Val1 =< 2147483647 -> Val1; true -> exit({error,{asn1,bad_range}}) end end, %%------------------------------------------------- %% attribute salt(2) with type GeneralString OPTIONAL %%------------------------------------------------- {Term2,Tlv3} = case Tlv2 of [{131073,V2}|TempTlv3] -> {begin binary_to_list(decode_restricted_string(V2, [27])) end , TempTlv3}; _ -> { asn1_NOVALUE, Tlv2} end, %%------------------------------------------------- %% attribute s2kparams(3) with type OCTET STRING OPTIONAL %%------------------------------------------------- {Term3,Tlv4} = case Tlv3 of [{131074,V3}|TempTlv4] -> {decode_octet_string(V3, [4]), TempTlv4}; _ -> { asn1_NOVALUE, Tlv3} end, case Tlv4 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv4}}}) % extra fields not allowed end, Res1 = {'ETYPE-INFO2-ENTRY',Term1,Term2,Term3}, Res1. %%================================ %% ETYPE-INFO2 %%================================ 'enc_ETYPE-INFO2'(Val) -> 'enc_ETYPE-INFO2'(Val, [<<48>>]). 'enc_ETYPE-INFO2'(Val, TagIn) -> {EncBytes,EncLen} = 'enc_ETYPE-INFO2_components'(Val,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_ETYPE-INFO2_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_ETYPE-INFO2_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = 'enc_ETYPE-INFO2-ENTRY'(H, [<<48>>]), 'enc_ETYPE-INFO2_components'(T,[EncBytes|AccBytes], AccLen + EncLen). 'dec_ETYPE-INFO2'(Tlv) -> 'dec_ETYPE-INFO2'(Tlv, [16]). 'dec_ETYPE-INFO2'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), ['dec_ETYPE-INFO2-ENTRY'(V1, [16]) || V1 <- Tlv1]. %%================================ %% AD-IF-RELEVANT %%================================ 'enc_AD-IF-RELEVANT'(Val) -> 'enc_AD-IF-RELEVANT'(Val, [<<48>>]). 'enc_AD-IF-RELEVANT'(Val, TagIn) -> enc_AuthorizationData(Val, TagIn). 'dec_AD-IF-RELEVANT'(Tlv) -> 'dec_AD-IF-RELEVANT'(Tlv, [16]). 'dec_AD-IF-RELEVANT'(Tlv, TagIn) -> 'dec_AuthorizationData'(Tlv, TagIn). %%================================ %% AD-KDCIssued %%================================ 'enc_AD-KDCIssued'(Val) -> 'enc_AD-KDCIssued'(Val, [<<48>>]). 'enc_AD-KDCIssued'(Val, TagIn) -> {_,Cindex1,Cindex2,Cindex3,Cindex4} = Val, %%------------------------------------------------- %% attribute ad-checksum(1) External KRB5:Checksum %%------------------------------------------------- {EncBytes1,EncLen1} = 'enc_Checksum'(Cindex1, [<<48>>,<<160>>]), %%------------------------------------------------- %% attribute i-realm(2) with type GeneralString OPTIONAL %%------------------------------------------------- {EncBytes2,EncLen2} = case Cindex2 of asn1_NOVALUE -> {<<>>,0}; _ -> encode_restricted_string(Cindex2, [<<27>>,<<161>>]) end, %%------------------------------------------------- %% attribute i-sname(3) External KRB5:PrincipalName OPTIONAL %%------------------------------------------------- {EncBytes3,EncLen3} = case Cindex3 of asn1_NOVALUE -> {<<>>,0}; _ -> 'enc_PrincipalName'(Cindex3, [<<48>>,<<162>>]) end, %%------------------------------------------------- %% attribute elements(4) External KRB5:AuthorizationData %%------------------------------------------------- {EncBytes4,EncLen4} = 'enc_AuthorizationData'(Cindex4, [<<48>>,<<163>>]), BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4], LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4, encode_tags(TagIn, BytesSoFar, LenSoFar). 'dec_AD-KDCIssued'(Tlv) -> 'dec_AD-KDCIssued'(Tlv, [16]). 'dec_AD-KDCIssued'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute ad-checksum(1) External KRB5:Checksum %%------------------------------------------------- [V1|Tlv2] = Tlv1, Term1 = 'dec_Checksum'(V1, [131072,16]), %%------------------------------------------------- %% attribute i-realm(2) with type GeneralString OPTIONAL %%------------------------------------------------- {Term2,Tlv3} = case Tlv2 of [{131073,V2}|TempTlv3] -> {begin binary_to_list(decode_restricted_string(V2, [27])) end , TempTlv3}; _ -> { asn1_NOVALUE, Tlv2} end, %%------------------------------------------------- %% attribute i-sname(3) External KRB5:PrincipalName OPTIONAL %%------------------------------------------------- {Term3,Tlv4} = case Tlv3 of [{131074,V3}|TempTlv4] -> {'dec_PrincipalName'(V3, [16]), TempTlv4}; _ -> { asn1_NOVALUE, Tlv3} end, %%------------------------------------------------- %% attribute elements(4) External KRB5:AuthorizationData %%------------------------------------------------- [V4|Tlv5] = Tlv4, Term4 = 'dec_AuthorizationData'(V4, [131075,16]), case Tlv5 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv5}}}) % extra fields not allowed end, Res1 = {'AD-KDCIssued',Term1,Term2,Term3,Term4}, Res1. %%================================ %% AD-AND-OR %%================================ 'enc_AD-AND-OR'(Val) -> 'enc_AD-AND-OR'(Val, [<<48>>]). 'enc_AD-AND-OR'(Val, TagIn) -> {_,Cindex1,Cindex2} = Val, %%------------------------------------------------- %% attribute condition-count(1) with type INTEGER %%------------------------------------------------- {EncBytes1,EncLen1} = encode_integer(Cindex1, [<<2>>,<<160>>]), %%------------------------------------------------- %% attribute elements(2) External KRB5:AuthorizationData %%------------------------------------------------- {EncBytes2,EncLen2} = 'enc_AuthorizationData'(Cindex2, [<<48>>,<<161>>]), BytesSoFar = [EncBytes1, EncBytes2], LenSoFar = EncLen1 + EncLen2, encode_tags(TagIn, BytesSoFar, LenSoFar). 'dec_AD-AND-OR'(Tlv) -> 'dec_AD-AND-OR'(Tlv, [16]). 'dec_AD-AND-OR'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute condition-count(1) with type INTEGER %%------------------------------------------------- [V1|Tlv2] = Tlv1, Term1 = begin Val1 = decode_integer(V1, [131072,2]), if -2147483648 =< Val1, Val1 =< 2147483647 -> Val1; true -> exit({error,{asn1,bad_range}}) end end, %%------------------------------------------------- %% attribute elements(2) External KRB5:AuthorizationData %%------------------------------------------------- [V2|Tlv3] = Tlv2, Term2 = 'dec_AuthorizationData'(V2, [131073,16]), case Tlv3 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv3}}}) % extra fields not allowed end, Res1 = {'AD-AND-OR',Term1,Term2}, Res1. %%================================ %% AD-MANDATORY-FOR-KDC %%================================ 'enc_AD-MANDATORY-FOR-KDC'(Val) -> 'enc_AD-MANDATORY-FOR-KDC'(Val, [<<48>>]). 'enc_AD-MANDATORY-FOR-KDC'(Val, TagIn) -> enc_AuthorizationData(Val, TagIn). 'dec_AD-MANDATORY-FOR-KDC'(Tlv) -> 'dec_AD-MANDATORY-FOR-KDC'(Tlv, [16]). 'dec_AD-MANDATORY-FOR-KDC'(Tlv, TagIn) -> 'dec_AuthorizationData'(Tlv, TagIn). %%================================ %% PA-PAC-REQUEST %%================================ 'enc_PA-PAC-REQUEST'(Val) -> 'enc_PA-PAC-REQUEST'(Val, [<<48>>]). 'enc_PA-PAC-REQUEST'(Val, TagIn) -> {_,Cindex1} = Val, %%------------------------------------------------- %% attribute include-pac(1) with type BOOLEAN %%------------------------------------------------- {EncBytes1,EncLen1} = encode_boolean(Cindex1, [<<1>>,<<160>>]), BytesSoFar = [EncBytes1], LenSoFar = EncLen1, encode_tags(TagIn, BytesSoFar, LenSoFar). 'dec_PA-PAC-REQUEST'(Tlv) -> 'dec_PA-PAC-REQUEST'(Tlv, [16]). 'dec_PA-PAC-REQUEST'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute include-pac(1) with type BOOLEAN %%------------------------------------------------- [V1|Tlv2] = Tlv1, Term1 = decode_boolean(V1, [131072,1]), case Tlv2 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv2}}}) % extra fields not allowed end, Res1 = {'PA-PAC-REQUEST',Term1}, Res1. 'id-krb5'() -> {1,3,6,1,5,2}. %%% %%% 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, <>} | 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, <>} | Rest], Acc, Uacc) -> collect_parts_bit(Rest, [Bits | Acc], Unused + Uacc); collect_parts_bit([], Acc, Uacc) -> list_to_binary([Uacc | lists:reverse(Acc)]). decode_boolean(Tlv, TagIn) -> Val = match_tags(Tlv, TagIn), case Val of <<0:8>> -> false; <<_:8>> -> true; _ -> exit({error, {asn1, {decode_boolean, Val}}}) end. decode_integer(Tlv, TagIn) -> Bin = match_tags(Tlv, TagIn), Len = byte_size(Bin), <> = Bin, Int. decode_native_bit_string(Buffer, Tags) -> case match_and_collect(Buffer, Tags) of <<0>> -> <<>>; <> -> Size = bit_size(Bits) - Unused, <> = Bits, Val end. decode_octet_string(Tlv, TagsIn) -> Bin = match_and_collect(Tlv, TagsIn), binary:copy(Bin). decode_restricted_string(Tlv, TagsIn) -> match_and_collect(Tlv, TagsIn). encode_boolean(true, TagIn) -> encode_tags(TagIn, [255], 1); encode_boolean(false, TagIn) -> encode_tags(TagIn, [0], 1); encode_boolean(X, _) -> exit({error, {asn1, {encode_boolean, X}}}). 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_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}. encode_unnamed_bit_string(Bits, TagIn) -> Unused = (8 - bit_size(Bits) band 7) band 7, Bin = <>, encode_tags(TagIn, Bin, byte_size(Bin)). 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, []).