pkix1algorithms88.erl
来自「OTP是开放电信平台的简称」· ERL 代码 · 共 1,327 行 · 第 1/3 页
ERL
1,327 行
'dec_FieldElement'(Tlv, [4]).'dec_FieldElement'(Tlv, TagIn) ->?RT_BER:decode_octet_string(Tlv,[],TagIn).%%================================%% ECPoint%%================================'enc_ECPoint'(Val) -> 'enc_ECPoint'(Val, [<<4>>]).'enc_ECPoint'({'ECPoint',Val}, TagIn) -> 'enc_ECPoint'(Val, TagIn);'enc_ECPoint'(Val, TagIn) ->?RT_BER:encode_octet_string([], Val, TagIn).'dec_ECPoint'(Tlv) -> 'dec_ECPoint'(Tlv, [4]).'dec_ECPoint'(Tlv, TagIn) ->?RT_BER:decode_octet_string(Tlv,[],TagIn).%%================================%% EcpkParameters%%================================'enc_EcpkParameters'(Val) -> 'enc_EcpkParameters'(Val, []).'enc_EcpkParameters'({'EcpkParameters',Val}, TagIn) -> 'enc_EcpkParameters'(Val, TagIn);'enc_EcpkParameters'(Val, TagIn) -> {EncBytes,EncLen} = case element(1,Val) of ecParameters -> 'enc_ECParameters'(element(2,Val), [<<48>>]); namedCurve -> ?RT_BER:encode_object_identifier(element(2,Val), [<<6>>]); implicitlyCA -> ?RT_BER:encode_null(element(2,Val), [<<5>>]); Else -> exit({error,{asn1,{invalid_choice_type,Else}}}) end,?RT_BER:encode_tags(TagIn, EncBytes, EncLen).'dec_EcpkParameters'(Tlv) -> 'dec_EcpkParameters'(Tlv, []).'dec_EcpkParameters'(Tlv, TagIn) ->Tlv1 = ?RT_BER:match_tags(Tlv,TagIn), case (case Tlv1 of [CtempTlv1] -> CtempTlv1; _ -> Tlv1 end) of%% 'ecParameters' {16, V1} -> {ecParameters, 'dec_ECParameters'(V1, [])};%% 'namedCurve' {6, V1} -> {namedCurve, ?RT_BER:decode_object_identifier(V1,[])};%% 'implicitlyCA' {5, V1} -> {implicitlyCA, ?RT_BER:decode_null(V1,[])}; Else -> exit({error,{asn1,{invalid_choice_tag,Else}}}) end.%%================================%% ECParameters%%================================'enc_ECParameters'(Val) -> 'enc_ECParameters'(Val, [<<48>>]).'enc_ECParameters'(Val, TagIn) ->{_,Cindex1, Cindex2, Cindex3, Cindex4, Cindex5, Cindex6} = Val,%%-------------------------------------------------%% attribute version(1) with type INTEGER%%------------------------------------------------- {EncBytes1,EncLen1} = ?RT_BER:encode_integer([], Cindex1, [{ecpVer1,1}], [<<2>>]),%%-------------------------------------------------%% attribute fieldID(2) External PKIX1Algorithms88:FieldID%%------------------------------------------------- {EncBytes2,EncLen2} = 'enc_FieldID'(Cindex2, [<<48>>]),%%-------------------------------------------------%% attribute curve(3) External PKIX1Algorithms88:Curve%%------------------------------------------------- {EncBytes3,EncLen3} = 'enc_Curve'(Cindex3, [<<48>>]),%%-------------------------------------------------%% attribute base(4) with type OCTET STRING%%------------------------------------------------- {EncBytes4,EncLen4} = ?RT_BER:encode_octet_string([], Cindex4, [<<4>>]),%%-------------------------------------------------%% attribute order(5) with type INTEGER%%------------------------------------------------- {EncBytes5,EncLen5} = ?RT_BER:encode_integer([], Cindex5, [<<2>>]),%%-------------------------------------------------%% attribute cofactor(6) with type INTEGER OPTIONAL%%------------------------------------------------- {EncBytes6,EncLen6} = case Cindex6 of asn1_NOVALUE -> {<<>>,0}; _ -> ?RT_BER:encode_integer([], Cindex6, [<<2>>]) end, BytesSoFar = [EncBytes1, EncBytes2, EncBytes3, EncBytes4, EncBytes5, EncBytes6],LenSoFar = EncLen1 + EncLen2 + EncLen3 + EncLen4 + EncLen5 + EncLen6,?RT_BER:encode_tags(TagIn, BytesSoFar, LenSoFar).'dec_ECParameters'(Tlv) -> 'dec_ECParameters'(Tlv, [16]).'dec_ECParameters'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%-------------------------------------------------Tlv1 = ?RT_BER:match_tags(Tlv,TagIn), %%-------------------------------------------------%% attribute version(1) with type INTEGER%%-------------------------------------------------[V1|Tlv2] = Tlv1, Term1 = ?RT_BER:decode_integer(V1,[],[{ecpVer1,1}],[2]),%%-------------------------------------------------%% attribute fieldID(2) External PKIX1Algorithms88:FieldID%%-------------------------------------------------[V2|Tlv3] = Tlv2, Term2 = 'dec_FieldID'(V2, [16]),%%-------------------------------------------------%% attribute curve(3) External PKIX1Algorithms88:Curve%%-------------------------------------------------[V3|Tlv4] = Tlv3, Term3 = 'dec_Curve'(V3, [16]),%%-------------------------------------------------%% attribute base(4) with type OCTET STRING%%-------------------------------------------------[V4|Tlv5] = Tlv4, Term4 = ?RT_BER:decode_octet_string(V4,[],[4]),%%-------------------------------------------------%% attribute order(5) with type INTEGER%%-------------------------------------------------[V5|Tlv6] = Tlv5, Term5 = ?RT_BER:decode_integer(V5,[],[2]),%%-------------------------------------------------%% attribute cofactor(6) with type INTEGER OPTIONAL%%-------------------------------------------------{Term6,Tlv7} = case Tlv6 of[{2,V6}|TempTlv7] -> {?RT_BER:decode_integer(V6,[],[]), TempTlv7}; _ -> { asn1_NOVALUE, Tlv6}end,case Tlv7 of[] -> true;_ -> exit({error,{asn1, {unexpected,Tlv7}}}) % extra fields not allowedend, {'ECParameters', Term1, Term2, Term3, Term4, Term5, Term6}.%%================================%% ECPVer%%================================'enc_ECPVer'(Val) -> 'enc_ECPVer'(Val, [<<2>>]).'enc_ECPVer'({'ECPVer',Val}, TagIn) -> 'enc_ECPVer'(Val, TagIn);'enc_ECPVer'(Val, TagIn) ->?RT_BER:encode_integer([], Val, [{ecpVer1,1}], TagIn).'dec_ECPVer'(Tlv) -> 'dec_ECPVer'(Tlv, [2]).'dec_ECPVer'(Tlv, TagIn) ->?RT_BER:decode_integer(Tlv,[],[{ecpVer1,1}],TagIn).%%================================%% Curve%%================================'enc_Curve'(Val) -> 'enc_Curve'(Val, [<<48>>]).'enc_Curve'(Val, TagIn) ->{_,Cindex1, Cindex2, Cindex3} = Val,%%-------------------------------------------------%% attribute a(1) with type OCTET STRING%%------------------------------------------------- {EncBytes1,EncLen1} = ?RT_BER:encode_octet_string([], Cindex1, [<<4>>]),%%-------------------------------------------------%% attribute b(2) with type OCTET STRING%%------------------------------------------------- {EncBytes2,EncLen2} = ?RT_BER:encode_octet_string([], Cindex2, [<<4>>]),%%-------------------------------------------------%% attribute seed(3) with type BIT STRING OPTIONAL%%------------------------------------------------- {EncBytes3,EncLen3} = case Cindex3 of asn1_NOVALUE -> {<<>>,0}; _ -> ?RT_BER:encode_bit_string([], Cindex3, [], [<<3>>]) end, BytesSoFar = [EncBytes1, EncBytes2, EncBytes3],LenSoFar = EncLen1 + EncLen2 + EncLen3,?RT_BER:encode_tags(TagIn, BytesSoFar, LenSoFar).'dec_Curve'(Tlv) -> 'dec_Curve'(Tlv, [16]).'dec_Curve'(Tlv, TagIn) -> %%------------------------------------------------- %% decode tag and length %%-------------------------------------------------Tlv1 = ?RT_BER:match_tags(Tlv,TagIn), %%-------------------------------------------------%% attribute a(1) with type OCTET STRING%%-------------------------------------------------[V1|Tlv2] = Tlv1, Term1 = ?RT_BER:decode_octet_string(V1,[],[4]),%%-------------------------------------------------%% attribute b(2) with type OCTET STRING%%-------------------------------------------------[V2|Tlv3] = Tlv2, Term2 = ?RT_BER:decode_octet_string(V2,[],[4]),%%-------------------------------------------------%% attribute seed(3) with type BIT STRING OPTIONAL%%-------------------------------------------------{Term3,Tlv4} = case Tlv3 of[{3,V3}|TempTlv4] -> {?RT_BER:decode_compact_bit_string(V3,[],[],[]), TempTlv4}; _ -> { asn1_NOVALUE, Tlv3}end,case Tlv4 of[] -> true;_ -> exit({error,{asn1, {unexpected,Tlv4}}}) % extra fields not allowedend, {'Curve', Term1, Term2, Term3}.'md2'() ->{1,2,840,113549,2,2}.'md5'() ->{1,2,840,113549,2,5}.'id-sha1'() ->{1,3,14,3,2,26}.'id-dsa'() ->{1,2,840,10040,4,1}.'id-dsa-with-sha1'() ->{1,2,840,10040,4,3}.'pkcs-1'() ->{1,2,840,113549,1,1}.'rsaEncryption'() ->{1,2,840,113549,1,1,1}.'md2WithRSAEncryption'() ->{1,2,840,113549,1,1,2}.'md5WithRSAEncryption'() ->{1,2,840,113549,1,1,4}.'sha1WithRSAEncryption'() ->{1,2,840,113549,1,1,5}.'dhpublicnumber'() ->{1,2,840,10046,2,1}.'id-keyExchangeAlgorithm'() ->{2,16,840,1,101,2,1,1,22}.'ansi-X9-62'() ->{1,2,840,10045}.'id-ecSigType'() ->{1,2,840,10045,4}.'ecdsa-with-SHA1'() ->{1,2,840,10045,4,1}.'id-fieldType'() ->{1,2,840,10045,1}.'prime-field'() ->{1,2,840,10045,1,1}.'characteristic-two-field'() ->{1,2,840,10045,1,2}.'id-characteristic-two-basis'() ->{1,2,840,10045,1,2,3}.'gnBasis'() ->{1,2,840,10045,1,2,3,1}.'tpBasis'() ->{1,2,840,10045,1,2,3,2}.'ppBasis'() ->{1,2,840,10045,1,2,3,3}.'id-publicKeyType'() ->{1,2,840,10045,2}.'id-ecPublicKey'() ->{1,2,840,10045,2,1}.'ellipticCurve'() ->{1,2,840,10045,3}.'c-TwoCurve'() ->{1,2,840,10045,3,0}.'c2pnb163v1'() ->{1,2,840,10045,3,0,1}.'c2pnb163v2'() ->{1,2,840,10045,3,0,2}.'c2pnb163v3'() ->{1,2,840,10045,3,0,3}.'c2pnb176w1'() ->{1,2,840,10045,3,0,4}.'c2tnb191v1'() ->{1,2,840,10045,3,0,5}.'c2tnb191v2'() ->{1,2,840,10045,3,0,6}.'c2tnb191v3'() ->{1,2,840,10045,3,0,7}.'c2onb191v4'() ->{1,2,840,10045,3,0,8}.'c2onb191v5'() ->{1,2,840,10045,3,0,9}.'c2pnb208w1'() ->{1,2,840,10045,3,0,10}.'c2tnb239v1'() ->{1,2,840,10045,3,0,11}.'c2tnb239v2'() ->{1,2,840,10045,3,0,12}.'c2tnb239v3'() ->{1,2,840,10045,3,0,13}.'c2onb239v4'() ->{1,2,840,10045,3,0,14}.'c2onb239v5'() ->{1,2,840,10045,3,0,15}.'c2pnb272w1'() ->{1,2,840,10045,3,0,16}.'c2pnb304w1'() ->{1,2,840,10045,3,0,17}.'c2tnb359v1'() ->{1,2,840,10045,3,0,18}.'c2pnb368w1'() ->{1,2,840,10045,3,0,19}.'c2tnb431r1'() ->{1,2,840,10045,3,0,20}.'primeCurve'() ->{1,2,840,10045,3,1}.'prime192v1'() ->{1,2,840,10045,3,1,1}.'prime192v2'() ->{1,2,840,10045,3,1,2}.'prime192v3'() ->{1,2,840,10045,3,1,3}.'prime239v1'() ->{1,2,840,10045,3,1,4}.'prime239v2'() ->{1,2,840,10045,3,1,5}.'prime239v3'() ->{1,2,840,10045,3,1,6}.'prime256v1'() ->{1,2,840,10045,3,1,7}.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?