ffddlmZddlmZmZmZmZmZmZm Z m Z ddl m Z eddZ GddZd d Zd Zd ZdS) ) _copy_bytes)load_pycryptodome_raw_libcreate_string_bufferget_raw_buffer VoidPointer SmartPointerc_size_t c_uint8_ptris_writeable_buffer)get_random_byteszCrypto.Cipher._Salsa20a int Salsa20_stream_init(uint8_t *key, size_t keylen, uint8_t *nonce, size_t nonce_len, void **pSalsaState); int Salsa20_stream_destroy(void *salsaState); int Salsa20_stream_encrypt(void *salsaState, const uint8_t in[], uint8_t out[], size_t len); c(eZdZdZdZddZddZdS) Salsa20CipherzSalsa20 cipher object. Do not create it directly. Use :py:func:`new` instead. :var nonce: The nonce with length 8 :vartype nonce: byte string c t|tvrtdt|zt|dkrtdt|ztdd||_t |_tt|tt|t|tt||j }|rtdt|j tj|_d|_t||_dS)zQInitialize a Salsa20 cipher object See also `new()` at the module level.z+Incorrect key length for Salsa20 (%d bytes)z-Incorrect nonce length for Salsa20 (%d bytes)Nz'Error %d instantiating a Salsa20 cipher)lenkey_size ValueErrorrnoncer_state_raw_salsa20_libSalsa20_stream_initr r address_ofrgetSalsa20_stream_destroy block_size)selfkeyrresults w/builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib64/python3.11/site-packages/Crypto/Cipher/Salsa20.py__init__zSalsa20Cipher.__init__6s; s888 # #JSQTXXUVV V u::??L ZZ()) )!tU33 !mm !55#C(( S**#E** U,, ..00 22  HFGG G"4;??#4#4#3#JLL C Nc |tt|}n_|}t|stdt|t|krt dt|zt |jt|t|tt|}|rt d|z|t|SdS)aEncrypt a piece of data. Args: plaintext(bytes/bytearray/memoryview): The data to encrypt, of any size. Keyword Args: output(bytes/bytearray/memoryview): The location where the ciphertext is written to. If ``None``, the ciphertext is returned. Returns: If ``output`` is ``None``, the ciphertext is returned as ``bytes``. Otherwise, ``None``. Nz4output must be a bytearray or a writeable memoryviewz9output must have the same length as the input (%d bytes)z&Error %d while encrypting with Salsa20) rrr TypeErrorrrSalsa20_stream_encryptrrr r r)r plaintextoutput ciphertextrs r encryptzSalsa20Cipher.encryptSs  >-c)nn==JJJ&v.. X VWWW9~~V,, "025i.."ABBB"88)-):):)4Y)?)?)4Z)@)@)1#i..)A)A CC  PENOO O >!*-- -4r"c |||S#t$r5}tt|ddd}~wwxYw)aDecrypt a piece of data. Args: ciphertext(bytes/bytearray/memoryview): The data to decrypt, of any size. Keyword Args: output(bytes/bytearray/memoryview): The location where the plaintext is written to. If ``None``, the plaintext is returned. Returns: If ``output`` is ``None``, the plaintext is returned as ``bytes``. Otherwise, ``None``. )r'encdecN)r)rstrreplace)rr(r'es r decryptzSalsa20Cipher.decryptys^ ;<< 6<:: : ; ; ;SVV^^E599:: : ;s A0AAN)__name__ __module__ __qualname____doc__r!r)r0r"r rr.sV!!!:$$$$L;;;;;;r"rNcD|td}t||S)a%Create a new Salsa20 cipher :keyword key: The secret key to use. It must be 16 or 32 bytes long. :type key: bytes/bytearray/memoryview :keyword nonce: A value that must never be reused for any other encryption done with this key. It must be 8 bytes long. If not provided, a random byte string will be generated (you can read it back via the ``nonce`` attribute of the returned object). :type nonce: bytes/bytearray/memoryview :Return: a :class:`Crypto.Cipher.Salsa20.Salsa20Cipher` object Nr)r r)rrs r newr8s&" } ## e $ $$r"r) r1)Crypto.Util.py3compatrCrypto.Util._raw_apirrrrrr r r Crypto.Randomr rrr8rrr6r"r r>s2.-----DDDDDDDDDDDDDDDDDDDD +*****,,-E  [;[;[;[;[;[;[;[;|%%%%.  r"