hyb
2026-01-30 44480e71b27aa9d4cb8441f50c873f1b110e9691
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
Ë
ž¬`iM?ãó”—dZdgZddlZddlmZmZmZmZmZm    Z    m
Z
m Z ddl m Z ddlmZmZddlmZedd    «ZGd
„de«Zd „Zy) z
Counter (CTR) mode.
ÚCtrModeéN)Úload_pycryptodome_raw_libÚ VoidPointerÚcreate_string_bufferÚget_raw_bufferÚ SmartPointerÚc_size_tÚ c_uint8_ptrÚis_writeable_buffer)Úget_random_bytes)Ú _copy_bytesÚ is_native_int)Ú long_to_byteszCrypto.Cipher._raw_ctra¾
                    int CTR_start_operation(void *cipher,
                                            uint8_t   initialCounterBlock[],
                                            size_t    initialCounterBlock_len,
                                            size_t    prefix_len,
                                            unsigned  counter_len,
                                            unsigned  littleEndian,
                                            void **pResult);
                    int CTR_encrypt(void *ctrState,
                                    const uint8_t *in,
                                    uint8_t *out,
                                    size_t data_len);
                    int CTR_decrypt(void *ctrState,
                                    const uint8_t *in,
                                    uint8_t *out,
                                    size_t data_len);
                    int CTR_stop_operation(void *ctrState);có&—eZdZdZd„Zdd„Zdd„Zy)ra**CounTeR (CTR)* mode.
 
    This mode is very similar to ECB, in that
    encryption of one block is done independently of all other blocks.
 
    Unlike ECB, the block *position* contributes to the encryption
    and no information leaks about symbol frequency.
 
    Each message block is associated to a *counter* which
    must be unique across all messages that get encrypted
    with the same key (not just within the same message).
    The counter is as big as the block size.
 
    Counters can be generated in several ways. The most
    straightword one is to choose an *initial counter block*
    (which can be made public, similarly to the *IV* for the
    other modes) and increment its lowest **m** bits by one
    (modulo *2^m*) for each block. In most cases, **m** is
    chosen to be half the block size.
 
    See `NIST SP800-38A`_, Section 6.5 (for the mode) and
    Appendix B (for how to manage the *initial counter block*).
 
    .. _`NIST SP800-38A` : http://csrc.nist.gov/publications/nistpubs/800-38a/sp800-38a.pdf
 
    :undocumented: __init__
    c
ó—t|«||zk(rtd||«|_    t«|_t
j |j«t|«tt|««t|«|||jj««}|rtd|z«‚t|jj«t
j«|_|j«t|«|_    ddg|_y)aBCreate a new block cipher, configured in CTR mode.
 
        :Parameters:
          block_cipher : C pointer
            A smart pointer to the low-level block cipher instance.
 
          initial_counter_block : bytes/bytearray/memoryview
            The initial plaintext to use to generate the key stream.
 
            It is as large as the cipher block, and it embeds
            the initial value of the counter.
 
            This value must not be reused.
            It shall contain a nonce or a random component.
            Reusing the *initial counter block* for encryptions
            performed with the same key compromises confidentiality.
 
          prefix_len : integer
            The amount of bytes at the beginning of the counter block
            that never change.
 
          counter_len : integer
            The length in bytes of the counter embedded in the counter
            block.
 
          little_endian : boolean
            True if the counter in the counter block is an integer encoded
            in little endian mode. If False, it is big endian.
        Nz)Error %X while instantiating the CTR modeÚencryptÚdecrypt)Úlenr ÚnoncerÚ_stateÚ raw_ctr_libÚCTR_start_operationÚgetr
r    Ú
address_ofÚ
ValueErrorrÚCTR_stop_operationÚreleaseÚ
block_sizeÚ_next)ÚselfÚ block_cipherÚinitial_counter_blockÚ
prefix_lenÚ counter_lenÚ little_endianÚresults       õjH:\项目\archive\测试组\脚本\Change_password\venv_build\Lib\site-packages\Crypto/Cipher/_mode_ctr.pyÚ__init__zCtrMode.__init__Ysò€ô@ Ð$Ó %¨°kÑ)AÒ AÜ$ T¨:Ð7LÓMˆDŒJØ Aä!“mˆŒ Ü×0Ñ0°×1AÑ1AÓ1CÜ1<Ð=RÓ1SÜ19¼#Ð>SÓ:TÓ1UÜ19¸*Ó1EØ1<Ø1>Ø15·±×1GÑ1GÓ1Ió Kˆñ ÜÐHØ%ñ&ó'ð 'ô
# 4§;¡;§?¡?Ó#4Ü#.×#AÑ#AóCˆŒ ð
    ×ÑÔäÐ3Ó4ˆŒØ@à Ð+ˆ
óNc
ó—d|jvr td«‚dg|_|€tt|««}nF|}t    |«s td«‚t|«t|«k7rt dt|«z«‚t j|jj«t|«t|«tt|«««}|r|dk(r td«‚t d|z«‚|€ t|«Sy)    aõEncrypt data with the key and the parameters set at initialization.
 
        A cipher object is stateful: once you have encrypted a message
        you cannot encrypt (or decrypt) another message using the same
        object.
 
        The data to encrypt can be broken up in two or
        more pieces and `encrypt` can be called multiple times.
 
        That is, the statement:
 
            >>> c.encrypt(a) + c.encrypt(b)
 
        is equivalent to:
 
             >>> c.encrypt(a+b)
 
        This function does not add any padding to the plaintext.
 
        :Parameters:
          plaintext : bytes/bytearray/memoryview
            The piece of data to encrypt.
            It can be of any length.
        :Keywords:
          output : bytearray/memoryview
            The location where the ciphertext must be written to.
            If ``None``, the ciphertext is returned.
        :Return:
          If ``output`` is ``None``, the ciphertext is returned as ``bytes``.
          Otherwise, ``None``.
        rz*encrypt() cannot be called after decrypt()Nú4output must be a bytearray or a writeable memoryviewú9output must have the same length as the input  (%d bytes)éú*The counter has wrapped around in CTR modez%Error %X while encrypting in CTR mode)rÚ    TypeErrorrrr rrÚ CTR_encryptrrr
r    Ú OverflowErrorr)r Ú    plaintextÚoutputÚ
ciphertextr&s     r'rzCtrMode.encrypt—s€ðB ˜DŸJ™JÑ &ÜÐHÓIÐ Iؐ[ˆŒ
à ˆ>Ü-¬c°)«nÓ=‰JàˆJä& vÔ.ÜРVÓWÐWä9‹~¤ V£Ò,Ü ð"0Ü25°i³.ñ"AóBðBô×(Ñ(¨¯©¯©Ó):Ü)4°YÓ)?Ü)4°ZÓ)@Ü)1´#°i³.Ó)AóCˆñ ؘҠÜ#ð%0ó1ð1äÐDÀvÑMÓNÐ Nà ˆ>Ü! *Ó-Ð -àr)c
ó—d|jvr td«‚dg|_|€tt|««}nF|}t    |«s td«‚t|«t|«k7rt dt|«z«‚t j|jj«t|«t|«tt|«««}|r|dk(r td«‚t d|z«‚|€ t|«Sy)    a÷Decrypt data with the key and the parameters set at initialization.
 
        A cipher object is stateful: once you have decrypted a message
        you cannot decrypt (or encrypt) another message with the same
        object.
 
        The data to decrypt can be broken up in two or
        more pieces and `decrypt` can be called multiple times.
 
        That is, the statement:
 
            >>> c.decrypt(a) + c.decrypt(b)
 
        is equivalent to:
 
             >>> c.decrypt(a+b)
 
        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.
        :Keywords:
          output : bytearray/memoryview
            The location where the plaintext must be written to.
            If ``None``, the plaintext is returned.
        :Return:
          If ``output`` is ``None``, the plaintext is returned as ``bytes``.
          Otherwise, ``None``.
        rz*decrypt() cannot be called after encrypt()Nr+r,r-r.z%Error %X while decrypting in CTR mode)rr/rrr rrÚ CTR_decryptrrr
r    r1r)r r4r3r2r&s     r'rzCtrMode.decrypt×s€ðB ˜DŸJ™JÑ &ÜÐHÓIÐ Iؐ[ˆŒ
à ˆ>Ü,¬S°«_Ó=‰IàˆIä& vÔ.ÜРVÓWÐWä:‹¤# f£+Ò-Ü ð"0Ü25°i³.ñ"AóBðBô×(Ñ(¨¯©¯©Ó):Ü)4°ZÓ)@Ü)4°YÓ)?Ü)1´#°j³/Ó)BóDˆñ ؘҠÜ#ð%0ó1ð1äÐDÀvÑMÓNÐ Nà ˆ>Ü! )Ó,Ð ,àr))N)Ú__name__Ú
__module__Ú __qualname__Ú__doc__r(rr©r)r'rr<s„ñò8<,ó|>ô@>r)c     ób—|j|«}|jdd«}|jdd«}|jdd«}|rtdt|«z«‚|||fdk7r td«‚|€ì|€3|jdkr td    «‚t |jd
z«}n#t |«|jk\r td «‚|jt |«z
}|€d }t|«r)d |dzzd z
|kr td«‚|t||«z}n,t |«|k7rtdt |«|fz«‚||z}t||t |«|d«St|«}    |jd«}|jd«}    |jd«}
|jd«}|jd«} g} |d kDr3| jtjd|dz««|dz}|d kDrŒ3| dgt!d |t | «z
«zz } | s| j#«|    dj%| «z|
z}t |«|jk7r#tdt |«|jfz«‚t||t |    «|| «S#t$r td«‚wxYw)a4Instantiate a cipher object that performs CTR encryption/decryption.
 
    :Parameters:
      factory : module
        The underlying block cipher, a module from ``Crypto.Cipher``.
 
    :Keywords:
      nonce : bytes/bytearray/memoryview
        The fixed part at the beginning of the counter block - the rest is
        the counter number that gets increased when processing the next block.
        The nonce must be such that no two messages are encrypted under the
        same key and the same nonce.
 
        The nonce must be shorter than the block size (it can have
        zero length; the counter is then as long as the block).
 
        If this parameter is not present, a random nonce will be created with
        length equal to half the block size. No random nonce shorter than
        64 bits will be created though - you must really think through all
        security consequences of using such a short block size.
 
      initial_value : posive integer or bytes/bytearray/memoryview
        The initial value for the counter. If not present, the cipher will
        start counting from 0. The value is incremented by one for each block.
        The counter number is encoded in big endian mode.
 
      counter : object
        Instance of ``Crypto.Util.Counter``, which allows full customization
        of the counter block. This parameter is incompatible to both ``nonce``
        and ``initial_value``.
 
    Any other keyword will be passed to the underlying block cipher.
    See the relevant documentation for details (at least ``key`` will need
    to be present).
    ÚcounterNrÚ initial_valuez#Invalid parameters for CTR mode: %s)NNz<'counter' and 'nonce'/'initial_value' are mutually exclusiveéz7Impossible to create a safe nonce for short block sizesézNonce is too longrééz"Initial counter value is too largez@Incorrect length for counter byte string (%d bytes, expected %d)Fr$ÚprefixÚsuffixr%z6Incorrect counter object (use Crypto.Util.Counter.new)ÚBéÿór)z?Size of the counter block (%d bytes) must match block size (%d))Ú_create_base_cipherÚpopr/Ústrrr rrrrrÚdictÚKeyErrorÚappendÚstructÚpackÚmaxÚreverseÚjoin) ÚfactoryÚkwargsÚ cipher_stater=rr>r$r"Ú_counterrCrDr%Úwordss              r'Ú_create_ctr_cipherrXsý€ðJ×.Ñ.¨vÓ6€Làj‰j˜ DÓ)€GØ J‰Jw Ó %€EØ—J‘J˜°Ó5€MÙ ÜÐ=ÄÀFà ÑKÓLÐLàР }Ð5¸ÒEÜð2ó3ð    3ð€à ˆ=Ø×!Ñ! BÒ&Üð!/ó0ð0ä$ W×%7Ñ%7¸1Ñ%<Ó=‰Eä5‹z˜W×/Ñ/Ò/Ü Ð!4Ó5Ð5ð×(Ñ(¬3¨u«:Ñ5ˆ à Ð  ØˆMä ˜Ô 'ؐk A‘oÑ&¨!Ñ+¨mÒ;Ü Ð!EÓFÐFØ$)¬M¸-ÈÓ,UÑ$UÑ !ä=Ó! [Ò0Ü Ð!cÜ"% mÓ"4°kÐ!Bñ"CóDðDà$)¨MÑ$9Ð !ä|Ø,ܘ5“zØ"Øó    ð    ôG‹}€Hð:Ø—l‘l =Ó1ˆ Ø—‘˜hÓ'ˆØ—‘˜hÓ'ˆØ Ÿ ™  _Ó5ˆ Ø Ÿ ™  _Ó5ˆ ð €EØ
˜!Ò
Ø  ‰ ”V—[‘[  m°cÑ&9Ó:Ô;ؘ!ш ð ˜!Ó
ð
ˆgˆYœ˜Q  ¬c°%«jÑ 8Ó9Ñ 9Ñ9€EÙ Ø  ‰ ŒØ" S§X¡X¨e£_Ñ4°vÑ=Ðä
Ð  Ó! W×%7Ñ%7Ò7Üð,Ü/2Ð3HÓ/IØ/6×/AÑ/Að/CñCóDð    Dô <Ð!6ܐv“;  ¨]ó <ð<øô' ò:Üð9ó:ð    :ð:ús Å/AJÊJ.)r:Ú__all__rNÚCrypto.Util._raw_apirrrrrr    r
r Ú Crypto.Randomr ÚCrypto.Util.py3compatr rÚCrypto.Util.numberrrÚobjectrrXr;r)r'ú<module>r_sXðñ.ð ˆ+€ã ÷7÷7ó7õ
+ß<Ý,á'Ð(@ðC?ó*€ ô(YˆfôYóxq<r)