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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
Ë
ž¬`i’6ãóx—ddlmZmZmZddlZddlmZmZmZddl    m
Z
ddlm Z Gd„d«Z d„Z d    „Zd
„Zd „Zy) é)ÚbchrÚbordÚ
iter_rangeN)Úceil_divÚ long_to_bytesÚ bytes_to_long)Ústrxor)ÚRandomcó(—eZdZdZd„Zd„Zd„Zd„Zy)Ú PSS_SigSchemezvA signature object for ``RSASSA-PSS``.
    Do not instantiate directly.
    Use :func:`Crypto.Signature.pss.new`.
    có<—||_||_||_||_y)atInitialize this PKCS#1 PSS signature scheme object.
 
        :Parameters:
          key : an RSA key object
            If a private half is given, both signature and
            verification are possible.
            If a public half is given, only verification is possible.
          mgfunc : callable
            A mask generation function that accepts two parameters:
            a string to use as seed, and the lenth of the mask to
            generate, in bytes.
          saltLen : integer
            Length of the salt, in bytes.
          randfunc : callable
            A function that returns random bytes.
        N)Ú_keyÚ_saltLenÚ_mgfuncÚ    _randfunc)ÚselfÚkeyÚmgfuncÚsaltLenÚrandfuncs     õgH:\项目\archive\测试组\脚本\Change_password\venv_build\Lib\site-packages\Crypto/Signature/pss.pyÚ__init__zPSS_SigScheme.__init__/s €ð$ˆŒ    ØˆŒ ؈Œ Ø!ˆócó6—|jj«S)z<Return ``True`` if this object can be used to sign messages.)rÚ has_private)rs rÚcan_signzPSS_SigScheme.can_signFs€ày‰y×$Ñ$Ó&Ð&rcó<‡—|j€ ‰j}n |j}|j€ˆfd„}n |j}tjj
j |jj«}t|d«}t‰|dz
|j||«}t|«}|jj|«}|tt|«|jj|jj«k7r t!d«‚|S)a~Create the PKCS#1 PSS signature of a message.
 
        This function is also called ``RSASSA-PSS-SIGN`` and
        it is specified in
        `section 8.1.1 of RFC8017 <https://tools.ietf.org/html/rfc8017#section-8.1.1>`_.
 
        :parameter msg_hash:
            This is an object from the :mod:`Crypto.Hash` package.
            It has been used to digest the message to sign.
        :type msg_hash: hash object
 
        :return: the signature encoded as a *byte string*.
        :raise ValueError: if the RSA key is not long enough for the given hash algorithm.
        :raise TypeError: if the RSA key has no private half.
        có•—t||‰«S©N©ÚMGF1©ÚxÚyÚmsg_hashs  €rú<lambda>z$PSS_SigScheme.sign.<locals>.<lambda>bóø€œt A q¨(Ó3€rééz+Fault detected in RSA private key operation)rÚ digest_sizerÚCryptoÚUtilÚnumberÚsizerÚnrÚ_EMSA_PSS_ENCODErrÚ_decrypt_to_bytesÚpowÚeÚ
ValueError)    rr%ÚsLenÚmgfÚmodBitsÚkÚemÚem_intÚ    signatures     `       rÚsignzPSS_SigScheme.signJsÛø€ð$ =‰=Ð  Ø×'Ñ'‰Dà—=‘=ˆDà <‰<Ð Û3‰Cà—,‘,ˆCä—+‘+×$Ñ$×)Ñ)¨$¯)©)¯+©+Ó6ˆô W˜aÓ  ˆä ˜h¨°©    °4·>±>À3ÈÓ Mˆä˜rÓ"ˆà—I‘I×/Ñ/°Ó7ˆ    à ”Sœ yÓ1°4·9±9·;±;ÀÇ    Á    Ç Á ÓLÒ LÜÐJÓKÐ KØÐrcóö‡—|j€ ‰j}n |j}|jr |j}nˆfd„}tjj
j |jj«}t|d«}t|«|k7r td«‚t|«}|jj|«}t|dz
d«}    t||    «}
t‰|
|dz
||«y)apCheck if the  PKCS#1 PSS signature over a message is valid.
 
        This function is also called ``RSASSA-PSS-VERIFY`` and
        it is specified in
        `section 8.1.2 of RFC8037 <https://tools.ietf.org/html/rfc8017#section-8.1.2>`_.
 
        :parameter msg_hash:
            The hash that was carried out over the message. This is an object
            belonging to the :mod:`Crypto.Hash` module.
        :type parameter: hash object
 
        :parameter signature:
            The signature that needs to be validated.
        :type signature: bytes
 
        :raise ValueError: if the signature is not valid.
        Ncó•—t||‰«Srr r"s  €rr&z&PSS_SigScheme.verify.<locals>.<lambda>r'rr(úIncorrect signaturer))rr*rr+r,r-r.rr/rÚlenr4rÚ_encryptrÚ_EMSA_PSS_VERIFY) rr%r;r5r6r7r8Ú signature_intr:ÚemLenr9s  `         rÚverifyzPSS_SigScheme.verifyusÎø€ð( =‰=Ð  Ø×'Ñ'‰Dà—=‘=ˆDØ <Š<Ø—,‘,‰Cã3ˆCä—+‘+×$Ñ$×)Ñ)¨$¯)©)¯+©+Ó6ˆô W˜aÓ  ˆä ˆy‹>˜QÒ ÜÐ2Ó3Ð 3ä% iÓ0ˆ à—‘×#Ñ# MÓ2ˆä˜ 1™ aÓ(ˆÜ ˜6 5Ó )ˆä˜ 2 w¨q¡y°#°tÕ<rN)Ú__name__Ú
__module__Ú __qualname__Ú__doc__rrr<rE©rrr r )s„ñò
"ò.'ò)óV,=rr cóþ—d}tt||j««D]E}t|d«}|j    «}|j ||z«||j «z}ŒGt|«|k\sJ‚|d|S)a»Mask Generation Function, described in `B.2.1 of RFC8017
    <https://tools.ietf.org/html/rfc8017>`_.
 
    :param mfgSeed:
        seed from which the mask is generated
    :type mfgSeed: byte string
 
    :param maskLen:
        intended length in bytes of the mask
    :type maskLen: integer
 
    :param hash_gen:
        A module or a hash object from :mod:`Crypto.Hash`
    :type hash_object:
 
    :return: the mask, as a *byte string*
    réN)rrr*rÚnewÚupdateÚdigestr@)ÚmgfSeedÚmaskLenÚhash_genÚTÚcounterÚcÚhobjs       rr!r!¤s€ð&     €AÜœh w°×0DÑ0DÓEÓFòˆÜ ˜' 1Ó %ˆØ|‰|‹~ˆØ  ‰ G˜a‘KÔ Ø — ‘ “ Ñ ‰ð    ô
ˆq‹6WÒ ÐÐ Ø ˆXˆgˆ;Ðrcó~—t|d«}d}td|z|z
«D]
}|dz    dz}Œ ||j|zdzkr td«‚||«}t    d«dz|j «z|z}    |j «}
|
j|    «t    d«||z
|jz
dz
z} | t    d«z|z} ||
j «||jz
dz
«} t| | «}t    t|d«|z«|ddz}||
j «zt    d«z}|S)    a
    Implement the ``EMSA-PSS-ENCODE`` function, as defined
    in PKCS#1 v2.1 (RFC3447, 9.1.1).
 
    The original ``EMSA-PSS-ENCODE`` actually accepts the message ``M``
    as input, and hash it internally. Here, we expect that the message
    has already been hashed instead.
 
    :Parameters:
      mhash : hash object
        The hash object that holds the digest of the message being signed.
      emBits : int
        Maximum length of the final encoding, in bits.
      randFunc : callable
        An RNG function that accepts as only parameter an int, and returns
        a string of random bytes, to be used as salt.
      mgf : callable
        A mask generation function that accepts two parameters: a string to
        use as seed, and the lenth of the mask to generate, in bytes.
      sLen : int
        Length of the salt, in bytes.
 
    :Return: An ``emLen`` byte long string that encodes the hash
      (with ``emLen = \ceil(emBits/8)``).
 
    :Raise ValueError:
        When digest or salt length are too big.
    r(rr)é€éz6Digest or salt length are too long for given key size.Né¼)
rrr*r4rrOrMrNr    r)ÚmhashÚemBitsÚrandFuncr6r5rDÚlmaskÚiÚsaltÚm_primeÚhÚpsÚdbÚdbMaskÚmaskedDBr9s                rr0r0ÁsQ€ô< V˜QÓ €Eð €EÜ ˜˜%™ ™Ó 'ò"ˆØ˜‘
˜TÑ!‰ð"ð
 ˆu× Ñ  Ñ% aÑ'Ò'Üð0ó1ð    1ñ D‹>€Dä1‹ga‰i˜%Ÿ,™,›.Ñ(¨4Ñ/€Gà     ‰    ‹ €A؇HHˆWÔä     ˆa‹%˜‘*˜U×.Ñ.Ñ.¨qÑ0Ñ    1€Bà     Œd1‹g‰˜Ñ    €Bá —‘“˜U 5×#4Ñ#4Ñ4°QÑ6Ó 7€Fäb˜&Ó!€Hä”D˜ !™Ó%¨¨Ñ.Ó/°(¸1¸2°,Ñ>€Hà    A—H‘H“JÑ    ¤ d£Ñ    +€BØ €Ircó\—t|d«}d}td|z|z
«D]
}|dz    dz}Œ ||j|zdzkr td«‚t    |dd«d    k7r td«‚|d||jz
dz
}|||jz
dz
d}    |t |d«zr td«‚||    ||jz
dz
«}
t ||
«} tt | d«|z«| ddz} | jtd«||jz
|z
dz
ztd«z«s td«‚|dkDr| | d} nd
} td«dz|j«z| z} |j«}|j| «|j«}|    |k7r td«‚y) a«
    Implement the ``EMSA-PSS-VERIFY`` function, as defined
    in PKCS#1 v2.1 (RFC3447, 9.1.2).
 
    ``EMSA-PSS-VERIFY`` actually accepts the message ``M`` as input,
    and hash it internally. Here, we expect that the message has already
    been hashed instead.
 
    :Parameters:
      mhash : hash object
        The hash object that holds the digest of the message to be verified.
      em : string
        The signature to verify, therefore proving that the sender really
        signed the message that was received.
      emBits : int
        Length of the final encoding (em), in bits.
      mgf : callable
        A mask generation function that accepts two parameters: a string to
        use as seed, and the lenth of the mask to generate, in bytes.
      sLen : int
        Length of the salt, in bytes.
 
    :Raise ValueError:
        When the encoding is inconsistent, or the digest or salt lengths
        are too big.
    r(rr)rXrYr?éÿÿÿÿNrZr) rrr*r4Úordrr    rÚ
startswithrOrMrN)r[r9r\r6r5rDr^r_rfrbrerdr`rarVÚhps                rrBrBsÕ€ô8 V˜QÓ €Eð €EÜ ˜˜%™ ™Ó 'ò"ˆØ˜‘
˜TÑ!‰ð"ð
 ˆu× Ñ  Ñ% aÑ'Ò'ÜÐ.Ó/Ð/ä
ˆ2ˆbˆcˆ7ƒ|tÒÜÐ.Ó/Ð/àÐ,5˜×*Ñ*Ñ*¨1Ñ,Ð-€HØ
ˆ5×"Ñ"Ñ " 1Ñ $ RÐ(€Aà ŒtBq‘E‹{ÒÜÐ.Ó/Ð/á E˜%×+Ñ+Ñ+¨AÑ-Ó .€Fä    ˜&Ó    !€Bä     Œd2a‘5‹k˜U˜FÑ"Ó    # b¨¨ fÑ    ,€Bà =‰=œ˜a› %¨×(9Ñ(9Ñ"9¸$Ñ">¸qÑ"@ÑAÄDÈÃGÑKÔ LÜÐ.Ó/Ð/à ˆa‚xؐ4%&ˆz‰àˆä1‹ga‰i˜%Ÿ,™,›.Ñ(¨4Ñ/€Gà 9‰9‹;€D؇KKÔØ     ‰‹€BàˆB‚wÜÐ.Ó/Ð/ðrc óü—|jdd«}|jdd«}|jdd«}|€tj}|r%tdt    |j ««z«‚t ||||«S)aCreate an object for making or verifying PKCS#1 PSS signatures.
 
    :parameter rsa_key:
      The RSA key to use for signing or verifying the message.
      This is a :class:`Crypto.PublicKey.RSA` object.
      Signing is only possible when ``rsa_key`` is a **private** RSA key.
    :type rsa_key: RSA object
 
    :Keyword Arguments:
 
        *   *mask_func* (``callable``) --
            A function that returns the mask (as `bytes`).
            It must accept two parameters: a seed (as `bytes`)
            and the length of the data to return.
 
            If not specified, it will be the function :func:`MGF1` defined in
            `RFC8017 <https://tools.ietf.org/html/rfc8017#page-67>`_ and
            combined with the same hash algorithm applied to the
            message to sign or verify.
 
            If you want to use a different function, for instance still :func:`MGF1`
            but together with another hash, you can do::
 
                from Crypto.Hash import SHA256
                from Crypto.Signature.pss import MGF1
                mgf = lambda x, y: MGF1(x, y, SHA256)
 
        *   *salt_bytes* (``integer``) --
            Length of the salt, in bytes.
            It is a value between 0 and ``emLen - hLen - 2``, where ``emLen``
            is the size of the RSA modulus and ``hLen`` is the size of the digest
            applied to the message to sign or verify.
 
            The salt is generated internally, you don't need to provide it.
 
            If not specified, the salt length will be ``hLen``.
            If it is zero, the signature scheme becomes deterministic.
 
            Note that in some implementations such as OpenSSL the default
            salt length is ``emLen - hLen - 2`` (even though it is not more
            secure than ``hLen``).
 
        *   *rand_func* (``callable``) --
            A function that returns random ``bytes``, of the desired length.
            The default is :func:`Crypto.Random.get_random_bytes`.
 
    :return: a :class:`PSS_SigScheme` signature object
    Ú    mask_funcNÚ
salt_bytesÚ    rand_funczUnknown keywords: )Úpopr
Úget_random_bytesr4ÚstrÚkeysr )Úrsa_keyÚkwargsrmÚsalt_lenros     rrMrMJsv€ðd—
‘
˜;¨Ó-€I؏z‰z˜,¨Ó-€HØ—
‘
˜;¨Ó-€IØÐÜ×+Ñ+ˆ    Ù ÜÐ-´°F·K±K³MÓ0BÑBÓCÐCÜ ˜ )¨X°yÓ AÐAr)ÚCrypto.Util.py3compatrrrÚCrypto.Util.numberr+rrrÚCrypto.Util.strxorr    r
r r!r0rBrMrJrrú<module>rzsGð÷>9Ñ8Û÷"ñ"õ&Ý÷x=ñx=òvò:=ò@F0óR9Br