hyb
2026-01-30 15bc7727b58bf9ca0c8f21702fa893daac232b8d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
Ë
ž¬`i[=ãó´—ddlmZddlmZddlmZddlmZddlm    Z    ddl
m Z ddgZ Gd    „de «ZGd
„d e«ZGd „d e«ZGd„de«Zdd„Zy)é)Ú DerSequence)Ú long_to_bytes)ÚInteger)ÚHMAC)ÚEccKey)ÚDsaKeyÚ DssSigSchemeÚnewcó4—eZdZdZd„Zd„Zd„Zd„Zd„Zd„Z    y)    r    zkA (EC)DSA signature object.
    Do not instantiate directly.
    Use :func:`Crypto.Signature.DSS.new`.
    có —||_||_||_|jj«|_|jdz
dzdz|_y)z Create a new Digital Signature Standard (DSS) object.
 
        Do not instantiate this object directly,
        use `Crypto.Signature.DSS.new` instead.
        ééN)Ú_keyÚ    _encodingÚ_orderÚ size_in_bitsÚ _order_bitsÚ _order_bytes)ÚselfÚkeyÚencodingÚorders    õgH:\项目\archive\测试组\脚本\Change_password\venv_build\Lib\site-packages\Crypto/Signature/DSS.pyÚ__init__zDssSigScheme.__init__3sK€ðˆŒ    Ø!ˆŒØˆŒ àŸ;™;×3Ñ3Ó5ˆÔØ!×-Ñ-°Ñ1°aÑ7¸!Ñ;ˆÕócó6—|jj«S)zRReturn ``True`` if this signature object can be used
        for signing messages.)rÚ has_private)rs rÚcan_signzDssSigScheme.can_signAs€ðy‰y×$Ñ$Ó&Ð&rcó—td«‚©NzTo be provided by subclasses©ÚNotImplementedError©rÚmsg_hashs  rÚ_compute_noncezDssSigScheme._compute_nonceGó€Ü!Ð"@ÓAÐArcó—td«‚r r!r#s  rÚ _valid_hashzDssSigScheme._valid_hashJr&rc    ó—|jj«s td«‚|j|«s t    d«‚|j |«}t j|j«d|j«}|jj||«}|jdk(r5dj|Dcgc]}t||j«‘Œc}«}|St|«j«}|Scc}w)aCompute the DSA/ECDSA signature of a message.
 
        Args:
          msg_hash (hash object):
            The hash that was carried out over the message.
            The object belongs to the :mod:`Crypto.Hash` package.
            Under mode ``'fips-186-3'``, the hash must be a FIPS
            approved secure hash (SHA-2 or SHA-3).
 
        :return: The signature as ``bytes``
        :raise ValueError: if the hash algorithm is incompatible to the (EC)DSA key
        :raise TypeError: if the (EC)DSA key has no private half
        zPrivate key is needed to signúHash is not sufficiently strongNÚbinaryr)rrÚ    TypeErrorr(Ú
ValueErrorr%rÚ
from_bytesÚdigestrÚ_signrÚjoinrrÚencode)rr$ÚnonceÚzÚsig_pairÚxÚoutputs       rÚsignzDssSigScheme.signMsì€ðy‰y×$Ñ$Ô&ÜÐ;Ó<Ð <à×Ñ Ô)ÜÐ>Ó?Ð ?ð×#Ñ# HÓ-ˆô × Ñ ˜xŸ™Ó0Ð1C°$×2CÑ2CÐDÓ EˆØ—9‘9—?‘? 1 eÓ,ˆð >‰>˜XÒ %Ø—X‘XØ(0ö2Ø#$ô -¨Q°×0AÑ0AÕBò2ó3ˆFðˆ ô! Ó*×1Ñ1Ó3ˆFàˆ ùò2sÂ=C>có†—|j|«s td«‚|jdk(rit|«d|jzk7r td«‚|d|j||jdfDcgc]}t j |«‘Œc}\}}na    t«j|d¬«}t|«dk7s|j«s td    «‚t |d
«t |d «}}d
|cxkr|jkr.n td «‚d
|cxkr|jkstd «‚td «‚t j |j«d|j«}|jj|||f«}|s td «‚ycc}w#ttf$r td«‚wxYw)aüCheck if a certain (EC)DSA signature is authentic.
 
        Args:
          msg_hash (hash object):
            The hash that was carried out over the message.
            This is an object belonging to the :mod:`Crypto.Hash` module.
            Under mode ``'fips-186-3'``, the hash must be a FIPS
            approved secure hash (SHA-2 or SHA-3).
 
          signature (``bytes``):
            The signature that needs to be validated.
 
        :raise ValueError: if the signature is not authentic
        r*r+éz'The signature is not authentic (length)NT)Ústrictz$The signature is not authentic (DER)z,The signature is not authentic (DER content)rr z"The signature is not authentic (d)zThe signature is not authenticF)r(r-rÚlenrrr.rÚdecodeÚ
IndexErrorÚ hasOnlyIntsrr/rÚ_verify)    rr$Ú    signaturer6Úr_primeÚs_primeÚder_seqr4Úresults             rÚverifyzDssSigScheme.verifyzsÀð ×Ñ Ô)ÜÐ>Ó?Ð ?à >‰>˜XÒ %ܐ9‹~ ! d×&7Ñ&7Ñ"7Ò8Ü Ð!JÓKÐKà*3Ð4F°T×5FÑ5FÐ*GØ*3°D×4EÑ4EÐ4FÐ*Gð*Iö JØ$%ô!(× 2Ñ 2°1Õ 5ò JÑ ˆG‘Wð IÜ%›-×.Ñ.¨yÀÐ.ÓFô7‹|˜qÒ ¨×(;Ñ(;Ô(=Ü Ð!OÓPÐPÜ& w¨q¡zÓ2´G¸GÀA¹JÓ4GWˆGàGÔ)˜dŸk™kÔ)ÜÐAÓBÐ Bð45°wÔ3LÀÇÁÒ3LÜÐAÓBÐ Bð4MÜÐAÓBÐ Bä × Ñ ˜xŸ™Ó0Ð1C°$×2CÑ2CÐDÓ EˆØ—‘×"Ñ" 1 w°Ð&8Ó9ˆÙÜÐ=Ó>Ð >àùò) Jøô ¤
Ð+ò IÜ Ð!GÓHÐHð IúsÁ2F ÂF%Æ%GN)
Ú__name__Ú
__module__Ú __qualname__Ú__doc__rrr%r(r8rF©rrr    r    -s(„ñò
<ò'ò BòBò+óZ*rcó<‡—eZdZˆfd„Zd„Zd„Zd„Zd„Zd„ZˆxZ    S)ÚDeterministicDsaSigSchemecó>•—tt| |||«||_y©N)ÚsuperrMrÚ _private_key)rrrrÚ private_keyÚ    __class__s     €rrz"DeterministicDsaSigScheme.__init__ªsø€Ü Ô'¨Ñ7¸¸XÀuÔMØ'ˆÕrcóš—tj|«}|jj«}t    |«dz}||kDr|||z
z}|S)zSee 2.3.2 in RFC6979r)rr.rrr<)rÚbstrrEÚq_lenÚb_lens     rÚ    _bits2intz#DeterministicDsaSigScheme._bits2int®sM€ô×#Ñ# DÓ)ˆØ— ‘ ×(Ñ(Ó*ˆÜD“    ˜A‘ ˆØ 5Š=à ˜ ™ Ñ &ˆF؈ rcób—d|cxkr|jksJ‚J‚t||j«S)zSee 2.3.3 in RFC6979r)rrr)rÚ    int_mod_qs  rÚ _int2octetsz%DeterministicDsaSigScheme._int2octets¹s4€ð9Ô*˜tŸ{™{Ò*Ð*Ñ*Ð*Ð*ܘY¨×(9Ñ(9Ó:Ð:rcóˆ—|j|«}||jkr|}n||jz
}|j|«S)zSee 2.3.4 in RFC6979)rXrr[)rrUÚz1Úz2s    rÚ _bits2octetsz&DeterministicDsaSigScheme._bits2octets¿sB€ð^‰^˜DÓ !ˆØ — ‘ Ò Ø‰Bàd—k‘kÑ!ˆBØ×Ñ Ó#Ð#rcóL—|j«}d|jz}d|jz}dD]}}tj|||z|j    |j
«z|j |«z|«j«}tj|||«j«}Œd}d|cxkr|jksÜn|dk7rMtj||dz|«j«}tj|||«j«}d}t|«|jkrCtj|||«j«}||z }t|«|jkrŒC|j|«}d|cxkr|jksŒÖ|SŒÚ|S)z!Generate k in a deterministic wayóó)rbraéÿÿÿÿrr) r/Ú digest_sizerr
r[rQr_rr<rrX)rÚmhashÚh1Úmask_vÚnonce_kÚint_octr3Úmask_ts        rr%z(DeterministicDsaSigScheme._compute_nonceÉs˜€ð
\‰\‹^ˆà˜5×,Ñ,Ñ,ˆà˜E×-Ñ-Ñ-ˆà)ò    ?ˆGä—h‘h˜wØ%¨Ñ/Ø#×/Ñ/°×0AÑ0AÓBñ Cà#×0Ñ0°Ó4ñ 5à6;ó=÷>D¹V»Xð ô
—X‘X˜g v¨uÓ5×<Ñ<Ó>‰Fð    ?ðˆØuÔ*˜tŸ{™{Ô*à˜Š{ÜŸ(™( 7¨F°WÑ,<Ø#(ó*ß*0©&«(ð䟙 '¨6°5Ó9×@Ñ@ÓBðˆFôf“+ × 1Ñ 1Ò1ÜŸ™ '¨6°5Ó9×@Ñ@ÓBØ˜&Ñ ôf“+ × 1Ñ 1Ó1ð
—N‘N 6Ó*ˆEð!uÔ*˜tŸ{™{Ó*ð"ˆ ñ#+ð"ˆ rcó—y)NTrKr#s  rr(z%DeterministicDsaSigScheme._valid_hashñs€Ør)
rGrHrIrrXr[r_r%r(Ú __classcell__©rSs@rrMrM§s"ø„ô(ò    ò;ò $ò&öPrrMcó.‡—eZdZdZˆfd„Zd„Zd„ZˆxZS)ÚFipsDsaSigScheme))ié )ééà)rqé)i rscóð•—tt| |||«||_t    |j
«j «}||jf|jvrd||jfz}t|«‚y)Nz+L/N (%d, %d) is not compliant to FIPS 186-3)
rProrÚ    _randfuncrÚprrÚ_fips_186_3_L_Nr-)rrrrÚrandfuncÚLÚerrorrSs       €rrzFipsDsaSigScheme.__init__suø€Ü Ô Ñ.¨s°H¸eÔDØ!ˆŒä C—E‘E‹N× 'Ñ 'Ó )ˆØ ˆt×ÑÐ  ¨×(<Ñ(<Ñ <ØBؘ4×+Ñ+Ð,ñ-ˆEä˜UÓ#Ð #ð =rcóZ—tjd|j|j¬«S©Nr )Ú min_inclusiveÚ max_exclusiverx)rÚ random_rangerrur#s  rr%zFipsDsaSigScheme._compute_nonce s%€ä×#Ñ#°!Ø26·+±+Ø-1¯^©^ô=ð    =rcóZ—|jdk(xs|jjd«S)z*Verify that SHA-1, SHA-2 or SHA-3 are usedz 1.3.14.3.2.26z2.16.840.1.101.3.4.2.)ÚoidÚ
startswithr#s  rr(zFipsDsaSigScheme._valid_hashs-€à— ‘  Ñ/òAØ— ‘ ×'Ñ'Ð(?Ó@ð    Br)rGrHrIrwrr%r(rlrms@rroroõsø„ð
€Oô$ò=ö Brrocó*‡—eZdZˆfd„Zd„Zd„ZˆxZS)ÚFipsEcDsaSigSchemecó>•—tt| |||«||_yrO)rPr„rru)rrrrrxrSs     €rrzFipsEcDsaSigScheme.__init__sø€Ü Ô  $Ñ0°°hÀÔFØ!ˆrcó‚—tjd|jjj|j
¬«Sr|)rrrÚ_curverrur#s  rr%z!FipsEcDsaSigScheme._compute_nonces1€Ü×#Ñ#°!Ø26·)±)×2BÑ2B×2HÑ2HØ-1¯^©^ô=ð    =rcó¶—|jjj«}d}d}d}d}||z|z|z}    |j|v}|S#t$rd}Y|SwxYw)zxVerify that the strength of the hash matches or exceeds
        the strength of the EC. We fail if the hash is too weak.)z2.16.840.1.101.3.4.2.4z2.16.840.1.101.3.4.2.7z2.16.840.1.101.3.4.2.5)z2.16.840.1.101.3.4.2.1z2.16.840.1.101.3.4.2.8z2.16.840.1.101.3.4.2.6)z2.16.840.1.101.3.4.2.2z2.16.840.1.101.3.4.2.9)z2.16.840.1.101.3.4.2.3z2.16.840.1.101.3.4.2.10F)rÚpointQrrÚAttributeError)    rr$Ú modulus_bitsÚsha224Úsha256Úsha384Úsha512ÚshsrEs             rr(zFipsEcDsaSigScheme._valid_hash"s{€ð—y‘y×'Ñ'×4Ñ4Ó6ˆ ð`ˆØ_ˆØEˆØFˆØv‰o Ñ&¨Ñ/ˆð    Ø—\‘\ SÐ(ˆFðˆ øôò    Ø‰F؈ ð    ús¹A    Á     AÁA)rGrHrIrr%r(rlrms@rr„r„sø„ô"ò=ö
rr„Ncó4—|dvrtd|z«‚t|t«r>|jj}d}|j
j d«sStd«‚t|t«rt|j«}d}n tdtt|««z«‚|j«r t||«}nd}|d    k(rt||||«S|d
k(r,t|t«rt||||«St!||||«Std |z«‚) a§
Create a signature object :class:`DssSigScheme` that
    can perform (EC)DSA signature or verification.
 
    .. note::
        Refer to `NIST SP 800 Part 1 Rev 4`_ (or newer release) for an
        overview of the recommended key lengths.
 
    Args:
        key (:class:`Crypto.PublicKey.DSA` or :class:`Crypto.PublicKey.ECC`):
            The key to use for computing the signature (*private* keys only)
            or for verifying one.
            For DSA keys, let ``L`` and ``N`` be the bit lengths of the modulus ``p``
            and of ``q``: the pair ``(L,N)`` must appear in the following list,
            in compliance to section 4.2 of `FIPS 186-4`_:
 
            - (1024, 160) *legacy only; do not create new signatures with this*
            - (2048, 224) *deprecated; do not create new signatures with this*
            - (2048, 256)
            - (3072, 256)
 
            For ECC, only keys over P-224, P-256, P-384, and P-521 are accepted.
 
        mode (string):
            The parameter can take these values:
 
            - ``'fips-186-3'``. The signature generation is randomized and carried out
              according to `FIPS 186-3`_: the nonce ``k`` is taken from the RNG.
            - ``'deterministic-rfc6979'``. The signature generation is not
              randomized. See RFC6979_.
 
        encoding (string):
            How the signature is encoded. This value determines the output of
            :meth:`sign` and the input to :meth:`verify`.
 
            The following values are accepted:
 
            - ``'binary'`` (default), the signature is the raw concatenation
              of ``r`` and ``s``. It is defined in the IEEE P.1363 standard.
              For DSA, the size in bytes of the signature is ``N/4`` bytes
              (e.g. 64 for ``N=256``).
              For ECDSA, the signature is always twice the length of a point
              coordinate (e.g. 64 bytes for P-256).
 
            - ``'der'``, the signature is a ASN.1 DER SEQUENCE
              with two INTEGERs (``r`` and ``s``). It is defined in RFC3279_.
              The size of the signature is variable.
 
        randfunc (callable):
            A function that returns random ``bytes``, of a given length.
            If omitted, the internal RNG is used.
            Only applicable for the *'fips-186-3'* mode.
 
    .. _FIPS 186-3: http://csrc.nist.gov/publications/fips/fips186-3/fips_186-3.pdf
    .. _FIPS 186-4: http://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.186-4.pdf
    .. _NIST SP 800 Part 1 Rev 4: http://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-57pt1r4.pdf
    .. _RFC6979: http://tools.ietf.org/html/rfc6979
    .. _RFC3279: https://tools.ietf.org/html/rfc3279#section-2.2.2
    )r+ÚderzUnknown encoding '%s'ÚdÚNISTz ECC key is not on a NIST P curver6zUnsupported key type Nzdeterministic-rfc6979z
fips-186-3zUnknown DSS mode '%s')r-Ú
isinstancerr‡rÚcurver‚rrÚqÚstrÚtyperÚgetattrrMr„ro)rÚmoderrxrÚprivate_key_attrrRs       rr
r
6s €ðDÐ(Ñ(ÜÐ0°8Ñ;Ó<Ð<ä#”vÔØ—
‘
× Ñ ˆØÐ؏y‰y×#Ñ# FÔ+ÜÐ?Ó@Ð @Ü    CœÔ     Ü˜Ÿ™“ˆØÑäÐ0´3´t¸C³y³>ÑAÓBÐBà
‡ÔܘcÐ#3Ó4‰ àˆ à Ð&Ò&Ü(¨¨h¸¸{ÓKÐKØ     Ò    Ü cœ6Ô "Ü% c¨8°U¸HÓEÐ Eä# C¨°5¸(ÓCÐ CäÐ0°4Ñ7Ó8Ð8r)r+N)ÚCrypto.Util.asn1rÚCrypto.Util.numberrÚCrypto.Math.NumbersrÚ Crypto.HashrÚCrypto.PublicKey.ECCrÚCrypto.PublicKey.DSArÚ__all__Úobjectr    rMror„r
rKrrú<module>r¥scðõD)Ý,Ý'åÝ'Ý'à ˜5Ð
!€ôw6ôwôtK  ôKô\B|ôBôD˜ôô>]9r