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
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
Ë
ž¬`i!8ãóŠ—dZdgZddlmZmZddlmZmZddlm    Z    ddl
m Z m Z ddl mZddlmZdd    lmZGd
„de«Zd „Zy ) z-
Synthetic Initialization Vector (SIV) mode.
ÚSivModeé)ÚhexlifyÚ    unhexlify)ÚbordÚ _copy_bytes)Ú    is_buffer)Ú long_to_bytesÚ bytes_to_long)Ú_S2V)ÚBLAKE2s)Úget_random_bytescóV—eZdZdZd„Zd„Zd„Zd„Zd„Zd„Z    d„Z
d    „Z d
„Z dd „Z dd „Zy )ra¡Synthetic Initialization Vector (SIV).
 
    This is an Authenticated Encryption with Associated Data (`AEAD`_) mode.
    It provides both confidentiality and authenticity.
 
    The header of the message may be left in the clear, if needed, and it will
    still be subject to authentication. The decryption step tells the receiver
    if the message comes from a source that really knowns the secret key.
    Additionally, decryption detects if any part of the message - including the
    header - has been modified or corrupted.
 
    Unlike other AEAD modes such as CCM, EAX or GCM, accidental reuse of a
    nonce is not catastrophic for the confidentiality of the message. The only
    effect is that an attacker can tell when the same plaintext (and same
    associated data) is protected with the same key.
 
    The length of the MAC is fixed to the block size of the underlying cipher.
    The key size is twice the length of the key of the underlying cipher.
 
    This mode is only available for AES ciphers.
 
    +--------------------+---------------+-------------------+
    |      Cipher        | SIV MAC size  |   SIV key length  |
    |                    |    (bytes)    |     (bytes)       |
    +====================+===============+===================+
    |    AES-128         |      16       |        32         |
    +--------------------+---------------+-------------------+
    |    AES-192         |      16       |        48         |
    +--------------------+---------------+-------------------+
    |    AES-256         |      16       |        64         |
    +--------------------+---------------+-------------------+
 
    See `RFC5297`_ and the `original paper`__.
 
    .. _RFC5297: https://tools.ietf.org/html/rfc5297
    .. _AEAD: http://blog.cryptographyengineering.com/2012/05/how-to-choose-authenticated-encryption.html
    .. __: http://www.cs.ucdavis.edu/~rogaway/papers/keywrap.pdf
 
    :undocumented: __init__
    cóæ—|j|_    ||_||_t|«dvrt    dt|«z«‚|Bt |«s t d«‚t|«dk(r t    d«‚tdd|«|_    t|«dz}d|_    t|d|||j¬«|_ ||d|_ |j|d||jfi|¤Žgd¢|_y)    N)é é0é@zIncorrect key length (%d bytes)z?When provided, the nonce must be bytes, bytearray or memoryviewrz*When provided, the nonce must be non-emptyé)Ú    ciphermodÚ cipher_params©ÚupdateÚencryptÚdecryptÚdigestÚverify)Ú
block_sizeÚ_factoryÚ_cipher_paramsÚlenÚ
ValueErrorrÚ    TypeErrorrÚnonceÚ_mac_tagr Ú_kdfÚ_subkey_cipherÚnewÚMODE_ECBÚ_next)ÚselfÚfactoryÚkeyr"ÚkwargsÚ subkey_sizes      õjH:\项目\archive\测试组\脚本\Change_password\venv_build\Lib\site-packages\Crypto/Cipher/_mode_siv.pyÚ__init__zSivMode.__init__[sý€à!×,Ñ,ˆŒØ@àˆŒ à$ˆÔä ˆs‹8˜<Ñ 'ÜÐ>ÄÀSÃÑIÓJÐ Jà РܘUÔ#ÜРaÓbÐbä5‹z˜QŠÜ Ð!MÓNÐNä$ T¨4°Ó7ˆDŒJð ô˜#“h !‘mˆ àˆŒ ܘ˜\˜kÐ*Ø#*Ø'+×':Ñ':ô<ˆŒ    ð" + ,Ð/ˆÔð    ˆ ‰ C˜ ˜Ð% w×'7Ñ'7ÑB¸6ÒBò*ˆ
ócó´—t|«}|dz}|jj|j|jjf|ddœ|j
¤ŽS)z*Create a new CTR cipher from V in SIV model    ÿÿýÿ÷ÿÿÿÿr0)Ú initial_valuer")r
rr&r%ÚMODE_CTRr)r)ÚvÚv_intÚqs    r.Ú_create_ctr_cipherzSivMode._create_ctr_cipherse€ô˜aÓ ˆØ Ð6Ñ 6ˆØ ˆt}‰}× Ñ Ø×'Ñ'Ø—M‘M×*Ñ*ð+ð#$Øñ    +ð
×)Ñ)ñ +ð    +r0có|—d|jvr td«‚gd¢|_|jj|«S)aüProtect one associated data component
 
        For SIV, the associated data is a sequence (*vector*) of non-empty
        byte strings (*components*).
 
        This method consumes the next component. It must be called
        once for each of the components that constitue the associated data.
 
        Note that the components have clear boundaries, so that:
 
            >>> cipher.update(b"builtin")
            >>> cipher.update(b"securely")
 
        is not equivalent to:
 
            >>> cipher.update(b"built")
            >>> cipher.update(b"insecurely")
 
        If there is no associated data, this method must not be called.
 
        :Parameters:
          component : bytes/bytearray/memoryview
            The next associated data component.
        rz<update() can only be called immediately after initializationr)r(r!r$r)r)Ú    components  r.rzSivMode.updatesE€ð4 ˜4Ÿ:™:Ñ %ÜðDóEð Eò*ˆŒ
ðy‰y×Ñ     Ó*Ð*r0có—td«‚)z±
        For SIV, encryption and MAC authentication must take place at the same
        point. This method shall not be used.
 
        Use `encrypt_and_digest` instead.
        zEencrypt() not allowed for SIV mode. Use encrypt_and_digest() instead.©r!)r)Ú    plaintexts  r.rzSivMode.encrypt°ó€ôð=ó>ð    >r0có—td«‚)z«
        For SIV, decryption and verification must take place at the same
        point. This method shall not be used.
 
        Use `decrypt_and_verify` instead.
        zEdecrypt() not allowed for SIV mode. Use decrypt_and_verify() instead.r;)r)Ú
ciphertexts  r.rzSivMode.decrypt»r=r0có²—d|jvr td«‚dg|_|j€|jj    «|_|jS)zýCompute the *binary* MAC tag.
 
        The caller invokes this function at the very end.
 
        This method returns the MAC that shall be sent to the receiver,
        together with the ciphertext.
 
        :Return: the MAC, as a byte string.
        rzAdigest() cannot be called when decrypting or validating a message)r(r!r#r$Úderive)r)s r.rzSivMode.digestÆsS€ð ˜4Ÿ:™:Ñ %Üð7ó8ð 8àZˆŒ
Ø =‰=Ð  Ø ŸI™I×,Ñ,Ó.ˆDŒM؏}‰}Ðr0c    ó~—dj|j«Dcgc]}dt|«z‘Œc}«Scc}w)z„Compute the *printable* MAC tag.
 
        This method is like `digest`.
 
        :Return: the MAC, as a hexadecimal string.
        Úz%02x)Újoinrr)r)Úxs  r.Ú    hexdigestzSivMode.hexdigestÙs0€ðw‰w°$·+±+³-Ö@¨Q˜¤ a£Ó(Ò@ÓAÐAùÒ@sž:có~—d|jvr td«‚dg|_|j€|jj    «|_t d«}t jd||j¬«}t jd||¬«}|j«|j«k7r td«‚y)a(Validate the *binary* MAC tag.
 
        The caller invokes this function at the very end.
 
        This method checks if the decrypted message is indeed valid
        (that is, if the key is correct) and it has not been
        tampered with while in transit.
 
        :Parameters:
          received_mac_tag : bytes/bytearray/memoryview
            This is the *binary* MAC, as received from the sender.
        :Raises ValueError:
            if the MAC does not match. The message has been tampered with
            or the key is incorrect.
        rz3verify() cannot be called when encrypting a messageNéé )Ú digest_bitsr+ÚdatazMAC check failed)
r(r!r#r$rAr r r&rr )r)Úreceived_mac_tagÚsecretÚmac1Úmac2s     r.rzSivMode.verifyâs¡€ð" ˜4Ÿ:™:Ñ %Üð9ó:ð :àZˆŒ
à =‰=Ð  Ø ŸI™I×,Ñ,Ó.ˆDŒMä! "Ó%ˆä{‰{ s°¸T¿]¹]ÔKˆÜ{‰{ s°Ð=MÔNˆà ;‰;‹=˜DŸK™K›MÒ )ÜÐ/Ó0Ð 0ð *r0có8—|jt|««y)aWValidate the *printable* MAC tag.
 
        This method is like `verify`.
 
        :Parameters:
          hex_mac_tag : string
            This is the *printable* MAC, as received from the sender.
        :Raises ValueError:
            if the MAC does not match. The message has been tampered with
            or the key is incorrect.
        N)rr)r)Ú hex_mac_tags  r.Ú    hexverifyzSivMode.hexverifys€ð      ‰ ”I˜kÓ*Õ+r0NcóŽ—d|jvr td«‚dg|_t|d«r%|jj    |j
«|jj    |«|jj «|_|j|j«}|j||¬«|jfS)a\Perform encrypt() and digest() in one step.
 
        :Parameters:
          plaintext : bytes/bytearray/memoryview
            The piece of data to encrypt.
        :Keywords:
          output : bytearray/memoryview
            The location where the ciphertext must be written to.
            If ``None``, the ciphertext is returned.
        :Return:
            a tuple with two items:
 
            - the ciphertext, as ``bytes``
            - the MAC tag, as ``bytes``
 
            The first item becomes ``None`` when the ``output`` parameter
            specified a location for the result.
        rz@encrypt() can only be called after initialization or an update()rr"©Úoutput)
r(r!Úhasattrr$rr"rAr#r7r)r)r<rUÚciphers    r.Úencrypt_and_digestzSivMode.encrypt_and_digests¥€ð( ˜DŸJ™JÑ &Üð=ó>ð >ðZˆŒ
ô 4˜Ô !Ø I‰I× Ñ ˜TŸZ™ZÔ (Ø     ‰    ×јÔ#ØŸ    ™    ×(Ñ(Ó*ˆŒ à×(Ñ(¨¯©Ó7ˆà~‰~˜i°ˆ~Ó7¸¿¹ÐFÐFr0cóp—d|jvr td«‚dg|_|j|«|_|jj    ||¬«}t |d«r%|j j|j«|j j|€|n|«|j|«|S)aPPerform decryption and verification in one step.
 
        A cipher object is stateful: once you have decrypted a message
        you cannot decrypt (or encrypt) another message with the same
        object.
 
        You cannot reuse an object for encrypting
        or decrypting other data with the same key.
 
        This function does not remove any padding from the plaintext.
 
        :Parameters:
          ciphertext : bytes/bytearray/memoryview
            The piece of data to decrypt.
            It can be of any length.
          mac_tag : bytes/bytearray/memoryview
            This is the *binary* MAC, as received from the sender.
        :Keywords:
          output : bytearray/memoryview
            The location where the plaintext must be written to.
            If ``None``, the plaintext is returned.
        :Return: the plaintext as ``bytes`` or ``None`` when the ``output``
            parameter specified a location for the result.
        :Raises ValueError:
            if the MAC does not match. The message has been tampered with
            or the key is incorrect.
        rz@decrypt() can only be called after initialization or an update()rrTr")
r(r!r7Ú_cipherrrVr$rr"r)r)r?Úmac_tagrUr<s     r.Údecrypt_and_verifyzSivMode.decrypt_and_verify6s¥€ð: ˜DŸJ™JÑ &ÜðCóDð DàZˆŒ
ð×.Ñ.¨wÓ7ˆŒ à—L‘L×(Ñ(¨¸FÐ(ÓCˆ    ä 4˜Ô !Ø I‰I× Ñ ˜TŸZ™ZÔ (Ø     ‰    ×Ñ f n™¸&ÔAØ  ‰ GÔàÐr0)N)Ú__name__Ú
__module__Ú __qualname__Ú__doc__r/r7rrrrrFrrRrXr\©r0r.rr1sE„ñ'òR$*òL
+ò!+òF    >ò    >òò&Bò1òB ,ó"GôH,r0c 󶗠   |jd«}|jdd«}t    ||||«S#t$r}tdt|«z«‚d}~wwxYw)a-Create a new block cipher, configured in
    Synthetic Initializaton Vector (SIV) mode.
 
    :Parameters:
 
      factory : object
        A symmetric cipher module from `Crypto.Cipher`
        (like `Crypto.Cipher.AES`).
 
    :Keywords:
 
      key : bytes/bytearray/memoryview
        The secret key to use in the symmetric cipher.
        It must be 32, 48 or 64 bytes long.
        If AES is the chosen cipher, the variants *AES-128*,
        *AES-192* and or *AES-256* will be used internally.
 
      nonce : bytes/bytearray/memoryview
        For deterministic encryption, it is not present.
 
        Otherwise, it is a value that must never be reused
        for encrypting message under this key.
 
        There are no restrictions on its length,
        but it is recommended to use at least 16 bytes.
    r+zMissing parameter: Nr")ÚpopÚKeyErrorr!Ústrr)r*r,r+Úer"s     r.Ú_create_siv_cipherrges_€ð88؏j‰j˜Óˆð J‰Jw Ó %€Eä 7˜C ¨Ó /Ð/øô ò8ÜÐ-´°A³Ñ6Ó7Ð7ûð8ús‚3³    A¼AÁAN)r`Ú__all__ÚbinasciirrÚCrypto.Util.py3compatrrÚCrypto.Util._raw_apirÚCrypto.Util.numberr    r
ÚCrypto.Protocol.KDFr Ú Crypto.Hashr Ú Crypto.Randomr Úobjectrrgrar0r.ú<module>rqs<ðñ>ð ˆ+€ç'ç3å*ç;Ý$ÝÝ*ôqˆfôqóh    #0r0