%% Generated by the Erlang ASN.1 BER compiler. Version: 5.0.9 %% Purpose: Encoding and decoding of the types in AuthenticationFramework. -module('AuthenticationFramework'). -compile(nowarn_unused_vars). -dialyzer(no_improper_lists). -include("AuthenticationFramework.hrl"). -asn1_info([{vsn,'5.0.9'}, {module,'AuthenticationFramework'}, {options,[{i,"src"},noobj,{outdir,"src"},{i,"."},{i,"priv/kep"}]}]). -export([encoding_rule/0,maps/0,bit_string_format/0, legacy_erlang_types/0]). -export(['dialyzer-suppressions'/1]). -export([ enc_Certificate/2, enc_Version/2, enc_CertificateSerialNumber/2, enc_AlgorithmIdentifier/2, enc_Validity/2, enc_SubjectPublicKeyInfo/2, enc_Time/2, enc_Extensions/2, enc_Extension/2, enc_Certificates/2, enc_ForwardCertificationPath/2, enc_CrossCertificates/2, enc_CertificationPath/2, enc_CertificatePair/2, enc_CertificateList/2, enc_AttributeCertificationPath/2, enc_ACPathData/2, enc_AttributeCertificate/2, enc_AttributeCertificateInfo/2, enc_IssuerSerial/2, enc_AttCertValidityPeriod/2, enc_AttributeCertificateAssertion/2 ]). -export([ dec_Certificate/2, dec_Version/2, dec_CertificateSerialNumber/2, dec_AlgorithmIdentifier/2, dec_Validity/2, dec_SubjectPublicKeyInfo/2, dec_Time/2, dec_Extensions/2, dec_Extension/2, dec_Certificates/2, dec_ForwardCertificationPath/2, dec_CrossCertificates/2, dec_CertificationPath/2, dec_CertificatePair/2, dec_CertificateList/2, dec_AttributeCertificationPath/2, dec_ACPathData/2, dec_AttributeCertificate/2, dec_AttributeCertificateInfo/2, dec_IssuerSerial/2, dec_AttCertValidityPeriod/2, dec_AttributeCertificateAssertion/2 ]). -export([ enc_attributeCertificate/3, enc_attributeCertificateMatch/3, enc_userPassword/3, enc_userCertificate/3, enc_cACertificate/3, enc_crossCertificatePair/3, enc_authorityRevocationList/3, enc_certificateRevocationList/3, enc_attributeCertificateRevocationList/3 ]). -export([ dec_attributeCertificate/3, dec_attributeCertificateMatch/3, dec_userPassword/3, dec_userCertificate/3, dec_cACertificate/3, dec_crossCertificatePair/3, dec_authorityRevocationList/3, dec_certificateRevocationList/3, dec_attributeCertificateRevocationList/3 ]). -export([ getenc_SupportedAlgorithms/1, getenc_ExtensionSet/1 ]). -export([ getdec_SupportedAlgorithms/1, getdec_ExtensionSet/1 ]). -export([ 'id-at-userPassword'/0, 'id-at-userCertificate'/0, 'id-at-cAcertificate'/0, 'id-at-authorityRevocationList'/0, 'id-at-certificateRevocationList'/0, 'id-at-crossCertificatePair'/0, 'id-at-attributeCertificate'/0, 'id-at-attributeCertificateRevocationList'/0, 'id-mr-attributeCertificateMatch'/0 ]). -export([info/0]). -export([encode/2,decode/2]). encoding_rule() -> ber. maps() -> false. bit_string_format() -> bitstring. legacy_erlang_types() -> false. encode(Type, Data) -> try iolist_to_binary(element(1, encode_disp(Type, Data))) of Bytes -> {ok,Bytes} catch Class:Exception:Stk when Class =:= error; Class =:= exit -> case Exception of {error,{asn1,Reason}} -> {error,{asn1,{Reason,Stk}}}; Reason -> {error,{asn1,{Reason,Stk}}} end end. decode(Type, Data) -> try Result = decode_disp(Type, element(1, ber_decode_nif(Data))), {ok,Result} catch Class:Exception:Stk when Class =:= error; Class =:= exit -> case Exception of {error,{asn1,Reason}} -> {error,{asn1,{Reason,Stk}}}; Reason -> {error,{asn1,{Reason,Stk}}} end end. encode_disp('Certificate', Data) -> enc_Certificate(Data); encode_disp('Version', Data) -> enc_Version(Data); encode_disp('CertificateSerialNumber', Data) -> enc_CertificateSerialNumber(Data); encode_disp('AlgorithmIdentifier', Data) -> enc_AlgorithmIdentifier(Data); encode_disp('Validity', Data) -> enc_Validity(Data); encode_disp('SubjectPublicKeyInfo', Data) -> enc_SubjectPublicKeyInfo(Data); encode_disp('Time', Data) -> enc_Time(Data); encode_disp('Extensions', Data) -> enc_Extensions(Data); encode_disp('Extension', Data) -> enc_Extension(Data); encode_disp('Certificates', Data) -> enc_Certificates(Data); encode_disp('ForwardCertificationPath', Data) -> enc_ForwardCertificationPath(Data); encode_disp('CrossCertificates', Data) -> enc_CrossCertificates(Data); encode_disp('CertificationPath', Data) -> enc_CertificationPath(Data); encode_disp('CertificatePair', Data) -> enc_CertificatePair(Data); encode_disp('CertificateList', Data) -> enc_CertificateList(Data); encode_disp('AttributeCertificationPath', Data) -> enc_AttributeCertificationPath(Data); encode_disp('ACPathData', Data) -> enc_ACPathData(Data); encode_disp('AttributeCertificate', Data) -> enc_AttributeCertificate(Data); encode_disp('AttributeCertificateInfo', Data) -> enc_AttributeCertificateInfo(Data); encode_disp('IssuerSerial', Data) -> enc_IssuerSerial(Data); encode_disp('AttCertValidityPeriod', Data) -> enc_AttCertValidityPeriod(Data); encode_disp('AttributeCertificateAssertion', Data) -> enc_AttributeCertificateAssertion(Data); encode_disp(Type, _Data) -> exit({error,{asn1,{undefined_type,Type}}}). decode_disp('Certificate', Data) -> dec_Certificate(Data); decode_disp('Version', Data) -> dec_Version(Data); decode_disp('CertificateSerialNumber', Data) -> dec_CertificateSerialNumber(Data); decode_disp('AlgorithmIdentifier', Data) -> dec_AlgorithmIdentifier(Data); decode_disp('Validity', Data) -> dec_Validity(Data); decode_disp('SubjectPublicKeyInfo', Data) -> dec_SubjectPublicKeyInfo(Data); decode_disp('Time', Data) -> dec_Time(Data); decode_disp('Extensions', Data) -> dec_Extensions(Data); decode_disp('Extension', Data) -> dec_Extension(Data); decode_disp('Certificates', Data) -> dec_Certificates(Data); decode_disp('ForwardCertificationPath', Data) -> dec_ForwardCertificationPath(Data); decode_disp('CrossCertificates', Data) -> dec_CrossCertificates(Data); decode_disp('CertificationPath', Data) -> dec_CertificationPath(Data); decode_disp('CertificatePair', Data) -> dec_CertificatePair(Data); decode_disp('CertificateList', Data) -> dec_CertificateList(Data); decode_disp('AttributeCertificationPath', Data) -> dec_AttributeCertificationPath(Data); decode_disp('ACPathData', Data) -> dec_ACPathData(Data); decode_disp('AttributeCertificate', Data) -> dec_AttributeCertificate(Data); decode_disp('AttributeCertificateInfo', Data) -> dec_AttributeCertificateInfo(Data); decode_disp('IssuerSerial', Data) -> dec_IssuerSerial(Data); decode_disp('AttCertValidityPeriod', Data) -> dec_AttCertValidityPeriod(Data); decode_disp('AttributeCertificateAssertion', Data) -> dec_AttributeCertificateAssertion(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. %%================================ %% Certificate %%================================ enc_Certificate(Val) -> enc_Certificate(Val, [<<48>>]). enc_Certificate(Val, TagIn) -> {_,Cindex1,Cindex2,Cindex3} = Val, %%------------------------------------------------- %% attribute toBeSigned(1) with type SEQUENCE %%------------------------------------------------- {EncBytes1,EncLen1} = 'enc_Certificate_toBeSigned'(Cindex1, [<<48>>]), %%------------------------------------------------- %% attribute algorithmIdentifier(2) External AuthenticationFramework:AlgorithmIdentifier %%------------------------------------------------- {EncBytes2,EncLen2} = 'enc_AlgorithmIdentifier'(Cindex2, [<<48>>]), %%------------------------------------------------- %% attribute encrypted(3) with type BIT STRING %%------------------------------------------------- {EncBytes3,EncLen3} = encode_unnamed_bit_string(Cindex3, [<<3>>]), BytesSoFar = [EncBytes1, EncBytes2, EncBytes3], LenSoFar = EncLen1 + EncLen2 + EncLen3, encode_tags(TagIn, BytesSoFar, LenSoFar). %%================================ %% Certificate_toBeSigned %%================================ enc_Certificate_toBeSigned(Val, TagIn) -> {_,Cindex1,Cindex2,Cindex3,Cindex4,Cindex5,Cindex6,Cindex7,Cindex8,Cindex9,Cindex10} = Val, %%------------------------------------------------- %% attribute version(1) with type INTEGER DEFAULT = 0 %%------------------------------------------------- {EncBytes1,EncLen1} = case Cindex1 of asn1_DEFAULT -> {<<>>,0}; _ when Cindex1 =:= 0 -> {<<>>,0}; _ -> encode_integer(Cindex1, [{v1,0},{v2,1},{v3,2}], [<<2>>,<<160>>]) end, %%------------------------------------------------- %% attribute serialNumber(2) with type INTEGER %%------------------------------------------------- {EncBytes2,EncLen2} = encode_integer(Cindex2, [<<2>>]), %%------------------------------------------------- %% attribute signature(3) External AuthenticationFramework:AlgorithmIdentifier %%------------------------------------------------- {EncBytes3,EncLen3} = 'enc_AlgorithmIdentifier'(Cindex3, [<<48>>]), %%------------------------------------------------- %% attribute issuer(4) External InformationFramework:Name %%------------------------------------------------- {EncBytes4,EncLen4} = 'InformationFramework':'enc_Name'(Cindex4, []), %%------------------------------------------------- %% attribute validity(5) External AuthenticationFramework:Validity %%------------------------------------------------- {EncBytes5,EncLen5} = 'enc_Validity'(Cindex5, [<<48>>]), %%------------------------------------------------- %% attribute subject(6) External InformationFramework:Name %%------------------------------------------------- {EncBytes6,EncLen6} = 'InformationFramework':'enc_Name'(Cindex6, []), %%------------------------------------------------- %% attribute subjectPublicKeyInfo(7) External AuthenticationFramework:SubjectPublicKeyInfo %%------------------------------------------------- {EncBytes7,EncLen7} = 'enc_SubjectPublicKeyInfo'(Cindex7, [<<48>>]), %%------------------------------------------------- %% attribute issuerUniqueIdentifier(8) with type BIT STRING OPTIONAL %%------------------------------------------------- {EncBytes8,EncLen8} = case Cindex8 of asn1_NOVALUE -> {<<>>,0}; _ -> encode_unnamed_bit_string(Cindex8, [<<129>>]) end, %%------------------------------------------------- %% attribute subjectUniqueIdentifier(9) with type BIT STRING OPTIONAL %%------------------------------------------------- {EncBytes9,EncLen9} = case Cindex9 of asn1_NOVALUE -> {<<>>,0}; _ -> encode_unnamed_bit_string(Cindex9, [<<130>>]) end, %%------------------------------------------------- %% attribute extensions(10) External AuthenticationFramework:Extensions OPTIONAL %%------------------------------------------------- {EncBytes10,EncLen10} = case Cindex10 of asn1_NOVALUE -> {<<>>,0}; _ -> 'enc_Extensions'(Cindex10, [<<48>>,<<163>>]) end, BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4, EncBytes5, EncBytes6, EncBytes7, EncBytes8, EncBytes9, EncBytes10], LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4 + EncLen5 + EncLen6 + EncLen7 + EncLen8 + EncLen9 + EncLen10, encode_tags(TagIn, BytesSoFar, LenSoFar). dec_Certificate(Tlv) -> dec_Certificate(Tlv, [16]). dec_Certificate(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute toBeSigned(1) with type SEQUENCE %%------------------------------------------------- [V1|Tlv2] = Tlv1, Term1 = 'dec_Certificate_toBeSigned'(V1, [16]), %%------------------------------------------------- %% attribute algorithmIdentifier(2) External AuthenticationFramework:AlgorithmIdentifier %%------------------------------------------------- [V2|Tlv3] = Tlv2, Term2 = 'dec_AlgorithmIdentifier'(V2, [16]), %%------------------------------------------------- %% attribute encrypted(3) with type BIT STRING %%------------------------------------------------- [V3|Tlv4] = Tlv3, Term3 = decode_native_bit_string(V3, [3]), case Tlv4 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv4}}}) % extra fields not allowed end, Res1 = {'Certificate',Term1,Term2,Term3}, Res1. 'dec_Certificate_toBeSigned'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute version(1) with type INTEGER DEFAULT = 0 %%------------------------------------------------- {Term1,Tlv2} = case Tlv1 of [{131072,V1}|TempTlv2] -> {begin Val1 = decode_integer(V1, [2]), number2name(Val1, [{v1,0},{v2,1},{v3,2}]) end , TempTlv2}; _ -> {0,Tlv1} end, %%------------------------------------------------- %% attribute serialNumber(2) with type INTEGER %%------------------------------------------------- [V2|Tlv3] = Tlv2, Term2 = decode_integer(V2, [2]), %%------------------------------------------------- %% attribute signature(3) External AuthenticationFramework:AlgorithmIdentifier %%------------------------------------------------- [V3|Tlv4] = Tlv3, Term3 = 'dec_AlgorithmIdentifier'(V3, [16]), %%------------------------------------------------- %% attribute issuer(4) External InformationFramework:Name %%------------------------------------------------- [V4|Tlv5] = Tlv4, Term4 = 'InformationFramework':'dec_Name'(V4, []), %%------------------------------------------------- %% attribute validity(5) External AuthenticationFramework:Validity %%------------------------------------------------- [V5|Tlv6] = Tlv5, Term5 = 'dec_Validity'(V5, [16]), %%------------------------------------------------- %% attribute subject(6) External InformationFramework:Name %%------------------------------------------------- [V6|Tlv7] = Tlv6, Term6 = 'InformationFramework':'dec_Name'(V6, []), %%------------------------------------------------- %% attribute subjectPublicKeyInfo(7) External AuthenticationFramework:SubjectPublicKeyInfo %%------------------------------------------------- [V7|Tlv8] = Tlv7, Term7 = 'dec_SubjectPublicKeyInfo'(V7, [16]), %%------------------------------------------------- %% attribute issuerUniqueIdentifier(8) with type BIT STRING OPTIONAL %%------------------------------------------------- {Term8,Tlv9} = case Tlv8 of [{131073,V8}|TempTlv9] -> {decode_native_bit_string(V8, []), TempTlv9}; _ -> { asn1_NOVALUE, Tlv8} end, %%------------------------------------------------- %% attribute subjectUniqueIdentifier(9) with type BIT STRING OPTIONAL %%------------------------------------------------- {Term9,Tlv10} = case Tlv9 of [{131074,V9}|TempTlv10] -> {decode_native_bit_string(V9, []), TempTlv10}; _ -> { asn1_NOVALUE, Tlv9} end, %%------------------------------------------------- %% attribute extensions(10) External AuthenticationFramework:Extensions OPTIONAL %%------------------------------------------------- {Term10,Tlv11} = case Tlv10 of [{131075,V10}|TempTlv11] -> {'dec_Extensions'(V10, [16]), TempTlv11}; _ -> { asn1_NOVALUE, Tlv10} end, case Tlv11 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv11}}}) % extra fields not allowed end, Res1 = {'Certificate_toBeSigned',Term1,Term2,Term3,Term4,Term5,Term6,Term7,Term8,Term9,Term10}, Res1. %%================================ %% Version %%================================ enc_Version(Val) -> enc_Version(Val, [<<2>>]). enc_Version(Val, TagIn) -> encode_integer(Val, [{v1,0},{v2,1},{v3,2}], TagIn). dec_Version(Tlv) -> dec_Version(Tlv, [2]). dec_Version(Tlv, TagIn) -> begin Val1 = decode_integer(Tlv, TagIn), number2name(Val1, [{v1,0},{v2,1},{v3,2}]) end . %%================================ %% CertificateSerialNumber %%================================ enc_CertificateSerialNumber(Val) -> enc_CertificateSerialNumber(Val, [<<2>>]). enc_CertificateSerialNumber(Val, TagIn) -> encode_integer(Val, TagIn). dec_CertificateSerialNumber(Tlv) -> dec_CertificateSerialNumber(Tlv, [2]). dec_CertificateSerialNumber(Tlv, TagIn) -> decode_integer(Tlv, TagIn). %%================================ %% AlgorithmIdentifier %%================================ enc_AlgorithmIdentifier(Val) -> enc_AlgorithmIdentifier(Val, [<<48>>]). enc_AlgorithmIdentifier(Val, TagIn) -> {_,Cindex1,Cindex2} = Val, Objalgorithm = 'AuthenticationFramework':'getenc_SupportedAlgorithms'( Cindex1), %%------------------------------------------------- %% attribute algorithm(1) with type OBJECT IDENTIFIER %%------------------------------------------------- {EncBytes1,EncLen1} = encode_object_identifier(Cindex1, [<<6>>]), %%------------------------------------------------- %% attribute parameters(2) with type typefieldType OPTIONAL %%------------------------------------------------- {EncBytes2,EncLen2} = case Cindex2 of asn1_NOVALUE -> {<<>>,0}; _ -> {TmpBytes2,_ } = Objalgorithm('Type', Cindex2, []), encode_open_type(TmpBytes2, []) end, BytesSoFar = [EncBytes1, EncBytes2], LenSoFar = EncLen1 + EncLen2, encode_tags(TagIn, BytesSoFar, LenSoFar). dec_AlgorithmIdentifier(Tlv) -> dec_AlgorithmIdentifier(Tlv, [16]). dec_AlgorithmIdentifier(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute algorithm(1) with type OBJECT IDENTIFIER %%------------------------------------------------- [V1|Tlv2] = Tlv1, Term1 = decode_object_identifier(V1, [6]), %%------------------------------------------------- %% attribute parameters(2) with type typefieldType OPTIONAL %%------------------------------------------------- {Tmpterm1,Tlv3} = case Tlv2 of [V2|TempTlv3] -> {decode_open_type(V2, []), TempTlv3}; _ -> { asn1_NOVALUE, Tlv2} end, DecObjalgorithmTerm1 = 'AuthenticationFramework':'getdec_SupportedAlgorithms'(Term1), Term2 = case Tmpterm1 of asn1_NOVALUE ->asn1_NOVALUE; _ -> case (catch DecObjalgorithmTerm1('Type', Tmpterm1, [])) of {'EXIT', Reason1} -> exit({'Type not compatible with table constraint',Reason1}); Tmpterm2 -> Tmpterm2 end end, case Tlv3 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv3}}}) % extra fields not allowed end, Res1 = {'AlgorithmIdentifier',Term1,Term2}, Res1. %%================================ %% Validity %%================================ enc_Validity(Val) -> enc_Validity(Val, [<<48>>]). enc_Validity(Val, TagIn) -> {_,Cindex1,Cindex2} = Val, %%------------------------------------------------- %% attribute notBefore(1) External AuthenticationFramework:Time %%------------------------------------------------- {EncBytes1,EncLen1} = 'enc_Time'(Cindex1, []), %%------------------------------------------------- %% attribute notAfter(2) External AuthenticationFramework:Time %%------------------------------------------------- {EncBytes2,EncLen2} = 'enc_Time'(Cindex2, []), BytesSoFar = [EncBytes1, EncBytes2], LenSoFar = EncLen1 + EncLen2, encode_tags(TagIn, BytesSoFar, LenSoFar). dec_Validity(Tlv) -> dec_Validity(Tlv, [16]). dec_Validity(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute notBefore(1) External AuthenticationFramework:Time %%------------------------------------------------- [V1|Tlv2] = Tlv1, Term1 = 'dec_Time'(V1, []), %%------------------------------------------------- %% attribute notAfter(2) External AuthenticationFramework:Time %%------------------------------------------------- [V2|Tlv3] = Tlv2, Term2 = 'dec_Time'(V2, []), case Tlv3 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv3}}}) % extra fields not allowed end, Res1 = {'Validity',Term1,Term2}, Res1. %%================================ %% SubjectPublicKeyInfo %%================================ enc_SubjectPublicKeyInfo(Val) -> enc_SubjectPublicKeyInfo(Val, [<<48>>]). enc_SubjectPublicKeyInfo(Val, TagIn) -> {_,Cindex1,Cindex2} = Val, %%------------------------------------------------- %% attribute algorithm(1) External AuthenticationFramework:AlgorithmIdentifier %%------------------------------------------------- {EncBytes1,EncLen1} = 'enc_AlgorithmIdentifier'(Cindex1, [<<48>>]), %%------------------------------------------------- %% attribute subjectPublicKey(2) with type BIT STRING %%------------------------------------------------- {EncBytes2,EncLen2} = encode_unnamed_bit_string(Cindex2, [<<3>>]), BytesSoFar = [EncBytes1, EncBytes2], LenSoFar = EncLen1 + EncLen2, encode_tags(TagIn, BytesSoFar, LenSoFar). dec_SubjectPublicKeyInfo(Tlv) -> dec_SubjectPublicKeyInfo(Tlv, [16]). dec_SubjectPublicKeyInfo(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute algorithm(1) External AuthenticationFramework:AlgorithmIdentifier %%------------------------------------------------- [V1|Tlv2] = Tlv1, Term1 = 'dec_AlgorithmIdentifier'(V1, [16]), %%------------------------------------------------- %% attribute subjectPublicKey(2) with type BIT STRING %%------------------------------------------------- [V2|Tlv3] = Tlv2, Term2 = decode_native_bit_string(V2, [3]), case Tlv3 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv3}}}) % extra fields not allowed end, Res1 = {'SubjectPublicKeyInfo',Term1,Term2}, Res1. %%================================ %% Time %%================================ enc_Time(Val) -> enc_Time(Val, []). enc_Time(Val, TagIn) -> {EncBytes,EncLen} = case element(1,Val) of utcTime -> encode_restricted_string(element(2,Val), [<<23>>]); generalizedTime -> encode_restricted_string(element(2,Val), [<<24>>]); Else -> exit({error,{asn1,{invalid_choice_type,Else}}}) end, encode_tags(TagIn, EncBytes, EncLen). dec_Time(Tlv) -> dec_Time(Tlv, []). dec_Time(Tlv, TagIn) -> Tlv1 = match_tags(Tlv, TagIn), case (case Tlv1 of [CtempTlv1] -> CtempTlv1; _ -> Tlv1 end) of %% 'utcTime' {23, V1} -> {utcTime, begin binary_to_list(decode_restricted_string(V1, [])) end }; %% 'generalizedTime' {24, V1} -> {generalizedTime, begin binary_to_list(decode_restricted_string(V1, [])) end }; Else -> exit({error,{asn1,{invalid_choice_tag,Else}}}) end . %%================================ %% Extensions %%================================ enc_Extensions(Val) -> enc_Extensions(Val, [<<48>>]). enc_Extensions(Val, TagIn) -> {EncBytes,EncLen} = 'enc_Extensions_components'(Val,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_Extensions_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_Extensions_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = 'enc_Extension'(H, [<<48>>]), 'enc_Extensions_components'(T,[EncBytes|AccBytes], AccLen + EncLen). dec_Extensions(Tlv) -> dec_Extensions(Tlv, [16]). dec_Extensions(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), ['dec_Extension'(V1, [16]) || V1 <- Tlv1]. %%================================ %% Extension %%================================ enc_Extension(Val) -> enc_Extension(Val, [<<48>>]). enc_Extension(Val, TagIn) -> {_,Cindex1,Cindex2,Cindex3} = Val, %%------------------------------------------------- %% attribute extnId(1) with type OBJECT IDENTIFIER %%------------------------------------------------- {EncBytes1,EncLen1} = encode_object_identifier(Cindex1, [<<6>>]), %%------------------------------------------------- %% attribute critical(2) with type BOOLEAN DEFAULT = false %%------------------------------------------------- {EncBytes2,EncLen2} = case Cindex2 of asn1_DEFAULT -> {<<>>,0}; _ when Cindex2 =:= false -> {<<>>,0}; _ -> encode_boolean(Cindex2, [<<1>>]) end, %%------------------------------------------------- %% attribute extnValue(3) with type OCTET STRING %%------------------------------------------------- {EncBytes3,EncLen3} = encode_restricted_string(Cindex3, [<<4>>]), BytesSoFar = [EncBytes1, EncBytes2, EncBytes3], LenSoFar = EncLen1 + EncLen2 + EncLen3, encode_tags(TagIn, BytesSoFar, LenSoFar). dec_Extension(Tlv) -> dec_Extension(Tlv, [16]). dec_Extension(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute extnId(1) with type OBJECT IDENTIFIER %%------------------------------------------------- [V1|Tlv2] = Tlv1, Term1 = decode_object_identifier(V1, [6]), %%------------------------------------------------- %% attribute critical(2) with type BOOLEAN DEFAULT = false %%------------------------------------------------- {Term2,Tlv3} = case Tlv2 of [{1,V2}|TempTlv3] -> {decode_boolean(V2, []), TempTlv3}; _ -> {false,Tlv2} end, %%------------------------------------------------- %% attribute extnValue(3) with type OCTET STRING %%------------------------------------------------- [V3|Tlv4] = Tlv3, Term3 = decode_octet_string(V3, [4]), case Tlv4 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv4}}}) % extra fields not allowed end, Res1 = {'Extension',Term1,Term2,Term3}, Res1. %%================================ %% Certificates %%================================ enc_Certificates(Val) -> enc_Certificates(Val, [<<48>>]). enc_Certificates(Val, TagIn) -> {_,Cindex1,Cindex2} = Val, %%------------------------------------------------- %% attribute userCertificate(1) External AuthenticationFramework:Certificate %%------------------------------------------------- {EncBytes1,EncLen1} = 'enc_Certificate'(Cindex1, [<<48>>]), %%------------------------------------------------- %% attribute certificationPath(2) External AuthenticationFramework:ForwardCertificationPath OPTIONAL %%------------------------------------------------- {EncBytes2,EncLen2} = case Cindex2 of asn1_NOVALUE -> {<<>>,0}; _ -> 'enc_ForwardCertificationPath'(Cindex2, [<<48>>]) end, BytesSoFar = [EncBytes1, EncBytes2], LenSoFar = EncLen1 + EncLen2, encode_tags(TagIn, BytesSoFar, LenSoFar). dec_Certificates(Tlv) -> dec_Certificates(Tlv, [16]). dec_Certificates(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute userCertificate(1) External AuthenticationFramework:Certificate %%------------------------------------------------- [V1|Tlv2] = Tlv1, Term1 = 'dec_Certificate'(V1, [16]), %%------------------------------------------------- %% attribute certificationPath(2) External AuthenticationFramework:ForwardCertificationPath OPTIONAL %%------------------------------------------------- {Term2,Tlv3} = case Tlv2 of [{16,V2}|TempTlv3] -> {'dec_ForwardCertificationPath'(V2, []), TempTlv3}; _ -> { asn1_NOVALUE, Tlv2} end, case Tlv3 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv3}}}) % extra fields not allowed end, Res1 = {'Certificates',Term1,Term2}, Res1. %%================================ %% ForwardCertificationPath %%================================ enc_ForwardCertificationPath(Val) -> enc_ForwardCertificationPath(Val, [<<48>>]). enc_ForwardCertificationPath(Val, TagIn) -> {EncBytes,EncLen} = 'enc_ForwardCertificationPath_components'(Val,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_ForwardCertificationPath_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_ForwardCertificationPath_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = 'enc_CrossCertificates'(H, [<<49>>]), 'enc_ForwardCertificationPath_components'(T,[EncBytes|AccBytes], AccLen + EncLen). dec_ForwardCertificationPath(Tlv) -> dec_ForwardCertificationPath(Tlv, [16]). dec_ForwardCertificationPath(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), ['dec_CrossCertificates'(V1, [17]) || V1 <- Tlv1]. %%================================ %% CrossCertificates %%================================ enc_CrossCertificates(Val) -> enc_CrossCertificates(Val, [<<49>>]). enc_CrossCertificates(Val, TagIn) -> {EncBytes,EncLen} = 'enc_CrossCertificates_components'(Val,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_CrossCertificates_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_CrossCertificates_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = 'enc_Certificate'(H, [<<48>>]), 'enc_CrossCertificates_components'(T,[EncBytes|AccBytes], AccLen + EncLen). dec_CrossCertificates(Tlv) -> dec_CrossCertificates(Tlv, [17]). dec_CrossCertificates(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), ['dec_Certificate'(V1, [16]) || V1 <- Tlv1]. %%================================ %% CertificationPath %%================================ enc_CertificationPath(Val) -> enc_CertificationPath(Val, [<<48>>]). enc_CertificationPath(Val, TagIn) -> {_,Cindex1,Cindex2} = Val, %%------------------------------------------------- %% attribute userCertificate(1) External AuthenticationFramework:Certificate %%------------------------------------------------- {EncBytes1,EncLen1} = 'enc_Certificate'(Cindex1, [<<48>>]), %%------------------------------------------------- %% attribute theCACertificates(2) with type SEQUENCE OF OPTIONAL %%------------------------------------------------- {EncBytes2,EncLen2} = case Cindex2 of asn1_NOVALUE -> {<<>>,0}; _ -> 'enc_CertificationPath_theCACertificates'(Cindex2, [<<48>>]) end, BytesSoFar = [EncBytes1, EncBytes2], LenSoFar = EncLen1 + EncLen2, encode_tags(TagIn, BytesSoFar, LenSoFar). %%================================ %% CertificationPath_theCACertificates %%================================ enc_CertificationPath_theCACertificates(Val, TagIn) -> {EncBytes,EncLen} = 'enc_CertificationPath_theCACertificates_components'(Val,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_CertificationPath_theCACertificates_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_CertificationPath_theCACertificates_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = 'enc_CertificatePair'(H, [<<48>>]), 'enc_CertificationPath_theCACertificates_components'(T,[EncBytes|AccBytes], AccLen + EncLen). dec_CertificationPath(Tlv) -> dec_CertificationPath(Tlv, [16]). dec_CertificationPath(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute userCertificate(1) External AuthenticationFramework:Certificate %%------------------------------------------------- [V1|Tlv2] = Tlv1, Term1 = 'dec_Certificate'(V1, [16]), %%------------------------------------------------- %% attribute theCACertificates(2) with type SEQUENCE OF OPTIONAL %%------------------------------------------------- {Term2,Tlv3} = case Tlv2 of [{16,V2}|TempTlv3] -> {'dec_CertificationPath_theCACertificates'(V2, []), TempTlv3}; _ -> { asn1_NOVALUE, Tlv2} end, case Tlv3 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv3}}}) % extra fields not allowed end, Res1 = {'CertificationPath',Term1,Term2}, Res1. 'dec_CertificationPath_theCACertificates'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), ['dec_CertificatePair'(V1, [16]) || V1 <- Tlv1]. %%================================ %% CertificatePair %%================================ enc_CertificatePair(Val) -> enc_CertificatePair(Val, [<<48>>]). enc_CertificatePair(Val, TagIn) -> {_,Cindex1,Cindex2} = Val, %%------------------------------------------------- %% attribute issuedByThisCA(1) External AuthenticationFramework:Certificate OPTIONAL %%------------------------------------------------- {EncBytes1,EncLen1} = case Cindex1 of asn1_NOVALUE -> {<<>>,0}; _ -> 'enc_Certificate'(Cindex1, [<<48>>,<<160>>]) end, %%------------------------------------------------- %% attribute issuedToThisCA(2) External AuthenticationFramework:Certificate OPTIONAL %%------------------------------------------------- {EncBytes2,EncLen2} = case Cindex2 of asn1_NOVALUE -> {<<>>,0}; _ -> 'enc_Certificate'(Cindex2, [<<48>>,<<161>>]) end, BytesSoFar = [EncBytes1, EncBytes2], LenSoFar = EncLen1 + EncLen2, encode_tags(TagIn, BytesSoFar, LenSoFar). dec_CertificatePair(Tlv) -> dec_CertificatePair(Tlv, [16]). dec_CertificatePair(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute issuedByThisCA(1) External AuthenticationFramework:Certificate OPTIONAL %%------------------------------------------------- {Term1,Tlv2} = case Tlv1 of [{131072,V1}|TempTlv2] -> {'dec_Certificate'(V1, [16]), TempTlv2}; _ -> { asn1_NOVALUE, Tlv1} end, %%------------------------------------------------- %% attribute issuedToThisCA(2) External AuthenticationFramework:Certificate OPTIONAL %%------------------------------------------------- {Term2,Tlv3} = case Tlv2 of [{131073,V2}|TempTlv3] -> {'dec_Certificate'(V2, [16]), TempTlv3}; _ -> { asn1_NOVALUE, Tlv2} end, case Tlv3 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv3}}}) % extra fields not allowed end, Res1 = {'CertificatePair',Term1,Term2}, Res1. %%================================ %% CertificateList %%================================ enc_CertificateList(Val) -> enc_CertificateList(Val, [<<48>>]). enc_CertificateList(Val, TagIn) -> {_,Cindex1,Cindex2,Cindex3} = Val, %%------------------------------------------------- %% attribute toBeSigned(1) with type SEQUENCE %%------------------------------------------------- {EncBytes1,EncLen1} = 'enc_CertificateList_toBeSigned'(Cindex1, [<<48>>]), %%------------------------------------------------- %% attribute algorithmIdentifier(2) External AuthenticationFramework:AlgorithmIdentifier %%------------------------------------------------- {EncBytes2,EncLen2} = 'enc_AlgorithmIdentifier'(Cindex2, [<<48>>]), %%------------------------------------------------- %% attribute encrypted(3) with type BIT STRING %%------------------------------------------------- {EncBytes3,EncLen3} = encode_unnamed_bit_string(Cindex3, [<<3>>]), BytesSoFar = [EncBytes1, EncBytes2, EncBytes3], LenSoFar = EncLen1 + EncLen2 + EncLen3, encode_tags(TagIn, BytesSoFar, LenSoFar). %%================================ %% CertificateList_toBeSigned %%================================ enc_CertificateList_toBeSigned(Val, TagIn) -> {_,Cindex1,Cindex2,Cindex3,Cindex4,Cindex5,Cindex6,Cindex7} = Val, %%------------------------------------------------- %% attribute version(1) with type INTEGER OPTIONAL %%------------------------------------------------- {EncBytes1,EncLen1} = case Cindex1 of asn1_NOVALUE -> {<<>>,0}; _ -> encode_integer(Cindex1, [{v1,0},{v2,1},{v3,2}], [<<2>>]) end, %%------------------------------------------------- %% attribute signature(2) External AuthenticationFramework:AlgorithmIdentifier %%------------------------------------------------- {EncBytes2,EncLen2} = 'enc_AlgorithmIdentifier'(Cindex2, [<<48>>]), %%------------------------------------------------- %% attribute issuer(3) External InformationFramework:Name %%------------------------------------------------- {EncBytes3,EncLen3} = 'InformationFramework':'enc_Name'(Cindex3, []), %%------------------------------------------------- %% attribute thisUpdate(4) External AuthenticationFramework:Time %%------------------------------------------------- {EncBytes4,EncLen4} = 'enc_Time'(Cindex4, []), %%------------------------------------------------- %% attribute nextUpdate(5) External AuthenticationFramework:Time OPTIONAL %%------------------------------------------------- {EncBytes5,EncLen5} = case Cindex5 of asn1_NOVALUE -> {<<>>,0}; _ -> 'enc_Time'(Cindex5, []) end, %%------------------------------------------------- %% attribute revokedCertificates(6) with type SEQUENCE OF OPTIONAL %%------------------------------------------------- {EncBytes6,EncLen6} = case Cindex6 of asn1_NOVALUE -> {<<>>,0}; _ -> 'enc_CertificateList_toBeSigned_revokedCertificates'(Cindex6, [<<48>>]) end, %%------------------------------------------------- %% attribute crlExtensions(7) External AuthenticationFramework:Extensions OPTIONAL %%------------------------------------------------- {EncBytes7,EncLen7} = case Cindex7 of asn1_NOVALUE -> {<<>>,0}; _ -> 'enc_Extensions'(Cindex7, [<<48>>,<<160>>]) end, BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4, EncBytes5, EncBytes6, EncBytes7], LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4 + EncLen5 + EncLen6 + EncLen7, encode_tags(TagIn, BytesSoFar, LenSoFar). %%================================ %% CertificateList_toBeSigned_revokedCertificates %%================================ enc_CertificateList_toBeSigned_revokedCertificates(Val, TagIn) -> {EncBytes,EncLen} = 'enc_CertificateList_toBeSigned_revokedCertificates_components'(Val,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_CertificateList_toBeSigned_revokedCertificates_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_CertificateList_toBeSigned_revokedCertificates_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = 'enc_CertificateList_toBeSigned_revokedCertificates_SEQOF'(H, [<<48>>]), 'enc_CertificateList_toBeSigned_revokedCertificates_components'(T,[EncBytes|AccBytes], AccLen + EncLen). %%================================ %% CertificateList_toBeSigned_revokedCertificates_SEQOF %%================================ enc_CertificateList_toBeSigned_revokedCertificates_SEQOF(Val, TagIn) -> {_,Cindex1,Cindex2,Cindex3} = Val, %%------------------------------------------------- %% attribute userCertificate(1) with type INTEGER %%------------------------------------------------- {EncBytes1,EncLen1} = encode_integer(Cindex1, [<<2>>]), %%------------------------------------------------- %% attribute revocationDate(2) External AuthenticationFramework:Time %%------------------------------------------------- {EncBytes2,EncLen2} = 'enc_Time'(Cindex2, []), %%------------------------------------------------- %% attribute crlEntryExtensions(3) External AuthenticationFramework:Extensions OPTIONAL %%------------------------------------------------- {EncBytes3,EncLen3} = case Cindex3 of asn1_NOVALUE -> {<<>>,0}; _ -> 'enc_Extensions'(Cindex3, [<<48>>]) end, BytesSoFar = [EncBytes1, EncBytes2, EncBytes3], LenSoFar = EncLen1 + EncLen2 + EncLen3, encode_tags(TagIn, BytesSoFar, LenSoFar). dec_CertificateList(Tlv) -> dec_CertificateList(Tlv, [16]). dec_CertificateList(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute toBeSigned(1) with type SEQUENCE %%------------------------------------------------- [V1|Tlv2] = Tlv1, Term1 = 'dec_CertificateList_toBeSigned'(V1, [16]), %%------------------------------------------------- %% attribute algorithmIdentifier(2) External AuthenticationFramework:AlgorithmIdentifier %%------------------------------------------------- [V2|Tlv3] = Tlv2, Term2 = 'dec_AlgorithmIdentifier'(V2, [16]), %%------------------------------------------------- %% attribute encrypted(3) with type BIT STRING %%------------------------------------------------- [V3|Tlv4] = Tlv3, Term3 = decode_native_bit_string(V3, [3]), case Tlv4 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv4}}}) % extra fields not allowed end, Res1 = {'CertificateList',Term1,Term2,Term3}, Res1. 'dec_CertificateList_toBeSigned'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute version(1) with type INTEGER OPTIONAL %%------------------------------------------------- {Term1,Tlv2} = case Tlv1 of [{2,V1}|TempTlv2] -> {begin Val1 = decode_integer(V1, []), number2name(Val1, [{v1,0},{v2,1},{v3,2}]) end , TempTlv2}; _ -> { asn1_NOVALUE, Tlv1} end, %%------------------------------------------------- %% attribute signature(2) External AuthenticationFramework:AlgorithmIdentifier %%------------------------------------------------- [V2|Tlv3] = Tlv2, Term2 = 'dec_AlgorithmIdentifier'(V2, [16]), %%------------------------------------------------- %% attribute issuer(3) External InformationFramework:Name %%------------------------------------------------- [V3|Tlv4] = Tlv3, Term3 = 'InformationFramework':'dec_Name'(V3, []), %%------------------------------------------------- %% attribute thisUpdate(4) External AuthenticationFramework:Time %%------------------------------------------------- [V4|Tlv5] = Tlv4, Term4 = 'dec_Time'(V4, []), %%------------------------------------------------- %% attribute nextUpdate(5) External AuthenticationFramework:Time OPTIONAL %%------------------------------------------------- {Term5,Tlv6} = case Tlv5 of [V5 = {23,_}|TempTlv6] -> {'dec_Time'(V5, []), TempTlv6}; [V5 = {24,_}|TempTlv6] -> {'dec_Time'(V5, []), TempTlv6}; _ -> { asn1_NOVALUE, Tlv5} end, %%------------------------------------------------- %% attribute revokedCertificates(6) with type SEQUENCE OF OPTIONAL %%------------------------------------------------- {Term6,Tlv7} = case Tlv6 of [{16,V6}|TempTlv7] -> {'dec_CertificateList_toBeSigned_revokedCertificates'(V6, []), TempTlv7}; _ -> { asn1_NOVALUE, Tlv6} end, %%------------------------------------------------- %% attribute crlExtensions(7) External AuthenticationFramework:Extensions OPTIONAL %%------------------------------------------------- {Term7,Tlv8} = case Tlv7 of [{131072,V7}|TempTlv8] -> {'dec_Extensions'(V7, [16]), TempTlv8}; _ -> { asn1_NOVALUE, Tlv7} end, case Tlv8 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv8}}}) % extra fields not allowed end, Res1 = {'CertificateList_toBeSigned',Term1,Term2,Term3,Term4,Term5,Term6,Term7}, Res1. 'dec_CertificateList_toBeSigned_revokedCertificates'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), ['dec_CertificateList_toBeSigned_revokedCertificates_SEQOF'(V1, [16]) || V1 <- Tlv1]. 'dec_CertificateList_toBeSigned_revokedCertificates_SEQOF'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute userCertificate(1) with type INTEGER %%------------------------------------------------- [V1|Tlv2] = Tlv1, Term1 = decode_integer(V1, [2]), %%------------------------------------------------- %% attribute revocationDate(2) External AuthenticationFramework:Time %%------------------------------------------------- [V2|Tlv3] = Tlv2, Term2 = 'dec_Time'(V2, []), %%------------------------------------------------- %% attribute crlEntryExtensions(3) External AuthenticationFramework:Extensions OPTIONAL %%------------------------------------------------- {Term3,Tlv4} = case Tlv3 of [{16,V3}|TempTlv4] -> {'dec_Extensions'(V3, []), TempTlv4}; _ -> { asn1_NOVALUE, Tlv3} end, case Tlv4 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv4}}}) % extra fields not allowed end, Res1 = {'CertificateList_toBeSigned_revokedCertificates_SEQOF',Term1,Term2,Term3}, Res1. %%================================ %% AttributeCertificationPath %%================================ enc_AttributeCertificationPath(Val) -> enc_AttributeCertificationPath(Val, [<<48>>]). enc_AttributeCertificationPath(Val, TagIn) -> {_,Cindex1,Cindex2} = Val, %%------------------------------------------------- %% attribute attributeCertificate(1) External AuthenticationFramework:AttributeCertificate %%------------------------------------------------- {EncBytes1,EncLen1} = 'enc_AttributeCertificate'(Cindex1, [<<48>>]), %%------------------------------------------------- %% attribute acPath(2) with type SEQUENCE OF OPTIONAL %%------------------------------------------------- {EncBytes2,EncLen2} = case Cindex2 of asn1_NOVALUE -> {<<>>,0}; _ -> 'enc_AttributeCertificationPath_acPath'(Cindex2, [<<48>>]) end, BytesSoFar = [EncBytes1, EncBytes2], LenSoFar = EncLen1 + EncLen2, encode_tags(TagIn, BytesSoFar, LenSoFar). %%================================ %% AttributeCertificationPath_acPath %%================================ enc_AttributeCertificationPath_acPath(Val, TagIn) -> {EncBytes,EncLen} = 'enc_AttributeCertificationPath_acPath_components'(Val,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_AttributeCertificationPath_acPath_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_AttributeCertificationPath_acPath_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = 'enc_ACPathData'(H, [<<48>>]), 'enc_AttributeCertificationPath_acPath_components'(T,[EncBytes|AccBytes], AccLen + EncLen). dec_AttributeCertificationPath(Tlv) -> dec_AttributeCertificationPath(Tlv, [16]). dec_AttributeCertificationPath(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute attributeCertificate(1) External AuthenticationFramework:AttributeCertificate %%------------------------------------------------- [V1|Tlv2] = Tlv1, Term1 = 'dec_AttributeCertificate'(V1, [16]), %%------------------------------------------------- %% attribute acPath(2) with type SEQUENCE OF OPTIONAL %%------------------------------------------------- {Term2,Tlv3} = case Tlv2 of [{16,V2}|TempTlv3] -> {'dec_AttributeCertificationPath_acPath'(V2, []), TempTlv3}; _ -> { asn1_NOVALUE, Tlv2} end, case Tlv3 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv3}}}) % extra fields not allowed end, Res1 = {'AttributeCertificationPath',Term1,Term2}, Res1. 'dec_AttributeCertificationPath_acPath'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), ['dec_ACPathData'(V1, [16]) || V1 <- Tlv1]. %%================================ %% ACPathData %%================================ enc_ACPathData(Val) -> enc_ACPathData(Val, [<<48>>]). enc_ACPathData(Val, TagIn) -> {_,Cindex1,Cindex2} = Val, %%------------------------------------------------- %% attribute certificate(1) External AuthenticationFramework:Certificate OPTIONAL %%------------------------------------------------- {EncBytes1,EncLen1} = case Cindex1 of asn1_NOVALUE -> {<<>>,0}; _ -> 'enc_Certificate'(Cindex1, [<<48>>,<<160>>]) end, %%------------------------------------------------- %% attribute attributeCertificate(2) External AuthenticationFramework:AttributeCertificate OPTIONAL %%------------------------------------------------- {EncBytes2,EncLen2} = case Cindex2 of asn1_NOVALUE -> {<<>>,0}; _ -> 'enc_AttributeCertificate'(Cindex2, [<<48>>,<<161>>]) end, BytesSoFar = [EncBytes1, EncBytes2], LenSoFar = EncLen1 + EncLen2, encode_tags(TagIn, BytesSoFar, LenSoFar). dec_ACPathData(Tlv) -> dec_ACPathData(Tlv, [16]). dec_ACPathData(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute certificate(1) External AuthenticationFramework:Certificate OPTIONAL %%------------------------------------------------- {Term1,Tlv2} = case Tlv1 of [{131072,V1}|TempTlv2] -> {'dec_Certificate'(V1, [16]), TempTlv2}; _ -> { asn1_NOVALUE, Tlv1} end, %%------------------------------------------------- %% attribute attributeCertificate(2) External AuthenticationFramework:AttributeCertificate OPTIONAL %%------------------------------------------------- {Term2,Tlv3} = case Tlv2 of [{131073,V2}|TempTlv3] -> {'dec_AttributeCertificate'(V2, [16]), TempTlv3}; _ -> { asn1_NOVALUE, Tlv2} end, case Tlv3 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv3}}}) % extra fields not allowed end, Res1 = {'ACPathData',Term1,Term2}, Res1. %%================================ %% AttributeCertificate %%================================ enc_AttributeCertificate(Val) -> enc_AttributeCertificate(Val, [<<48>>]). enc_AttributeCertificate(Val, TagIn) -> {_,Cindex1,Cindex2,Cindex3} = Val, %%------------------------------------------------- %% attribute toBeSigned(1) External AuthenticationFramework:AttributeCertificateInfo %%------------------------------------------------- {EncBytes1,EncLen1} = 'enc_AttributeCertificateInfo'(Cindex1, [<<48>>]), %%------------------------------------------------- %% attribute algorithmIdentifier(2) External AuthenticationFramework:AlgorithmIdentifier %%------------------------------------------------- {EncBytes2,EncLen2} = 'enc_AlgorithmIdentifier'(Cindex2, [<<48>>]), %%------------------------------------------------- %% attribute encrypted(3) with type BIT STRING %%------------------------------------------------- {EncBytes3,EncLen3} = encode_unnamed_bit_string(Cindex3, [<<3>>]), BytesSoFar = [EncBytes1, EncBytes2, EncBytes3], LenSoFar = EncLen1 + EncLen2 + EncLen3, encode_tags(TagIn, BytesSoFar, LenSoFar). dec_AttributeCertificate(Tlv) -> dec_AttributeCertificate(Tlv, [16]). dec_AttributeCertificate(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute toBeSigned(1) External AuthenticationFramework:AttributeCertificateInfo %%------------------------------------------------- [V1|Tlv2] = Tlv1, Term1 = 'dec_AttributeCertificateInfo'(V1, [16]), %%------------------------------------------------- %% attribute algorithmIdentifier(2) External AuthenticationFramework:AlgorithmIdentifier %%------------------------------------------------- [V2|Tlv3] = Tlv2, Term2 = 'dec_AlgorithmIdentifier'(V2, [16]), %%------------------------------------------------- %% attribute encrypted(3) with type BIT STRING %%------------------------------------------------- [V3|Tlv4] = Tlv3, Term3 = decode_native_bit_string(V3, [3]), case Tlv4 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv4}}}) % extra fields not allowed end, Res1 = {'AttributeCertificate',Term1,Term2,Term3}, Res1. %%================================ %% AttributeCertificateInfo %%================================ enc_AttributeCertificateInfo(Val) -> enc_AttributeCertificateInfo(Val, [<<48>>]). enc_AttributeCertificateInfo(Val, TagIn) -> {_,Cindex1,Cindex2,Cindex3,Cindex4,Cindex5,Cindex6,Cindex7,Cindex8,Cindex9} = Val, %%------------------------------------------------- %% attribute version(1) with type INTEGER DEFAULT = 0 %%------------------------------------------------- {EncBytes1,EncLen1} = case Cindex1 of asn1_DEFAULT -> {<<>>,0}; _ when Cindex1 =:= 0 -> {<<>>,0}; _ -> encode_integer(Cindex1, [{v1,0},{v2,1},{v3,2}], [<<2>>]) end, %%------------------------------------------------- %% attribute subject(2) with type CHOICE %%------------------------------------------------- {EncBytes2,EncLen2} = 'enc_AttributeCertificateInfo_subject'(Cindex2, []), %%------------------------------------------------- %% attribute issuer(3) External CertificateExtensions:GeneralNames %%------------------------------------------------- {EncBytes3,EncLen3} = 'CertificateExtensions':'enc_GeneralNames'(Cindex3, [<<48>>]), %%------------------------------------------------- %% attribute signature(4) External AuthenticationFramework:AlgorithmIdentifier %%------------------------------------------------- {EncBytes4,EncLen4} = 'enc_AlgorithmIdentifier'(Cindex4, [<<48>>]), %%------------------------------------------------- %% attribute serialNumber(5) with type INTEGER %%------------------------------------------------- {EncBytes5,EncLen5} = encode_integer(Cindex5, [<<2>>]), %%------------------------------------------------- %% attribute attCertValidityPeriod(6) External AuthenticationFramework:AttCertValidityPeriod %%------------------------------------------------- {EncBytes6,EncLen6} = 'enc_AttCertValidityPeriod'(Cindex6, [<<48>>]), %%------------------------------------------------- %% attribute attributes(7) with type SEQUENCE OF %%------------------------------------------------- {EncBytes7,EncLen7} = 'enc_AttributeCertificateInfo_attributes'(Cindex7, [<<48>>]), %%------------------------------------------------- %% attribute issuerUniqueID(8) with type BIT STRING OPTIONAL %%------------------------------------------------- {EncBytes8,EncLen8} = case Cindex8 of asn1_NOVALUE -> {<<>>,0}; _ -> encode_unnamed_bit_string(Cindex8, [<<3>>]) end, %%------------------------------------------------- %% attribute extensions(9) External AuthenticationFramework:Extensions OPTIONAL %%------------------------------------------------- {EncBytes9,EncLen9} = case Cindex9 of asn1_NOVALUE -> {<<>>,0}; _ -> 'enc_Extensions'(Cindex9, [<<48>>]) 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). %%================================ %% AttributeCertificateInfo_subject %%================================ enc_AttributeCertificateInfo_subject(Val, TagIn) -> {EncBytes,EncLen} = case element(1,Val) of baseCertificateID -> 'enc_IssuerSerial'(element(2,Val), [<<48>>,<<160>>]); subjectName -> 'CertificateExtensions':'enc_GeneralNames'(element(2,Val), [<<48>>,<<161>>]); Else -> exit({error,{asn1,{invalid_choice_type,Else}}}) end, encode_tags(TagIn, EncBytes, EncLen). %%================================ %% AttributeCertificateInfo_attributes %%================================ enc_AttributeCertificateInfo_attributes(Val, TagIn) -> {EncBytes,EncLen} = 'enc_AttributeCertificateInfo_attributes_components'(Val,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_AttributeCertificateInfo_attributes_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_AttributeCertificateInfo_attributes_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = 'InformationFramework':'enc_Attribute'(H, [<<48>>]), 'enc_AttributeCertificateInfo_attributes_components'(T,[EncBytes|AccBytes], AccLen + EncLen). dec_AttributeCertificateInfo(Tlv) -> dec_AttributeCertificateInfo(Tlv, [16]). dec_AttributeCertificateInfo(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute version(1) with type INTEGER DEFAULT = 0 %%------------------------------------------------- {Term1,Tlv2} = case Tlv1 of [{2,V1}|TempTlv2] -> {begin Val1 = decode_integer(V1, []), number2name(Val1, [{v1,0},{v2,1},{v3,2}]) end , TempTlv2}; _ -> {0,Tlv1} end, %%------------------------------------------------- %% attribute subject(2) with type CHOICE %%------------------------------------------------- [V2|Tlv3] = Tlv2, Term2 = 'dec_AttributeCertificateInfo_subject'(V2, []), %%------------------------------------------------- %% attribute issuer(3) External CertificateExtensions:GeneralNames %%------------------------------------------------- [V3|Tlv4] = Tlv3, Term3 = 'CertificateExtensions':'dec_GeneralNames'(V3, [16]), %%------------------------------------------------- %% attribute signature(4) External AuthenticationFramework:AlgorithmIdentifier %%------------------------------------------------- [V4|Tlv5] = Tlv4, Term4 = 'dec_AlgorithmIdentifier'(V4, [16]), %%------------------------------------------------- %% attribute serialNumber(5) with type INTEGER %%------------------------------------------------- [V5|Tlv6] = Tlv5, Term5 = decode_integer(V5, [2]), %%------------------------------------------------- %% attribute attCertValidityPeriod(6) External AuthenticationFramework:AttCertValidityPeriod %%------------------------------------------------- [V6|Tlv7] = Tlv6, Term6 = 'dec_AttCertValidityPeriod'(V6, [16]), %%------------------------------------------------- %% attribute attributes(7) with type SEQUENCE OF %%------------------------------------------------- [V7|Tlv8] = Tlv7, Term7 = 'dec_AttributeCertificateInfo_attributes'(V7, [16]), %%------------------------------------------------- %% attribute issuerUniqueID(8) with type BIT STRING OPTIONAL %%------------------------------------------------- {Term8,Tlv9} = case Tlv8 of [{3,V8}|TempTlv9] -> {decode_native_bit_string(V8, []), TempTlv9}; _ -> { asn1_NOVALUE, Tlv8} end, %%------------------------------------------------- %% attribute extensions(9) External AuthenticationFramework:Extensions OPTIONAL %%------------------------------------------------- {Term9,Tlv10} = case Tlv9 of [{16,V9}|TempTlv10] -> {'dec_Extensions'(V9, []), TempTlv10}; _ -> { asn1_NOVALUE, Tlv9} end, case Tlv10 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv10}}}) % extra fields not allowed end, Res1 = {'AttributeCertificateInfo',Term1,Term2,Term3,Term4,Term5,Term6,Term7,Term8,Term9}, Res1. 'dec_AttributeCertificateInfo_subject'(Tlv, TagIn) -> Tlv1 = match_tags(Tlv, TagIn), case (case Tlv1 of [CtempTlv1] -> CtempTlv1; _ -> Tlv1 end) of %% 'baseCertificateID' {131072, V1} -> {baseCertificateID, 'dec_IssuerSerial'(V1, [16])}; %% 'subjectName' {131073, V1} -> {subjectName, 'CertificateExtensions':'dec_GeneralNames'(V1, [16])}; Else -> exit({error,{asn1,{invalid_choice_tag,Else}}}) end . 'dec_AttributeCertificateInfo_attributes'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), ['InformationFramework':'dec_Attribute'(V1, [16]) || V1 <- Tlv1]. %%================================ %% IssuerSerial %%================================ enc_IssuerSerial(Val) -> enc_IssuerSerial(Val, [<<48>>]). enc_IssuerSerial(Val, TagIn) -> {_,Cindex1,Cindex2,Cindex3} = Val, %%------------------------------------------------- %% attribute issuer(1) External CertificateExtensions:GeneralNames %%------------------------------------------------- {EncBytes1,EncLen1} = 'CertificateExtensions':'enc_GeneralNames'(Cindex1, [<<48>>]), %%------------------------------------------------- %% attribute serial(2) with type INTEGER %%------------------------------------------------- {EncBytes2,EncLen2} = encode_integer(Cindex2, [<<2>>]), %%------------------------------------------------- %% attribute issuerUID(3) with type BIT STRING OPTIONAL %%------------------------------------------------- {EncBytes3,EncLen3} = case Cindex3 of asn1_NOVALUE -> {<<>>,0}; _ -> encode_unnamed_bit_string(Cindex3, [<<3>>]) end, BytesSoFar = [EncBytes1, EncBytes2, EncBytes3], LenSoFar = EncLen1 + EncLen2 + EncLen3, encode_tags(TagIn, BytesSoFar, LenSoFar). dec_IssuerSerial(Tlv) -> dec_IssuerSerial(Tlv, [16]). dec_IssuerSerial(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute issuer(1) External CertificateExtensions:GeneralNames %%------------------------------------------------- [V1|Tlv2] = Tlv1, Term1 = 'CertificateExtensions':'dec_GeneralNames'(V1, [16]), %%------------------------------------------------- %% attribute serial(2) with type INTEGER %%------------------------------------------------- [V2|Tlv3] = Tlv2, Term2 = decode_integer(V2, [2]), %%------------------------------------------------- %% attribute issuerUID(3) with type BIT STRING OPTIONAL %%------------------------------------------------- {Term3,Tlv4} = case Tlv3 of [{3,V3}|TempTlv4] -> {decode_native_bit_string(V3, []), TempTlv4}; _ -> { asn1_NOVALUE, Tlv3} end, case Tlv4 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv4}}}) % extra fields not allowed end, Res1 = {'IssuerSerial',Term1,Term2,Term3}, Res1. %%================================ %% AttCertValidityPeriod %%================================ enc_AttCertValidityPeriod(Val) -> enc_AttCertValidityPeriod(Val, [<<48>>]). enc_AttCertValidityPeriod(Val, TagIn) -> {_,Cindex1,Cindex2} = Val, %%------------------------------------------------- %% attribute notBeforeTime(1) with type GeneralizedTime %%------------------------------------------------- {EncBytes1,EncLen1} = encode_restricted_string(Cindex1, [<<24>>]), %%------------------------------------------------- %% attribute notAfterTime(2) with type GeneralizedTime %%------------------------------------------------- {EncBytes2,EncLen2} = encode_restricted_string(Cindex2, [<<24>>]), BytesSoFar = [EncBytes1, EncBytes2], LenSoFar = EncLen1 + EncLen2, encode_tags(TagIn, BytesSoFar, LenSoFar). dec_AttCertValidityPeriod(Tlv) -> dec_AttCertValidityPeriod(Tlv, [16]). dec_AttCertValidityPeriod(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute notBeforeTime(1) with type GeneralizedTime %%------------------------------------------------- [V1|Tlv2] = Tlv1, Term1 = begin binary_to_list(decode_restricted_string(V1, [24])) end , %%------------------------------------------------- %% attribute notAfterTime(2) with type GeneralizedTime %%------------------------------------------------- [V2|Tlv3] = Tlv2, Term2 = begin binary_to_list(decode_restricted_string(V2, [24])) end , case Tlv3 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv3}}}) % extra fields not allowed end, Res1 = {'AttCertValidityPeriod',Term1,Term2}, Res1. %%================================ %% AttributeCertificateAssertion %%================================ enc_AttributeCertificateAssertion(Val) -> enc_AttributeCertificateAssertion(Val, [<<48>>]). enc_AttributeCertificateAssertion(Val, TagIn) -> {_,Cindex1,Cindex2,Cindex3,Cindex4} = Val, %%------------------------------------------------- %% attribute subject(1) with type CHOICE OPTIONAL %%------------------------------------------------- {EncBytes1,EncLen1} = case Cindex1 of asn1_NOVALUE -> {<<>>,0}; _ -> 'enc_AttributeCertificateAssertion_subject'(Cindex1, [<<160>>]) end, %%------------------------------------------------- %% attribute issuer(2) External InformationFramework:Name OPTIONAL %%------------------------------------------------- {EncBytes2,EncLen2} = case Cindex2 of asn1_NOVALUE -> {<<>>,0}; _ -> 'InformationFramework':'enc_Name'(Cindex2, [<<161>>]) end, %%------------------------------------------------- %% attribute attCertValidity(3) with type GeneralizedTime OPTIONAL %%------------------------------------------------- {EncBytes3,EncLen3} = case Cindex3 of asn1_NOVALUE -> {<<>>,0}; _ -> encode_restricted_string(Cindex3, [<<24>>,<<162>>]) end, %%------------------------------------------------- %% attribute attType(4) with type SET OF OPTIONAL %%------------------------------------------------- {EncBytes4,EncLen4} = case Cindex4 of asn1_NOVALUE -> {<<>>,0}; _ -> 'enc_AttributeCertificateAssertion_attType'(Cindex4, [<<49>>,<<163>>]) end, BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4], LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4, encode_tags(TagIn, BytesSoFar, LenSoFar). %%================================ %% AttributeCertificateAssertion_subject %%================================ enc_AttributeCertificateAssertion_subject(Val, TagIn) -> {EncBytes,EncLen} = case element(1,Val) of baseCertificateID -> 'enc_IssuerSerial'(element(2,Val), [<<48>>,<<160>>]); subjectName -> 'InformationFramework':'enc_Name'(element(2,Val), [<<161>>]); Else -> exit({error,{asn1,{invalid_choice_type,Else}}}) end, encode_tags(TagIn, EncBytes, EncLen). %%================================ %% AttributeCertificateAssertion_attType %%================================ enc_AttributeCertificateAssertion_attType(Val, TagIn) -> {EncBytes,EncLen} = 'enc_AttributeCertificateAssertion_attType_components'(Val,[],0), encode_tags(TagIn, EncBytes, EncLen). 'enc_AttributeCertificateAssertion_attType_components'([], AccBytes, AccLen) -> {lists:reverse(AccBytes),AccLen}; 'enc_AttributeCertificateAssertion_attType_components'([H|T],AccBytes, AccLen) -> {EncBytes,EncLen} = encode_object_identifier(H, [<<6>>]), 'enc_AttributeCertificateAssertion_attType_components'(T,[EncBytes|AccBytes], AccLen + EncLen). dec_AttributeCertificateAssertion(Tlv) -> dec_AttributeCertificateAssertion(Tlv, [16]). dec_AttributeCertificateAssertion(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), %%------------------------------------------------- %% attribute subject(1) with type CHOICE OPTIONAL %%------------------------------------------------- {Term1,Tlv2} = case Tlv1 of [{131072,V1}|TempTlv2] -> {'dec_AttributeCertificateAssertion_subject'(V1, []), TempTlv2}; _ -> { asn1_NOVALUE, Tlv1} end, %%------------------------------------------------- %% attribute issuer(2) External InformationFramework:Name OPTIONAL %%------------------------------------------------- {Term2,Tlv3} = case Tlv2 of [{131073,V2}|TempTlv3] -> {'InformationFramework':'dec_Name'(V2, []), TempTlv3}; _ -> { asn1_NOVALUE, Tlv2} end, %%------------------------------------------------- %% attribute attCertValidity(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 attType(4) with type SET OF OPTIONAL %%------------------------------------------------- {Term4,Tlv5} = case Tlv4 of [{131075,V4}|TempTlv5] -> {'dec_AttributeCertificateAssertion_attType'(V4, [17]), TempTlv5}; _ -> { asn1_NOVALUE, Tlv4} end, case Tlv5 of [] -> true;_ -> exit({error,{asn1, {unexpected,Tlv5}}}) % extra fields not allowed end, Res1 = {'AttributeCertificateAssertion',Term1,Term2,Term3,Term4}, Res1. 'dec_AttributeCertificateAssertion_subject'(Tlv, TagIn) -> Tlv1 = match_tags(Tlv, TagIn), case (case Tlv1 of [CtempTlv1] -> CtempTlv1; _ -> Tlv1 end) of %% 'baseCertificateID' {131072, V1} -> {baseCertificateID, 'dec_IssuerSerial'(V1, [16])}; %% 'subjectName' {131073, V1} -> {subjectName, 'InformationFramework':'dec_Name'(V1, [])}; Else -> exit({error,{asn1,{invalid_choice_tag,Else}}}) end . 'dec_AttributeCertificateAssertion_attType'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%------------------------------------------------- Tlv1 = match_tags(Tlv, TagIn), [decode_object_identifier(V1, [6]) || V1 <- Tlv1]. 'id-at-userPassword'() -> {2,5,4,35}. 'id-at-userCertificate'() -> {2,5,4,36}. 'id-at-cAcertificate'() -> {2,5,4,37}. 'id-at-authorityRevocationList'() -> {2,5,4,38}. 'id-at-certificateRevocationList'() -> {2,5,4,39}. 'id-at-crossCertificatePair'() -> {2,5,4,40}. 'id-at-attributeCertificate'() -> {2,5,4,58}. 'id-at-attributeCertificateRevocationList'() -> {2,5,4,59}. 'id-mr-attributeCertificateMatch'() -> {2,5,13,42}. %%================================ %% attributeCertificate %%================================ enc_attributeCertificate(derivation, _,_) -> exit({error,{'use of missing field in object', derivation}}); enc_attributeCertificate('Type', Val, _RestPrimFieldName) -> enc_AttributeCertificate(Val, [<<48>>]); enc_attributeCertificate('equality-match', Val, [H|T]) -> enc_attributeCertificateMatch(H, Val, T); enc_attributeCertificate('ordering-match', _,_) -> exit({error,{'use of missing field in object', 'ordering-match'}}); enc_attributeCertificate('substrings-match', _,_) -> exit({error,{'use of missing field in object', 'substrings-match'}}). dec_attributeCertificate(derivation, _,_) -> exit({error,{'illegal use of missing field in object', derivation}}); dec_attributeCertificate('Type', Bytes,_) -> Tlv = tlv_format(Bytes), dec_AttributeCertificate(Tlv, [16]); dec_attributeCertificate('equality-match', Bytes,[H|T]) -> dec_attributeCertificateMatch(H, Bytes, T); dec_attributeCertificate('ordering-match', _,_) -> exit({error,{'illegal use of missing field in object', 'ordering-match'}}); dec_attributeCertificate('substrings-match', _,_) -> exit({error,{'illegal use of missing field in object', 'substrings-match'}}). tlv_format(Bytes) when is_binary(Bytes) -> {Tlv,_} = ber_decode_nif(Bytes), Tlv; tlv_format(Bytes) -> Bytes. %%================================ %% attributeCertificateMatch %%================================ enc_attributeCertificateMatch('AssertionType', Val, _RestPrimFieldName) -> enc_AttributeCertificateAssertion(Val, [<<48>>]). dec_attributeCertificateMatch('AssertionType', Bytes,_) -> Tlv = tlv_format(Bytes), dec_AttributeCertificateAssertion(Tlv, [16]). %%================================ %% userPassword %%================================ enc_userPassword(derivation, _,_) -> exit({error,{'use of missing field in object', derivation}}); enc_userPassword('Type', Val, _RestPrimFieldName) -> encode_restricted_string(Val, [<<4>>]); enc_userPassword('equality-match', Val, [H|T]) -> 'SelectedAttributeTypes':enc_octetStringMatch(H, Val, T); enc_userPassword('ordering-match', _,_) -> exit({error,{'use of missing field in object', 'ordering-match'}}); enc_userPassword('substrings-match', _,_) -> exit({error,{'use of missing field in object', 'substrings-match'}}). dec_userPassword(derivation, _,_) -> exit({error,{'illegal use of missing field in object', derivation}}); dec_userPassword('Type', Bytes,_) -> Tlv = tlv_format(Bytes), begin Val1 = decode_octet_string(Tlv, [4]), C1 = byte_size(Val1), if 0 =< C1, C1 =< 128 -> Val1; true -> exit({error,{asn1,bad_range}}) end end; dec_userPassword('equality-match', Bytes,[H|T]) -> 'SelectedAttributeTypes':dec_octetStringMatch(H, Bytes, T); dec_userPassword('ordering-match', _,_) -> exit({error,{'illegal use of missing field in object', 'ordering-match'}}); dec_userPassword('substrings-match', _,_) -> exit({error,{'illegal use of missing field in object', 'substrings-match'}}). %%================================ %% userCertificate %%================================ enc_userCertificate(derivation, _,_) -> exit({error,{'use of missing field in object', derivation}}); enc_userCertificate('Type', Val, _RestPrimFieldName) -> enc_Certificate(Val, [<<48>>]); enc_userCertificate('equality-match', Val, [H|T]) -> 'CertificateExtensions':enc_certificateExactMatch(H, Val, T); enc_userCertificate('ordering-match', _,_) -> exit({error,{'use of missing field in object', 'ordering-match'}}); enc_userCertificate('substrings-match', _,_) -> exit({error,{'use of missing field in object', 'substrings-match'}}). dec_userCertificate(derivation, _,_) -> exit({error,{'illegal use of missing field in object', derivation}}); dec_userCertificate('Type', Bytes,_) -> Tlv = tlv_format(Bytes), dec_Certificate(Tlv, [16]); dec_userCertificate('equality-match', Bytes,[H|T]) -> 'CertificateExtensions':dec_certificateExactMatch(H, Bytes, T); dec_userCertificate('ordering-match', _,_) -> exit({error,{'illegal use of missing field in object', 'ordering-match'}}); dec_userCertificate('substrings-match', _,_) -> exit({error,{'illegal use of missing field in object', 'substrings-match'}}). %%================================ %% cACertificate %%================================ enc_cACertificate(derivation, _,_) -> exit({error,{'use of missing field in object', derivation}}); enc_cACertificate('Type', Val, _RestPrimFieldName) -> enc_Certificate(Val, [<<48>>]); enc_cACertificate('equality-match', Val, [H|T]) -> 'CertificateExtensions':enc_certificateExactMatch(H, Val, T); enc_cACertificate('ordering-match', _,_) -> exit({error,{'use of missing field in object', 'ordering-match'}}); enc_cACertificate('substrings-match', _,_) -> exit({error,{'use of missing field in object', 'substrings-match'}}). dec_cACertificate(derivation, _,_) -> exit({error,{'illegal use of missing field in object', derivation}}); dec_cACertificate('Type', Bytes,_) -> Tlv = tlv_format(Bytes), dec_Certificate(Tlv, [16]); dec_cACertificate('equality-match', Bytes,[H|T]) -> 'CertificateExtensions':dec_certificateExactMatch(H, Bytes, T); dec_cACertificate('ordering-match', _,_) -> exit({error,{'illegal use of missing field in object', 'ordering-match'}}); dec_cACertificate('substrings-match', _,_) -> exit({error,{'illegal use of missing field in object', 'substrings-match'}}). %%================================ %% crossCertificatePair %%================================ enc_crossCertificatePair(derivation, _,_) -> exit({error,{'use of missing field in object', derivation}}); enc_crossCertificatePair('Type', Val, _RestPrimFieldName) -> enc_CertificatePair(Val, [<<48>>]); enc_crossCertificatePair('equality-match', Val, [H|T]) -> 'CertificateExtensions':enc_certificatePairExactMatch(H, Val, T); enc_crossCertificatePair('ordering-match', _,_) -> exit({error,{'use of missing field in object', 'ordering-match'}}); enc_crossCertificatePair('substrings-match', _,_) -> exit({error,{'use of missing field in object', 'substrings-match'}}). dec_crossCertificatePair(derivation, _,_) -> exit({error,{'illegal use of missing field in object', derivation}}); dec_crossCertificatePair('Type', Bytes,_) -> Tlv = tlv_format(Bytes), dec_CertificatePair(Tlv, [16]); dec_crossCertificatePair('equality-match', Bytes,[H|T]) -> 'CertificateExtensions':dec_certificatePairExactMatch(H, Bytes, T); dec_crossCertificatePair('ordering-match', _,_) -> exit({error,{'illegal use of missing field in object', 'ordering-match'}}); dec_crossCertificatePair('substrings-match', _,_) -> exit({error,{'illegal use of missing field in object', 'substrings-match'}}). %%================================ %% authorityRevocationList %%================================ enc_authorityRevocationList(derivation, _,_) -> exit({error,{'use of missing field in object', derivation}}); enc_authorityRevocationList('Type', Val, _RestPrimFieldName) -> enc_CertificateList(Val, [<<48>>]); enc_authorityRevocationList('equality-match', Val, [H|T]) -> 'CertificateExtensions':enc_certificateListExactMatch(H, Val, T); enc_authorityRevocationList('ordering-match', _,_) -> exit({error,{'use of missing field in object', 'ordering-match'}}); enc_authorityRevocationList('substrings-match', _,_) -> exit({error,{'use of missing field in object', 'substrings-match'}}). dec_authorityRevocationList(derivation, _,_) -> exit({error,{'illegal use of missing field in object', derivation}}); dec_authorityRevocationList('Type', Bytes,_) -> Tlv = tlv_format(Bytes), dec_CertificateList(Tlv, [16]); dec_authorityRevocationList('equality-match', Bytes,[H|T]) -> 'CertificateExtensions':dec_certificateListExactMatch(H, Bytes, T); dec_authorityRevocationList('ordering-match', _,_) -> exit({error,{'illegal use of missing field in object', 'ordering-match'}}); dec_authorityRevocationList('substrings-match', _,_) -> exit({error,{'illegal use of missing field in object', 'substrings-match'}}). %%================================ %% certificateRevocationList %%================================ enc_certificateRevocationList(derivation, _,_) -> exit({error,{'use of missing field in object', derivation}}); enc_certificateRevocationList('Type', Val, _RestPrimFieldName) -> enc_CertificateList(Val, [<<48>>]); enc_certificateRevocationList('equality-match', Val, [H|T]) -> 'CertificateExtensions':enc_certificateListExactMatch(H, Val, T); enc_certificateRevocationList('ordering-match', _,_) -> exit({error,{'use of missing field in object', 'ordering-match'}}); enc_certificateRevocationList('substrings-match', _,_) -> exit({error,{'use of missing field in object', 'substrings-match'}}). dec_certificateRevocationList(derivation, _,_) -> exit({error,{'illegal use of missing field in object', derivation}}); dec_certificateRevocationList('Type', Bytes,_) -> Tlv = tlv_format(Bytes), dec_CertificateList(Tlv, [16]); dec_certificateRevocationList('equality-match', Bytes,[H|T]) -> 'CertificateExtensions':dec_certificateListExactMatch(H, Bytes, T); dec_certificateRevocationList('ordering-match', _,_) -> exit({error,{'illegal use of missing field in object', 'ordering-match'}}); dec_certificateRevocationList('substrings-match', _,_) -> exit({error,{'illegal use of missing field in object', 'substrings-match'}}). %%================================ %% attributeCertificateRevocationList %%================================ enc_attributeCertificateRevocationList(derivation, _,_) -> exit({error,{'use of missing field in object', derivation}}); enc_attributeCertificateRevocationList('Type', Val, _RestPrimFieldName) -> enc_CertificateList(Val, [<<48>>]); enc_attributeCertificateRevocationList('equality-match', _,_) -> exit({error,{'use of missing field in object', 'equality-match'}}); enc_attributeCertificateRevocationList('ordering-match', _,_) -> exit({error,{'use of missing field in object', 'ordering-match'}}); enc_attributeCertificateRevocationList('substrings-match', _,_) -> exit({error,{'use of missing field in object', 'substrings-match'}}). dec_attributeCertificateRevocationList(derivation, _,_) -> exit({error,{'illegal use of missing field in object', derivation}}); dec_attributeCertificateRevocationList('Type', Bytes,_) -> Tlv = tlv_format(Bytes), dec_CertificateList(Tlv, [16]); dec_attributeCertificateRevocationList('equality-match', _,_) -> exit({error,{'illegal use of missing field in object', 'equality-match'}}); dec_attributeCertificateRevocationList('ordering-match', _,_) -> exit({error,{'illegal use of missing field in object', 'ordering-match'}}); dec_attributeCertificateRevocationList('substrings-match', _,_) -> exit({error,{'illegal use of missing field in object', 'substrings-match'}}). %%================================ %% SupportedAlgorithms %%================================ getenc_SupportedAlgorithms(_) -> fun(_, Val, _RestPrimFieldName) -> case Val of {asn1_OPENTYPE,Bin} when is_binary(Bin) -> {Bin,byte_size(Bin)} end end. getdec_SupportedAlgorithms(_) -> fun(_,Bytes, _RestPrimFieldName) -> case Bytes of Bin when is_binary(Bin) -> {asn1_OPENTYPE,Bin}; _ -> {asn1_OPENTYPE,ber_encode(Bytes)} end end. %%================================ %% ExtensionSet %%================================ getenc_ExtensionSet(_) -> fun(_, Val, _RestPrimFieldName) -> case Val of {asn1_OPENTYPE,Bin} when is_binary(Bin) -> {Bin,byte_size(Bin)} end end. getdec_ExtensionSet(_) -> fun(_,Bytes, _RestPrimFieldName) -> case Bytes of Bin when is_binary(Bin) -> {asn1_OPENTYPE,Bin}; _ -> {asn1_OPENTYPE,ber_encode(Bytes)} end end. %%% %%% Run-time functions. %%% 'dialyzer-suppressions'(Arg) -> ok. ber_decode_nif(B) -> asn1rt_nif:decode_ber_tlv(B). ber_encode([Tlv]) -> ber_encode(Tlv); ber_encode(Tlv) when is_binary(Tlv) -> Tlv; ber_encode(Tlv) -> asn1rt_nif:encode_ber_tlv(Tlv). 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)]). dec_subidentifiers(<<>>, _Av, Al) -> lists:reverse(Al); dec_subidentifiers(<<1:1,H:7,T/binary>>, Av, Al) -> dec_subidentifiers(T, Av bsl 7 + H, Al); dec_subidentifiers(<>, Av, Al) -> dec_subidentifiers(T, 0, [Av bsl 7 + H | Al]). 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_object_identifier(Tlv, Tags) -> Val = match_tags(Tlv, Tags), [AddedObjVal | ObjVals] = dec_subidentifiers(Val, 0, []), {Val1, Val2} = if AddedObjVal < 40 -> {0, AddedObjVal}; AddedObjVal < 80 -> {1, AddedObjVal - 40}; true -> {2, AddedObjVal - 80} end, list_to_tuple([Val1, Val2 | ObjVals]). decode_octet_string(Tlv, TagsIn) -> Bin = match_and_collect(Tlv, TagsIn), binary:copy(Bin). decode_open_type(Tlv, TagIn) -> case match_tags(Tlv, TagIn) of Bin when is_binary(Bin) -> {InnerTlv, _} = ber_decode_nif(Bin), InnerTlv; TlvBytes -> TlvBytes end. decode_restricted_string(Tlv, TagsIn) -> match_and_collect(Tlv, TagsIn). e_object_identifier({'OBJECT IDENTIFIER', V}) -> e_object_identifier(V); e_object_identifier(V) when is_tuple(V) -> e_object_identifier(tuple_to_list(V)); e_object_identifier([E1, E2 | Tail]) -> Head = 40 * E1 + E2, {H, Lh} = mk_object_val(Head), {R, Lr} = lists:mapfoldl(fun enc_obj_id_tail/2, 0, Tail), {[H | R], Lh + Lr}. enc_obj_id_tail(H, Len) -> {B, L} = mk_object_val(H), {B, Len + L}. encode_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, NamedNumberList, Tag) when is_atom(Val) -> case lists:keyfind(Val, 1, NamedNumberList) of {_, NewVal} -> encode_tags(Tag, encode_integer(NewVal)); _ -> exit({error, {asn1, {encode_integer_namednumber, Val}}}) end; encode_integer(Val, _NamedNumberList, Tag) -> encode_tags(Tag, encode_integer(Val)). 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_object_identifier(Val, TagIn) -> encode_tags(TagIn, e_object_identifier(Val)). encode_open_type(Val, T) when is_list(Val) -> encode_open_type(list_to_binary(Val), T); encode_open_type(Val, Tag) -> encode_tags(Tag, Val, byte_size(Val)). 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, []). mk_object_val(0, Ack, Len) -> {Ack, Len}; mk_object_val(Val, Ack, Len) -> mk_object_val(Val bsr 7, [Val band 127 bor 128 | Ack], Len + 1). mk_object_val(Val) when Val =< 127 -> {[255 band Val], 1}; mk_object_val(Val) -> mk_object_val(Val bsr 7, [Val band 127], 1). number2name(Int, NamedNumberList) -> case lists:keyfind(Int, 2, NamedNumberList) of {NamedVal, _} -> NamedVal; _ -> Int end.