hyb
2026-01-30 7657e1b2fa251a2ea372710ad75cb395a3c0e374
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
Ë
ž¬`i(ãód—ddgZddlmZddlmZmZddlmZmZm    Z    ddl
m Z Gd„d«Z d d
„Z y    ) ÚnewÚPKCS115_Cipheré)ÚRandom)Ú bytes_to_longÚ long_to_bytes)ÚbordÚis_bytesÚ _copy_bytesé)Ú pkcs1_decodecó0—eZdZdZd„Zd„Zd„Zd„Zdd„Zy)    rz”This cipher can perform PKCS#1 v1.5 RSA encryption or decryption.
    Do not instantiate directly. Use :func:`Crypto.Cipher.PKCS1_v1_5.new` instead.có —||_||_y)aJInitialize this PKCS#1 v1.5 cipher object.
 
        :Parameters:
         key : an RSA key object
          If a private half is given, both encryption and decryption are possible.
          If a public half is given, only encryption is possible.
         randfunc : callable
          Function that returns random bytes.
        N)Ú_keyÚ    _randfunc)ÚselfÚkeyÚrandfuncs   õkH:\项目\archive\测试组\脚本\Change_password\venv_build\Lib\site-packages\Crypto/Cipher/PKCS1_v1_5.pyÚ__init__zPKCS115_Cipher.__init__#s€ðˆŒ    Ø!ˆócó6—|jj«S)z=Return True if this cipher object can be used for encryption.)rÚ can_encrypt©rs rrzPKCS115_Cipher.can_encrypt1ó€ày‰y×$Ñ$Ó&Ð&rcó6—|jj«S)z=Return True if this cipher object can be used for decryption.)rÚ can_decryptrs rrzPKCS115_Cipher.can_decrypt5rrcóæ—|jj«}t|«}||dz
kDr td«‚g}t|«||z
dz
k7rI|j    d«}t |d«dk(rŒ7|j |«t|«||z
dz
k7rŒIdj|«}d|zdztd    d    |«z}t|«}|jj|«}t||«}    |    S)
aåProduce the PKCS#1 v1.5 encryption of a message.
 
        This function is named ``RSAES-PKCS1-V1_5-ENCRYPT``, and it is specified in
        `section 7.2.1 of RFC8017
        <https://tools.ietf.org/html/rfc8017#page-28>`_.
 
        :param message:
            The message to encrypt, also known as plaintext. It can be of
            variable length, but not longer than the RSA modulus (in bytes) minus 11.
        :type message: bytes/bytearray/memoryview
 
        :Returns: A byte string, the ciphertext in which the message is encrypted.
            It is as long as the RSA modulus (in bytes).
 
        :Raises ValueError:
            If the RSA key length is not sufficiently long to deal with the given
            message.
        é zPlaintext is too long.ér rrsóN) rÚ size_in_bytesÚlenÚ
ValueErrorrrÚappendÚjoinr
rÚ_encryptr)
rÚmessageÚkÚmLenÚpsÚnew_byteÚemÚem_intÚm_intÚcs
          rÚencryptzPKCS115_Cipher.encrypt9sð€ð* I‰I× #Ñ #Ó %ˆÜ7‹|ˆð !b‘&Š=ÜÐ5Ó6Ð 6à ˆÜ"‹g˜˜T™ A™Ò%Ø—~‘~ aÓ(ˆHܐH˜Q‘KÓ  DÒ(ØØ I‰IhÔ ô    "‹g˜˜T™ A™Ó%ð
X‰Xb‹\ˆà ˜2Ñ  Ñ '¬+°d¸DÀ'Ó*JÑ Jˆä˜rÓ"ˆà—    ‘    ×"Ñ" 6Ó*ˆä ˜% Ó #ˆØˆrcón—|jj«}t|«|k7rtd|z«‚t    |«}|jj |«}t t|««}t|«rt|«|kDrt|d||«}|dkr|S||dSt||||«}||dS)aÓDecrypt a PKCS#1 v1.5 ciphertext.
 
        This is the function ``RSAES-PKCS1-V1_5-DECRYPT`` specified in
        `section 7.2.2 of RFC8017
        <https://tools.ietf.org/html/rfc8017#page-29>`_.
 
        Args:
          ciphertext (bytes/bytearray/memoryview):
            The ciphertext that contains the message to recover.
          sentinel (any type):
            The object to return whenever an error is detected.
          expected_pt_len (integer):
            The length the plaintext is known to have, or 0 if unknown.
 
        Returns (byte string):
            It is either the original message or the ``sentinel`` (in case of an error).
 
        .. warning::
            PKCS#1 v1.5 decryption is intrinsically vulnerable to timing
            attacks (see `Bleichenbacher's`__ attack).
            **Use PKCS#1 OAEP instead**.
 
            This implementation attempts to mitigate the risk
            with some constant-time constructs.
            However, they are not sufficient by themselves: the type of protocol you
            implement and the way you handle errors make a big difference.
 
            Specifically, you should make it very hard for the (malicious)
            party that submitted the ciphertext to quickly understand if decryption
            succeeded or not.
 
            To this end, it is recommended that your protocol only encrypts
            plaintexts of fixed length (``expected_pt_len``),
            that ``sentinel`` is a random byte string of the same length,
            and that processing continues for as long
            as possible even if ``sentinel`` is returned (i.e. in case of
            incorrect decryption).
 
            .. __: https://dx.doi.org/10.1007/BFb0055716
        z/Ciphertext with incorrect length (not %d bytes)rrN)
rr!r"r#rÚ_decrypt_to_bytesÚbytesÚ    bytearrayr    r )    rÚ
ciphertextÚsentinelÚexpected_pt_lenr(Úct_intr,ÚoutputÚsizes             rÚdecryptzPKCS115_Cipher.decryptfs€ðV I‰I× #Ñ #Ó %ˆô ˆz‹?˜aÒ ÜÐNÐQRÑRÓSÐ Sô˜zÓ*ˆðY‰Y× (Ñ (¨Ó 0ˆô”y “|Ó$ˆÜ˜Ô!¤S¨£]°QÒ%6Ü  C¨¸&ÓAˆDؐaŠxؐà˜d˜e}Ð$ô˜B ¨/¸6ÓBˆØdeˆ}ÐrN)r)    Ú__name__Ú
__module__Ú __qualname__Ú__doc__rrrr0r;©rrrrs#„ñVò "ò'ò'ò+ôZBrNcó>—|€tj}t||«S)aäCreate a cipher for performing PKCS#1 v1.5 encryption or decryption.
 
    :param key:
      The key to use to encrypt or decrypt the message. This is a `Crypto.PublicKey.RSA` object.
      Decryption is only possible if *key* is a private RSA key.
    :type key: RSA key object
 
    :param randfunc:
      Function that return random bytes.
      The default is :func:`Crypto.Random.get_random_bytes`.
    :type randfunc: callable
 
    :returns: A cipher object `PKCS115_Cipher`.
    )rÚget_random_bytesr)rrs  rrr«s"€ð ÐÜ×*Ñ*ˆÜ ˜#˜xÓ (Ð(r)N)Ú__all__ÚCryptorÚCrypto.Util.numberrrÚCrypto.Util.py3compatrr    r
Ú_pkcs1_oaep_decoder rrr@rrú<module>rHs3ðð. Ð"Ð
#€åß;ß=Ñ=Ý,÷IñIôX)r