pkix1implicit88.erl

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

ERL
2,076
字号
    'enc_SubjectKeyIdentifier'(Val, [<<4>>]).'enc_SubjectKeyIdentifier'({'SubjectKeyIdentifier',Val}, TagIn) ->   'enc_SubjectKeyIdentifier'(Val, TagIn);'enc_SubjectKeyIdentifier'(Val, TagIn) ->?RT_BER:encode_octet_string([], Val, TagIn).'dec_SubjectKeyIdentifier'(Tlv) ->   'dec_SubjectKeyIdentifier'(Tlv, [4]).'dec_SubjectKeyIdentifier'(Tlv, TagIn) ->?RT_BER:decode_octet_string(Tlv,[],TagIn).%%================================%%  KeyUsage%%================================'enc_KeyUsage'(Val) ->    'enc_KeyUsage'(Val, [<<3>>]).'enc_KeyUsage'({'KeyUsage',Val}, TagIn) ->   'enc_KeyUsage'(Val, TagIn);'enc_KeyUsage'(Val, TagIn) ->?RT_BER:encode_bit_string([], Val, [{digitalSignature,0},{nonRepudiation,1},{keyEncipherment,2},{dataEncipherment,3},{keyAgreement,4},{keyCertSign,5},{cRLSign,6},{encipherOnly,7},{decipherOnly,8}], TagIn).'dec_KeyUsage'(Tlv) ->   'dec_KeyUsage'(Tlv, [3]).'dec_KeyUsage'(Tlv, TagIn) ->?RT_BER:decode_compact_bit_string(Tlv,[],[{digitalSignature,0},{nonRepudiation,1},{keyEncipherment,2},{dataEncipherment,3},{keyAgreement,4},{keyCertSign,5},{cRLSign,6},{encipherOnly,7},{decipherOnly,8}],TagIn).%%================================%%  PrivateKeyUsagePeriod%%================================'enc_PrivateKeyUsagePeriod'(Val) ->    'enc_PrivateKeyUsagePeriod'(Val, [<<48>>]).'enc_PrivateKeyUsagePeriod'(Val, TagIn) ->{_,Cindex1, Cindex2} = Val,%%-------------------------------------------------%% attribute notBefore(1) with type GeneralizedTime OPTIONAL%%-------------------------------------------------   {EncBytes1,EncLen1} =  case Cindex1 of         asn1_NOVALUE -> {<<>>,0};         _ ->            ?RT_BER:encode_generalized_time([], Cindex1, [<<128>>])       end,%%-------------------------------------------------%% attribute notAfter(2) with type GeneralizedTime OPTIONAL%%-------------------------------------------------   {EncBytes2,EncLen2} =  case Cindex2 of         asn1_NOVALUE -> {<<>>,0};         _ ->            ?RT_BER:encode_generalized_time([], Cindex2, [<<129>>])       end,   BytesSoFar = [EncBytes1, EncBytes2],LenSoFar = EncLen1 + EncLen2,?RT_BER:encode_tags(TagIn, BytesSoFar, LenSoFar).'dec_PrivateKeyUsagePeriod'(Tlv) ->   'dec_PrivateKeyUsagePeriod'(Tlv, [16]).'dec_PrivateKeyUsagePeriod'(Tlv, TagIn) ->   %%-------------------------------------------------   %% decode tag and length    %%-------------------------------------------------Tlv1 = ?RT_BER:match_tags(Tlv,TagIn), %%-------------------------------------------------%% attribute notBefore(1) with type GeneralizedTime OPTIONAL%%-------------------------------------------------{Term1,Tlv2} = case Tlv1 of[{131072,V1}|TempTlv2] ->    {?RT_BER:decode_generalized_time(V1,[],[]), TempTlv2};    _ ->        { asn1_NOVALUE, Tlv1}end,%%-------------------------------------------------%% attribute notAfter(2) with type GeneralizedTime OPTIONAL%%-------------------------------------------------{Term2,Tlv3} = case Tlv2 of[{131073,V2}|TempTlv3] ->    {?RT_BER:decode_generalized_time(V2,[],[]), TempTlv3};    _ ->        { asn1_NOVALUE, Tlv2}end,case Tlv3 of[] -> true;_ -> exit({error,{asn1, {unexpected,Tlv3}}}) % extra fields not allowedend,   {'PrivateKeyUsagePeriod', Term1, Term2}.%%================================%%  CertificatePolicies%%================================'enc_CertificatePolicies'(Val) ->    'enc_CertificatePolicies'(Val, [<<48>>]).'enc_CertificatePolicies'({'CertificatePolicies',Val}, TagIn) ->   'enc_CertificatePolicies'(Val, TagIn);'enc_CertificatePolicies'(Val, TagIn) ->   {EncBytes,EncLen} = 'enc_CertificatePolicies_components'(Val,[],0),   ?RT_BER:encode_tags(TagIn, EncBytes, EncLen).'enc_CertificatePolicies_components'([], AccBytes, AccLen) ->    {lists:reverse(AccBytes),AccLen};'enc_CertificatePolicies_components'([H|T],AccBytes, AccLen) ->   {EncBytes,EncLen} = 'enc_PolicyInformation'(H, [<<48>>]),   'enc_CertificatePolicies_components'(T,[EncBytes|AccBytes], AccLen + EncLen).'dec_CertificatePolicies'(Tlv) ->   'dec_CertificatePolicies'(Tlv, [16]).'dec_CertificatePolicies'(Tlv, TagIn) ->   %%-------------------------------------------------   %% decode tag and length    %%-------------------------------------------------Tlv1 = ?RT_BER:match_tags(Tlv,TagIn), ['dec_PolicyInformation'(V1, [16]) || V1 <- Tlv1].%%================================%%  PolicyInformation%%================================'enc_PolicyInformation'(Val) ->    'enc_PolicyInformation'(Val, [<<48>>]).'enc_PolicyInformation'(Val, TagIn) ->{_,Cindex1, Cindex2} = Val,%%-------------------------------------------------%% attribute policyIdentifier(1) with type OBJECT IDENTIFIER%%-------------------------------------------------   {EncBytes1,EncLen1} = ?RT_BER:encode_object_identifier(Cindex1, [<<6>>]),%%-------------------------------------------------%% attribute policyQualifiers(2) with type SEQUENCE OF OPTIONAL%%-------------------------------------------------   {EncBytes2,EncLen2} =  case Cindex2 of         asn1_NOVALUE -> {<<>>,0};         _ ->            'enc_PolicyInformation_policyQualifiers'(Cindex2, [<<48>>])       end,   BytesSoFar = [EncBytes1, EncBytes2],LenSoFar = EncLen1 + EncLen2,?RT_BER:encode_tags(TagIn, BytesSoFar, LenSoFar).%%================================%%  PolicyInformation_policyQualifiers%%================================'enc_PolicyInformation_policyQualifiers'({'PolicyInformation_policyQualifiers',Val}, TagIn) ->   'enc_PolicyInformation_policyQualifiers'(Val, TagIn);'enc_PolicyInformation_policyQualifiers'(Val, TagIn) ->      {EncBytes,EncLen} = 'enc_PolicyInformation_policyQualifiers_components'(Val,[],0),   ?RT_BER:encode_tags(TagIn, EncBytes, EncLen).'enc_PolicyInformation_policyQualifiers_components'([], AccBytes, AccLen) ->    {lists:reverse(AccBytes),AccLen};'enc_PolicyInformation_policyQualifiers_components'([H|T],AccBytes, AccLen) ->   {EncBytes,EncLen} = 'enc_PolicyQualifierInfo'(H, [<<48>>]),   'enc_PolicyInformation_policyQualifiers_components'(T,[EncBytes|AccBytes], AccLen + EncLen).'dec_PolicyInformation_policyQualifiers'(Tlv, TagIn) ->   %%-------------------------------------------------   %% decode tag and length    %%-------------------------------------------------Tlv1 = ?RT_BER:match_tags(Tlv,TagIn), ['dec_PolicyQualifierInfo'(V1, [16]) || V1 <- Tlv1].'dec_PolicyInformation'(Tlv) ->   'dec_PolicyInformation'(Tlv, [16]).'dec_PolicyInformation'(Tlv, TagIn) ->   %%-------------------------------------------------   %% decode tag and length    %%-------------------------------------------------Tlv1 = ?RT_BER:match_tags(Tlv,TagIn), %%-------------------------------------------------%% attribute policyIdentifier(1) with type OBJECT IDENTIFIER%%-------------------------------------------------[V1|Tlv2] = Tlv1, Term1 = ?RT_BER:decode_object_identifier(V1,[6]),%%-------------------------------------------------%% attribute policyQualifiers(2) with type SEQUENCE OF OPTIONAL%%-------------------------------------------------{Term2,Tlv3} = case Tlv2 of[{16,V2}|TempTlv3] ->    {'dec_PolicyInformation_policyQualifiers'(V2, []), TempTlv3};    _ ->        { asn1_NOVALUE, Tlv2}end,case Tlv3 of[] -> true;_ -> exit({error,{asn1, {unexpected,Tlv3}}}) % extra fields not allowedend,   {'PolicyInformation', Term1, Term2}.%%================================%%  CertPolicyId%%================================'enc_CertPolicyId'(Val) ->    'enc_CertPolicyId'(Val, [<<6>>]).'enc_CertPolicyId'({'CertPolicyId',Val}, TagIn) ->   'enc_CertPolicyId'(Val, TagIn);'enc_CertPolicyId'(Val, TagIn) ->?RT_BER:encode_object_identifier(Val, TagIn).'dec_CertPolicyId'(Tlv) ->   'dec_CertPolicyId'(Tlv, [6]).'dec_CertPolicyId'(Tlv, TagIn) ->?RT_BER:decode_object_identifier(Tlv,TagIn).%%================================%%  PolicyQualifierInfo%%================================'enc_PolicyQualifierInfo'(Val) ->    'enc_PolicyQualifierInfo'(Val, [<<48>>]).'enc_PolicyQualifierInfo'(Val, TagIn) ->{_,Cindex1, Cindex2} = Val,%%-------------------------------------------------%% attribute policyQualifierId(1) with type OBJECT IDENTIFIER%%-------------------------------------------------   {EncBytes1,EncLen1} = ?RT_BER:encode_object_identifier(Cindex1, [<<6>>]),%%-------------------------------------------------%% attribute qualifier(2) with type ASN1_OPEN_TYPE%%-------------------------------------------------   {EncBytes2,EncLen2} = ?RT_BER:encode_open_type(Cindex2, []),   BytesSoFar = [EncBytes1, EncBytes2],LenSoFar = EncLen1 + EncLen2,?RT_BER:encode_tags(TagIn, BytesSoFar, LenSoFar).'dec_PolicyQualifierInfo'(Tlv) ->   'dec_PolicyQualifierInfo'(Tlv, [16]).'dec_PolicyQualifierInfo'(Tlv, TagIn) ->   %%-------------------------------------------------   %% decode tag and length    %%-------------------------------------------------Tlv1 = ?RT_BER:match_tags(Tlv,TagIn), %%-------------------------------------------------%% attribute policyQualifierId(1) with type OBJECT IDENTIFIER%%-------------------------------------------------[V1|Tlv2] = Tlv1, Term1 = ?RT_BER:decode_object_identifier(V1,[6]),%%-------------------------------------------------%% attribute qualifier(2) with type ASN1_OPEN_TYPE%%-------------------------------------------------[V2|Tlv3] = Tlv2, Term2 = ?RT_BER:decode_open_type_as_binary(V2,[]),case Tlv3 of[] -> true;_ -> exit({error,{asn1, {unexpected,Tlv3}}}) % extra fields not allowedend,   {'PolicyQualifierInfo', Term1, Term2}.%%================================%%  PolicyQualifierId%%================================'enc_PolicyQualifierId'(Val) ->    'enc_PolicyQualifierId'(Val, [<<6>>]).'enc_PolicyQualifierId'({'PolicyQualifierId',Val}, TagIn) ->   'enc_PolicyQualifierId'(Val, TagIn);'enc_PolicyQualifierId'(Val, TagIn) ->?RT_BER:encode_object_identifier(Val, TagIn).'dec_PolicyQualifierId'(Tlv) ->   'dec_PolicyQualifierId'(Tlv, [6]).'dec_PolicyQualifierId'(Tlv, TagIn) ->?RT_BER:decode_object_identifier(Tlv,TagIn).%%================================%%  CPSuri%%================================'enc_CPSuri'(Val) ->    'enc_CPSuri'(Val, [<<22>>]).'enc_CPSuri'({'CPSuri',Val}, TagIn) ->   'enc_CPSuri'(Val, TagIn);'enc_CPSuri'(Val, TagIn) ->?RT_BER:encode_restricted_string([], Val, 22, TagIn).'dec_CPSuri'(Tlv) ->   'dec_CPSuri'(Tlv, [22]).'dec_CPSuri'(Tlv, TagIn) ->?RT_BER:decode_restricted_string(Tlv,[],22,TagIn).%%================================%%  UserNotice%%================================'enc_UserNotice'(Val) ->    'enc_UserNotice'(Val, [<<48>>]).'enc_UserNotice'(Val, TagIn) ->{_,Cindex1, Cindex2} = Val,%%-------------------------------------------------%% attribute noticeRef(1)   External PKIX1Implicit88:NoticeReference OPTIONAL%%-------------------------------------------------   {EncBytes1,EncLen1} =  case Cindex1 of         asn1_NOVALUE -> {<<>>,0};         _ ->            'enc_NoticeReference'(Cindex1, [<<48>>])       end,%%-------------------------------------------------%% attribute explicitText(2)   External PKIX1Implicit88:DisplayText OPTIONAL%%-------------------------------------------------   {EncBytes2,EncLen2} =  case Cindex2 of         asn1_NOVALUE -> {<<>>,0};         _ ->            'enc_DisplayText'(Cindex2, [])       end,   BytesSoFar = [EncBytes1, EncBytes2],LenSoFar = EncLen1 + EncLen2,?RT_BER:encode_tags(TagIn, BytesSoFar, LenSoFar).'dec_UserNotice'(Tlv) ->   'dec_UserNotice'(Tlv, [16]).'dec_UserNotice'(Tlv, TagIn) ->   %%-------------------------------------------------   %% decode tag and length    %%-------------------------------------------------Tlv1 = ?RT_BER:match_tags(Tlv,TagIn), %%-------------------------------------------------%% attribute noticeRef(1)   External PKIX1Implicit88:NoticeReference OPTIONAL%%-------------------------------------------------{Term1,Tlv2} = case Tlv1 of[{16,V1}|TempTlv2] ->    {'dec_NoticeReference'(V1, []), TempTlv2};    _ ->        { asn1_NOVALUE, Tlv1}end,%%-------------------------------------------------%% attribute explicitText(2)   External PKIX1Implicit88:DisplayText OPTIONAL%%-------------------------------------------------{Term2,Tlv3} = case Tlv2 of[V2 = {22,_}|TempTlv3] ->    {'dec_DisplayText'(V2, []), TempTlv3};[V2 = {26,_}|TempTlv3] ->    {'dec_DisplayText'(V2, []), TempTlv3};[V2 = {30,_}|TempTlv3] ->    {'dec_DisplayText'(V2, []), TempTlv3};[V2 = {12,_}|TempTlv3] ->    {'dec_DisplayText'(V2, []), TempTlv3};    _ ->        { asn1_NOVALUE, Tlv2}

⌨️ 快捷键说明

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