pkix1implicit88.erl

来自「OTP是开放电信平台的简称」· ERL 代码 · 共 2,076 行 · 第 1/5 页

ERL
2,076
字号
   %%-------------------------------------------------Tlv1 = ?RT_BER:match_tags(Tlv,TagIn), %%-------------------------------------------------%% attribute type-id(1) with type OBJECT IDENTIFIER%%-------------------------------------------------[V1|Tlv2] = Tlv1, Term1 = ?RT_BER:decode_object_identifier(V1,[6]),%%-------------------------------------------------%% attribute value(2) with type ASN1_OPEN_TYPE%%-------------------------------------------------[V2|Tlv3] = Tlv2, Term2 = ?RT_BER:decode_open_type_as_binary(V2,[131072]),case Tlv3 of[] -> true;_ -> exit({error,{asn1, {unexpected,Tlv3}}}) % extra fields not allowedend,   {'AnotherName', Term1, Term2}.%%================================%%  EDIPartyName%%================================'enc_EDIPartyName'(Val) ->    'enc_EDIPartyName'(Val, [<<48>>]).'enc_EDIPartyName'(Val, TagIn) ->{_,Cindex1, Cindex2} = Val,%%-------------------------------------------------%% attribute nameAssigner(1)   External PKIX1Explicit88:DirectoryString OPTIONAL%%-------------------------------------------------   {EncBytes1,EncLen1} =  case Cindex1 of         asn1_NOVALUE -> {<<>>,0};         _ ->            'PKIX1Explicit88':'enc_DirectoryString'(Cindex1, [<<160>>])       end,%%-------------------------------------------------%% attribute partyName(2)   External PKIX1Explicit88:DirectoryString%%-------------------------------------------------   {EncBytes2,EncLen2} = 'PKIX1Explicit88':'enc_DirectoryString'(Cindex2, [<<161>>]),   BytesSoFar = [EncBytes1, EncBytes2],LenSoFar = EncLen1 + EncLen2,?RT_BER:encode_tags(TagIn, BytesSoFar, LenSoFar).'dec_EDIPartyName'(Tlv) ->   'dec_EDIPartyName'(Tlv, [16]).'dec_EDIPartyName'(Tlv, TagIn) ->   %%-------------------------------------------------   %% decode tag and length    %%-------------------------------------------------Tlv1 = ?RT_BER:match_tags(Tlv,TagIn), %%-------------------------------------------------%% attribute nameAssigner(1)   External PKIX1Explicit88:DirectoryString OPTIONAL%%-------------------------------------------------{Term1,Tlv2} = case Tlv1 of[{131072,V1}|TempTlv2] ->    {'PKIX1Explicit88':'dec_DirectoryString'(V1, []), TempTlv2};    _ ->        { asn1_NOVALUE, Tlv1}end,%%-------------------------------------------------%% attribute partyName(2)   External PKIX1Explicit88:DirectoryString%%-------------------------------------------------[V2|Tlv3] = Tlv2, Term2 = 'PKIX1Explicit88':'dec_DirectoryString'(V2, [131073]),case Tlv3 of[] -> true;_ -> exit({error,{asn1, {unexpected,Tlv3}}}) % extra fields not allowedend,   {'EDIPartyName', Term1, Term2}.%%================================%%  IssuerAltName%%================================'enc_IssuerAltName'(Val) ->    'enc_IssuerAltName'(Val, [<<48>>]).'enc_IssuerAltName'({'IssuerAltName',Val}, TagIn) ->   'enc_IssuerAltName'(Val, TagIn);'enc_IssuerAltName'(Val, TagIn) ->   'enc_GeneralNames'(Val, TagIn).'dec_IssuerAltName'(Tlv) ->   'dec_IssuerAltName'(Tlv, [16]).'dec_IssuerAltName'(Tlv, TagIn) ->'dec_GeneralNames'(Tlv, TagIn).%%================================%%  SubjectDirectoryAttributes%%================================'enc_SubjectDirectoryAttributes'(Val) ->    'enc_SubjectDirectoryAttributes'(Val, [<<48>>]).'enc_SubjectDirectoryAttributes'({'SubjectDirectoryAttributes',Val}, TagIn) ->   'enc_SubjectDirectoryAttributes'(Val, TagIn);'enc_SubjectDirectoryAttributes'(Val, TagIn) ->   {EncBytes,EncLen} = 'enc_SubjectDirectoryAttributes_components'(Val,[],0),   ?RT_BER:encode_tags(TagIn, EncBytes, EncLen).'enc_SubjectDirectoryAttributes_components'([], AccBytes, AccLen) ->    {lists:reverse(AccBytes),AccLen};'enc_SubjectDirectoryAttributes_components'([H|T],AccBytes, AccLen) ->   {EncBytes,EncLen} = 'PKIX1Explicit88':'enc_Attribute'(H, [<<48>>]),   'enc_SubjectDirectoryAttributes_components'(T,[EncBytes|AccBytes], AccLen + EncLen).'dec_SubjectDirectoryAttributes'(Tlv) ->   'dec_SubjectDirectoryAttributes'(Tlv, [16]).'dec_SubjectDirectoryAttributes'(Tlv, TagIn) ->   %%-------------------------------------------------   %% decode tag and length    %%-------------------------------------------------Tlv1 = ?RT_BER:match_tags(Tlv,TagIn), ['PKIX1Explicit88':'dec_Attribute'(V1, [16]) || V1 <- Tlv1].%%================================%%  BasicConstraints%%================================'enc_BasicConstraints'(Val) ->    'enc_BasicConstraints'(Val, [<<48>>]).'enc_BasicConstraints'(Val, TagIn) ->{_,Cindex1, Cindex2} = Val,%%-------------------------------------------------%% attribute cA(1) with type BOOLEAN DEFAULT = false%%-------------------------------------------------   {EncBytes1,EncLen1} =  case catch asn1rt_check:check_bool(false, Cindex1) of            true -> {[],0};         _ ->            ?RT_BER:encode_boolean(Cindex1, [<<1>>])       end,%%-------------------------------------------------%% attribute pathLenConstraint(2) with type INTEGER OPTIONAL%%-------------------------------------------------   {EncBytes2,EncLen2} =  case Cindex2 of         asn1_NOVALUE -> {<<>>,0};         _ ->            ?RT_BER:encode_integer([], Cindex2, [<<2>>])       end,   BytesSoFar = [EncBytes1, EncBytes2],LenSoFar = EncLen1 + EncLen2,?RT_BER:encode_tags(TagIn, BytesSoFar, LenSoFar).'dec_BasicConstraints'(Tlv) ->   'dec_BasicConstraints'(Tlv, [16]).'dec_BasicConstraints'(Tlv, TagIn) ->   %%-------------------------------------------------   %% decode tag and length    %%-------------------------------------------------Tlv1 = ?RT_BER:match_tags(Tlv,TagIn), %%-------------------------------------------------%% attribute cA(1) with type BOOLEAN DEFAULT = false%%-------------------------------------------------{Term1,Tlv2} = case Tlv1 of[{1,V1}|TempTlv2] ->    {?RT_BER:decode_boolean(V1,[]), TempTlv2};    _ ->        {false,Tlv1}end,%%-------------------------------------------------%% attribute pathLenConstraint(2) with type INTEGER OPTIONAL%%-------------------------------------------------{Term2,Tlv3} = case Tlv2 of[{2,V2}|TempTlv3] ->    {?RT_BER:decode_integer(V2,{0,'MAX'},[]), TempTlv3};    _ ->        { asn1_NOVALUE, Tlv2}end,case Tlv3 of[] -> true;_ -> exit({error,{asn1, {unexpected,Tlv3}}}) % extra fields not allowedend,   {'BasicConstraints', Term1, Term2}.%%================================%%  NameConstraints%%================================'enc_NameConstraints'(Val) ->    'enc_NameConstraints'(Val, [<<48>>]).'enc_NameConstraints'(Val, TagIn) ->{_,Cindex1, Cindex2} = Val,%%-------------------------------------------------%% attribute permittedSubtrees(1)   External PKIX1Implicit88:GeneralSubtrees OPTIONAL%%-------------------------------------------------   {EncBytes1,EncLen1} =  case Cindex1 of         asn1_NOVALUE -> {<<>>,0};         _ ->            'enc_GeneralSubtrees'(Cindex1, [<<160>>])       end,%%-------------------------------------------------%% attribute excludedSubtrees(2)   External PKIX1Implicit88:GeneralSubtrees OPTIONAL%%-------------------------------------------------   {EncBytes2,EncLen2} =  case Cindex2 of         asn1_NOVALUE -> {<<>>,0};         _ ->            'enc_GeneralSubtrees'(Cindex2, [<<161>>])       end,   BytesSoFar = [EncBytes1, EncBytes2],LenSoFar = EncLen1 + EncLen2,?RT_BER:encode_tags(TagIn, BytesSoFar, LenSoFar).'dec_NameConstraints'(Tlv) ->   'dec_NameConstraints'(Tlv, [16]).'dec_NameConstraints'(Tlv, TagIn) ->   %%-------------------------------------------------   %% decode tag and length    %%-------------------------------------------------Tlv1 = ?RT_BER:match_tags(Tlv,TagIn), %%-------------------------------------------------%% attribute permittedSubtrees(1)   External PKIX1Implicit88:GeneralSubtrees OPTIONAL%%-------------------------------------------------{Term1,Tlv2} = case Tlv1 of[{131072,V1}|TempTlv2] ->    {'dec_GeneralSubtrees'(V1, []), TempTlv2};    _ ->        { asn1_NOVALUE, Tlv1}end,%%-------------------------------------------------%% attribute excludedSubtrees(2)   External PKIX1Implicit88:GeneralSubtrees OPTIONAL%%-------------------------------------------------{Term2,Tlv3} = case Tlv2 of[{131073,V2}|TempTlv3] ->    {'dec_GeneralSubtrees'(V2, []), TempTlv3};    _ ->        { asn1_NOVALUE, Tlv2}end,case Tlv3 of[] -> true;_ -> exit({error,{asn1, {unexpected,Tlv3}}}) % extra fields not allowedend,   {'NameConstraints', Term1, Term2}.%%================================%%  GeneralSubtrees%%================================'enc_GeneralSubtrees'(Val) ->    'enc_GeneralSubtrees'(Val, [<<48>>]).'enc_GeneralSubtrees'({'GeneralSubtrees',Val}, TagIn) ->   'enc_GeneralSubtrees'(Val, TagIn);'enc_GeneralSubtrees'(Val, TagIn) ->   {EncBytes,EncLen} = 'enc_GeneralSubtrees_components'(Val,[],0),   ?RT_BER:encode_tags(TagIn, EncBytes, EncLen).'enc_GeneralSubtrees_components'([], AccBytes, AccLen) ->    {lists:reverse(AccBytes),AccLen};'enc_GeneralSubtrees_components'([H|T],AccBytes, AccLen) ->   {EncBytes,EncLen} = 'enc_GeneralSubtree'(H, [<<48>>]),   'enc_GeneralSubtrees_components'(T,[EncBytes|AccBytes], AccLen + EncLen).'dec_GeneralSubtrees'(Tlv) ->   'dec_GeneralSubtrees'(Tlv, [16]).'dec_GeneralSubtrees'(Tlv, TagIn) ->   %%-------------------------------------------------   %% decode tag and length    %%-------------------------------------------------Tlv1 = ?RT_BER:match_tags(Tlv,TagIn), ['dec_GeneralSubtree'(V1, [16]) || V1 <- Tlv1].%%================================%%  GeneralSubtree%%================================'enc_GeneralSubtree'(Val) ->    'enc_GeneralSubtree'(Val, [<<48>>]).'enc_GeneralSubtree'(Val, TagIn) ->{_,Cindex1, Cindex2, Cindex3} = Val,%%-------------------------------------------------%% attribute base(1)   External PKIX1Implicit88:GeneralName%%-------------------------------------------------   {EncBytes1,EncLen1} = 'enc_GeneralName'(Cindex1, []),%%-------------------------------------------------%% attribute minimum(2) with type INTEGER DEFAULT = 0%%-------------------------------------------------   {EncBytes2,EncLen2} =  case catch asn1rt_check:check_int(0, Cindex2, []) of            true -> {[],0};         _ ->            ?RT_BER:encode_integer([], Cindex2, [<<128>>])       end,%%-------------------------------------------------%% attribute maximum(3) with type INTEGER OPTIONAL%%-------------------------------------------------   {EncBytes3,EncLen3} =  case Cindex3 of         asn1_NOVALUE -> {<<>>,0};         _ ->            ?RT_BER:encode_integer([], Cindex3, [<<129>>])       end,   BytesSoFar = [EncBytes1, EncBytes2, EncBytes3],LenSoFar = EncLen1 + EncLen2 + EncLen3,?RT_BER:encode_tags(TagIn, BytesSoFar, LenSoFar).'dec_GeneralSubtree'(Tlv) ->   'dec_GeneralSubtree'(Tlv, [16]).'dec_GeneralSubtree'(Tlv, TagIn) ->   %%-------------------------------------------------   %% decode tag and length    %%-------------------------------------------------Tlv1 = ?RT_BER:match_tags(Tlv,TagIn), %%-------------------------------------------------%% attribute base(1)   External PKIX1Implicit88:GeneralName%%-------------------------------------------------[V1|Tlv2] = Tlv1, Term1 = 'dec_GeneralName'(V1, []),%%-------------------------------------------------%% attribute minimum(2) with type INTEGER DEFAULT = 0%%-------------------------------------------------{Term2,Tlv3} = case Tlv2 of[{131072,V2}|TempTlv3] ->    {?RT_BER:decode_integer(V2,{0,'MAX'},[]), TempTlv3};    _ ->        {0,Tlv2}end,%%-------------------------------------------------%% attribute maximum(3) with type INTEGER OPTIONAL%%-------------------------------------------------{Term3,Tlv4} = case Tlv3 of[{131073,V3}|TempTlv4] ->    {?RT_BER:decode_integer(V3,{0,'MAX'},[]), TempTlv4};    _ ->        { asn1_NOVALUE, Tlv3}end,case Tlv4 of[] -> true;_ -> exit({error,{asn1, {unexpected,Tlv4}}}) % extra fields not allowedend,   {'GeneralSubtree', Term1, Term2, Term3}.%%================================%%  BaseDistance%%================================'enc_BaseDistance'(Val) ->    'enc_BaseDistance'(Val, [<<2>>]).'enc_BaseDistance'({'BaseDistance',Val}, TagIn) ->   'enc_BaseDistance'(Val, TagIn);'enc_BaseDistance'(Val, TagIn) ->?RT_BER:encode_integer([], Val, TagIn).'dec_BaseDistance'(Tlv) ->   'dec_BaseDistance'(Tlv, [2]).'dec_BaseDistance'(Tlv, TagIn) ->?RT_BER:decode_integer(Tlv,{0,'MAX'},TagIn).%%================================%%  PolicyConstraints%%================================

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?