U +¥Mb ã@sbddlmZddlmZmZmZmZmZmZm Z eddƒZ Gdd„dƒZ dd„Z d Z ed d ƒZd S) é)Úb)Úload_pycryptodome_raw_libÚ VoidPointerÚcreate_string_bufferÚget_raw_bufferÚ SmartPointerÚc_size_tÚ c_uint8_ptrzCrypto.Cipher._ARC4al int ARC4_stream_encrypt(void *rc4State, const uint8_t in[], uint8_t out[], size_t len); int ARC4_stream_init(uint8_t *key, size_t keylen, void **pRc4State); int ARC4_stream_destroy(void *rc4State); c@s(eZdZdZdd„Zdd„Zdd„ZdS) Ú ARC4CipherzcARC4 cipher object. Do not create it directly. Use :func:`Crypto.Cipher.ARC4.new` instead. cOsÄt|ƒdkr"|d}|dd…}n | dd¡}t|ƒtkrJtdt|ƒƒ‚tƒ|_t t|ƒt t|ƒƒ|j  ¡¡}|dkr†td|ƒ‚t |j  ¡tj ƒ|_|dkr°| d|¡d|_t|ƒ|_dS)zOInitialize an ARC4 cipher object See also `new()` at the module level.réNZdropz$Incorrect ARC4 key length (%d bytes)z'Error %d while creating the ARC4 cipheró)ÚlenÚpopÚkey_sizeÚ ValueErrorrÚ_stateÚ _raw_arc4_libZARC4_stream_initr rZ address_ofrÚgetZARC4_stream_destroyÚencryptÚ block_size)ÚselfÚkeyÚargsÚkwargsZndropÚresult©rú9/tmp/pip-target-t616c12r/lib/python/Crypto/Cipher/ARC4.pyÚ__init__,s0   ÿ  þÿ ÿzARC4Cipher.__init__cCsFtt|ƒƒ}t |j ¡t|ƒ|tt|ƒƒ¡}|r>td|ƒ‚t |ƒS)zíEncrypt a piece of data. :param plaintext: The data to encrypt, of any size. :type plaintext: bytes, bytearray, memoryview :returns: the encrypted byte string, of equal length as the plaintext. z"Error %d while encrypting with RC4) rr rZARC4_stream_encryptrrr rrr)rÚ plaintextÚ ciphertextrrrrrNs   ý zARC4Cipher.encryptc CsHz | |¡WStk rB}ztt|ƒ dd¡ƒ‚W5d}~XYnXdS)zðDecrypt a piece of data. :param ciphertext: The data to decrypt, of any size. :type ciphertext: bytes, bytearray, memoryview :returns: the decrypted byte string, of equal length as the ciphertext. ÚencÚdecN)rrÚstrÚreplace)rrÚerrrÚdecrypt`s  zARC4Cipher.decryptN)Ú__name__Ú __module__Ú __qualname__Ú__doc__rrr%rrrrr 's"r cOst|f|ž|ŽS)a¹Create a new ARC4 cipher. :param key: The secret key to use in the symmetric cipher. Its length must be in the range ``[5..256]``. The recommended length is 16 bytes. :type key: bytes, bytearray, memoryview :Keyword Arguments: * *drop* (``integer``) -- The amount of bytes to discard from the initial part of the keystream. In fact, such part has been found to be distinguishable from random data (while it shouldn't) and also correlated to key. The recommended value is 3072_ bytes. The default value is 0. :Return: an `ARC4Cipher` object .. _3072: http://eprint.iacr.org/2002/067.pdf )r )rrrrrrÚnewosr*r éiN)ZCrypto.Util.py3compatrZCrypto.Util._raw_apirrrrrrr rr r*rÚrangerrrrrÚs $ H