pkix1algorithms88.erl

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

ERL
1,327
字号
%%-------------------------------------------------   {EncBytes3,EncLen3} = ?RT_BER:encode_integer([], Cindex3, [<<2>>]),%%-------------------------------------------------%% attribute j(4) with type INTEGER OPTIONAL%%-------------------------------------------------   {EncBytes4,EncLen4} =  case Cindex4 of         asn1_NOVALUE -> {<<>>,0};         _ ->            ?RT_BER:encode_integer([], Cindex4, [<<2>>])       end,%%-------------------------------------------------%% attribute validationParms(5)   External PKIX1Algorithms88:ValidationParms OPTIONAL%%-------------------------------------------------   {EncBytes5,EncLen5} =  case Cindex5 of         asn1_NOVALUE -> {<<>>,0};         _ ->            'enc_ValidationParms'(Cindex5, [<<48>>])       end,   BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4, EncBytes5],LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4 + EncLen5,?RT_BER:encode_tags(TagIn, BytesSoFar, LenSoFar).'dec_DomainParameters'(Tlv) ->   'dec_DomainParameters'(Tlv, [16]).'dec_DomainParameters'(Tlv, TagIn) ->   %%-------------------------------------------------   %% decode tag and length    %%-------------------------------------------------Tlv1 = ?RT_BER:match_tags(Tlv,TagIn), %%-------------------------------------------------%% attribute p(1) with type INTEGER%%-------------------------------------------------[V1|Tlv2] = Tlv1, Term1 = ?RT_BER:decode_integer(V1,[],[2]),%%-------------------------------------------------%% attribute g(2) with type INTEGER%%-------------------------------------------------[V2|Tlv3] = Tlv2, Term2 = ?RT_BER:decode_integer(V2,[],[2]),%%-------------------------------------------------%% attribute q(3) with type INTEGER%%-------------------------------------------------[V3|Tlv4] = Tlv3, Term3 = ?RT_BER:decode_integer(V3,[],[2]),%%-------------------------------------------------%% attribute j(4) with type INTEGER OPTIONAL%%-------------------------------------------------{Term4,Tlv5} = case Tlv4 of[{2,V4}|TempTlv5] ->    {?RT_BER:decode_integer(V4,[],[]), TempTlv5};    _ ->        { asn1_NOVALUE, Tlv4}end,%%-------------------------------------------------%% attribute validationParms(5)   External PKIX1Algorithms88:ValidationParms OPTIONAL%%-------------------------------------------------{Term5,Tlv6} = case Tlv5 of[{16,V5}|TempTlv6] ->    {'dec_ValidationParms'(V5, []), TempTlv6};    _ ->        { asn1_NOVALUE, Tlv5}end,case Tlv6 of[] -> true;_ -> exit({error,{asn1, {unexpected,Tlv6}}}) % extra fields not allowedend,   {'DomainParameters', Term1, Term2, Term3, Term4, Term5}.%%================================%%  ValidationParms%%================================'enc_ValidationParms'(Val) ->    'enc_ValidationParms'(Val, [<<48>>]).'enc_ValidationParms'(Val, TagIn) ->{_,Cindex1, Cindex2} = Val,%%-------------------------------------------------%% attribute seed(1) with type BIT STRING%%-------------------------------------------------   {EncBytes1,EncLen1} = ?RT_BER:encode_bit_string([], Cindex1, [], [<<3>>]),%%-------------------------------------------------%% attribute pgenCounter(2) with type INTEGER%%-------------------------------------------------   {EncBytes2,EncLen2} = ?RT_BER:encode_integer([], Cindex2, [<<2>>]),   BytesSoFar = [EncBytes1, EncBytes2],LenSoFar = EncLen1 + EncLen2,?RT_BER:encode_tags(TagIn, BytesSoFar, LenSoFar).'dec_ValidationParms'(Tlv) ->   'dec_ValidationParms'(Tlv, [16]).'dec_ValidationParms'(Tlv, TagIn) ->   %%-------------------------------------------------   %% decode tag and length    %%-------------------------------------------------Tlv1 = ?RT_BER:match_tags(Tlv,TagIn), %%-------------------------------------------------%% attribute seed(1) with type BIT STRING%%-------------------------------------------------[V1|Tlv2] = Tlv1, Term1 = ?RT_BER:decode_compact_bit_string(V1,[],[],[3]),%%-------------------------------------------------%% attribute pgenCounter(2) with type INTEGER%%-------------------------------------------------[V2|Tlv3] = Tlv2, Term2 = ?RT_BER:decode_integer(V2,[],[2]),case Tlv3 of[] -> true;_ -> exit({error,{asn1, {unexpected,Tlv3}}}) % extra fields not allowedend,   {'ValidationParms', Term1, Term2}.%%================================%%  KEA-Parms-Id%%================================'enc_KEA-Parms-Id'(Val) ->    'enc_KEA-Parms-Id'(Val, [<<4>>]).'enc_KEA-Parms-Id'({'KEA-Parms-Id',Val}, TagIn) ->   'enc_KEA-Parms-Id'(Val, TagIn);'enc_KEA-Parms-Id'(Val, TagIn) ->?RT_BER:encode_octet_string([], Val, TagIn).'dec_KEA-Parms-Id'(Tlv) ->   'dec_KEA-Parms-Id'(Tlv, [4]).'dec_KEA-Parms-Id'(Tlv, TagIn) ->?RT_BER:decode_octet_string(Tlv,[],TagIn).%%================================%%  FieldID%%================================'enc_FieldID'(Val) ->    'enc_FieldID'(Val, [<<48>>]).'enc_FieldID'(Val, TagIn) ->{_,Cindex1, Cindex2} = Val,%%-------------------------------------------------%% attribute fieldType(1) with type OBJECT IDENTIFIER%%-------------------------------------------------   {EncBytes1,EncLen1} = ?RT_BER:encode_object_identifier(Cindex1, [<<6>>]),%%-------------------------------------------------%% attribute parameters(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_FieldID'(Tlv) ->   'dec_FieldID'(Tlv, [16]).'dec_FieldID'(Tlv, TagIn) ->   %%-------------------------------------------------   %% decode tag and length    %%-------------------------------------------------Tlv1 = ?RT_BER:match_tags(Tlv,TagIn), %%-------------------------------------------------%% attribute fieldType(1) with type OBJECT IDENTIFIER%%-------------------------------------------------[V1|Tlv2] = Tlv1, Term1 = ?RT_BER:decode_object_identifier(V1,[6]),%%-------------------------------------------------%% attribute parameters(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,   {'FieldID', Term1, Term2}.%%================================%%  ECDSA-Sig-Value%%================================'enc_ECDSA-Sig-Value'(Val) ->    'enc_ECDSA-Sig-Value'(Val, [<<48>>]).'enc_ECDSA-Sig-Value'(Val, TagIn) ->{_,Cindex1, Cindex2} = Val,%%-------------------------------------------------%% attribute r(1) with type INTEGER%%-------------------------------------------------   {EncBytes1,EncLen1} = ?RT_BER:encode_integer([], Cindex1, [<<2>>]),%%-------------------------------------------------%% attribute s(2) with type INTEGER%%-------------------------------------------------   {EncBytes2,EncLen2} = ?RT_BER:encode_integer([], Cindex2, [<<2>>]),   BytesSoFar = [EncBytes1, EncBytes2],LenSoFar = EncLen1 + EncLen2,?RT_BER:encode_tags(TagIn, BytesSoFar, LenSoFar).'dec_ECDSA-Sig-Value'(Tlv) ->   'dec_ECDSA-Sig-Value'(Tlv, [16]).'dec_ECDSA-Sig-Value'(Tlv, TagIn) ->   %%-------------------------------------------------   %% decode tag and length    %%-------------------------------------------------Tlv1 = ?RT_BER:match_tags(Tlv,TagIn), %%-------------------------------------------------%% attribute r(1) with type INTEGER%%-------------------------------------------------[V1|Tlv2] = Tlv1, Term1 = ?RT_BER:decode_integer(V1,[],[2]),%%-------------------------------------------------%% attribute s(2) with type INTEGER%%-------------------------------------------------[V2|Tlv3] = Tlv2, Term2 = ?RT_BER:decode_integer(V2,[],[2]),case Tlv3 of[] -> true;_ -> exit({error,{asn1, {unexpected,Tlv3}}}) % extra fields not allowedend,   {'ECDSA-Sig-Value', Term1, Term2}.%%================================%%  Prime-p%%================================'enc_Prime-p'(Val) ->    'enc_Prime-p'(Val, [<<2>>]).'enc_Prime-p'({'Prime-p',Val}, TagIn) ->   'enc_Prime-p'(Val, TagIn);'enc_Prime-p'(Val, TagIn) ->?RT_BER:encode_integer([], Val, TagIn).'dec_Prime-p'(Tlv) ->   'dec_Prime-p'(Tlv, [2]).'dec_Prime-p'(Tlv, TagIn) ->?RT_BER:decode_integer(Tlv,[],TagIn).%%================================%%  Characteristic-two%%================================'enc_Characteristic-two'(Val) ->    'enc_Characteristic-two'(Val, [<<48>>]).'enc_Characteristic-two'(Val, TagIn) ->{_,Cindex1, Cindex2, Cindex3} = Val,%%-------------------------------------------------%% attribute m(1) with type INTEGER%%-------------------------------------------------   {EncBytes1,EncLen1} = ?RT_BER:encode_integer([], Cindex1, [<<2>>]),%%-------------------------------------------------%% attribute basis(2) with type OBJECT IDENTIFIER%%-------------------------------------------------   {EncBytes2,EncLen2} = ?RT_BER:encode_object_identifier(Cindex2, [<<6>>]),%%-------------------------------------------------%% attribute parameters(3) with type ASN1_OPEN_TYPE%%-------------------------------------------------   {EncBytes3,EncLen3} = ?RT_BER:encode_open_type(Cindex3, []),   BytesSoFar = [EncBytes1, EncBytes2, EncBytes3],LenSoFar = EncLen1 + EncLen2 + EncLen3,?RT_BER:encode_tags(TagIn, BytesSoFar, LenSoFar).'dec_Characteristic-two'(Tlv) ->   'dec_Characteristic-two'(Tlv, [16]).'dec_Characteristic-two'(Tlv, TagIn) ->   %%-------------------------------------------------   %% decode tag and length    %%-------------------------------------------------Tlv1 = ?RT_BER:match_tags(Tlv,TagIn), %%-------------------------------------------------%% attribute m(1) with type INTEGER%%-------------------------------------------------[V1|Tlv2] = Tlv1, Term1 = ?RT_BER:decode_integer(V1,[],[2]),%%-------------------------------------------------%% attribute basis(2) with type OBJECT IDENTIFIER%%-------------------------------------------------[V2|Tlv3] = Tlv2, Term2 = ?RT_BER:decode_object_identifier(V2,[6]),%%-------------------------------------------------%% attribute parameters(3) with type ASN1_OPEN_TYPE%%-------------------------------------------------[V3|Tlv4] = Tlv3, Term3 = ?RT_BER:decode_open_type_as_binary(V3,[]),case Tlv4 of[] -> true;_ -> exit({error,{asn1, {unexpected,Tlv4}}}) % extra fields not allowedend,   {'Characteristic-two', Term1, Term2, Term3}.%%================================%%  Trinomial%%================================'enc_Trinomial'(Val) ->    'enc_Trinomial'(Val, [<<2>>]).'enc_Trinomial'({'Trinomial',Val}, TagIn) ->   'enc_Trinomial'(Val, TagIn);'enc_Trinomial'(Val, TagIn) ->?RT_BER:encode_integer([], Val, TagIn).'dec_Trinomial'(Tlv) ->   'dec_Trinomial'(Tlv, [2]).'dec_Trinomial'(Tlv, TagIn) ->?RT_BER:decode_integer(Tlv,[],TagIn).%%================================%%  Pentanomial%%================================'enc_Pentanomial'(Val) ->    'enc_Pentanomial'(Val, [<<48>>]).'enc_Pentanomial'(Val, TagIn) ->{_,Cindex1, Cindex2, Cindex3} = Val,%%-------------------------------------------------%% attribute k1(1) with type INTEGER%%-------------------------------------------------   {EncBytes1,EncLen1} = ?RT_BER:encode_integer([], Cindex1, [<<2>>]),%%-------------------------------------------------%% attribute k2(2) with type INTEGER%%-------------------------------------------------   {EncBytes2,EncLen2} = ?RT_BER:encode_integer([], Cindex2, [<<2>>]),%%-------------------------------------------------%% attribute k3(3) with type INTEGER%%-------------------------------------------------   {EncBytes3,EncLen3} = ?RT_BER:encode_integer([], Cindex3, [<<2>>]),   BytesSoFar = [EncBytes1, EncBytes2, EncBytes3],LenSoFar = EncLen1 + EncLen2 + EncLen3,?RT_BER:encode_tags(TagIn, BytesSoFar, LenSoFar).'dec_Pentanomial'(Tlv) ->   'dec_Pentanomial'(Tlv, [16]).'dec_Pentanomial'(Tlv, TagIn) ->   %%-------------------------------------------------   %% decode tag and length    %%-------------------------------------------------Tlv1 = ?RT_BER:match_tags(Tlv,TagIn), %%-------------------------------------------------%% attribute k1(1) with type INTEGER%%-------------------------------------------------[V1|Tlv2] = Tlv1, Term1 = ?RT_BER:decode_integer(V1,[],[2]),%%-------------------------------------------------%% attribute k2(2) with type INTEGER%%-------------------------------------------------[V2|Tlv3] = Tlv2, Term2 = ?RT_BER:decode_integer(V2,[],[2]),%%-------------------------------------------------%% attribute k3(3) with type INTEGER%%-------------------------------------------------[V3|Tlv4] = Tlv3, Term3 = ?RT_BER:decode_integer(V3,[],[2]),case Tlv4 of[] -> true;_ -> exit({error,{asn1, {unexpected,Tlv4}}}) % extra fields not allowedend,   {'Pentanomial', Term1, Term2, Term3}.%%================================%%  FieldElement%%================================'enc_FieldElement'(Val) ->    'enc_FieldElement'(Val, [<<4>>]).'enc_FieldElement'({'FieldElement',Val}, TagIn) ->   'enc_FieldElement'(Val, TagIn);'enc_FieldElement'(Val, TagIn) ->?RT_BER:encode_octet_string([], Val, TagIn).'dec_FieldElement'(Tlv) ->

⌨️ 快捷键说明

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