h8l/b d Z ddlZddlmZ ddlmZmZmZmZ ddl m
Z
mZmZm
Z
e
dd Zd Zd Zd
ZdZdZd
ZdZdZdZdZdZdZdS )a
Module's constants for the modes of operation supported with Triple DES:
:var MODE_ECB: :ref:`Electronic Code Book (ECB) `
:var MODE_CBC: :ref:`Cipher-Block Chaining (CBC) `
:var MODE_CFB: :ref:`Cipher FeedBack (CFB) `
:var MODE_OFB: :ref:`Output FeedBack (OFB) `
:var MODE_CTR: :ref:`CounTer Mode (CTR) `
:var MODE_OPENPGP: :ref:`OpenPGP Mode `
:var MODE_EAX: :ref:`EAX Mode `
N)_create_cipher)byte_stringbchrbordbstr)load_pycryptodome_raw_libVoidPointerSmartPointerc_size_tzCrypto.Cipher._raw_des3a
int DES3_start_operation(const uint8_t key[],
size_t key_len,
void **pResult);
int DES3_encrypt(const void *state,
const uint8_t *in,
uint8_t *out,
size_t data_len);
int DES3_decrypt(const void *state,
const uint8_t *in,
uint8_t *out,
size_t data_len);
int DES3_stop_operation(void *state);
c d t | t vrt d d fd| D }|dd |dd k s|dd |d d k rt d
|S )am Set the parity bits in a TDES key.
:param key_in: the TDES key whose bits need to be adjusted
:type key_in: byte string
:returns: a copy of ``key_in``, with the parity bits correctly set
:rtype: byte string
:raises ValueError: if the TDES key is not 16 or 24 bytes long
:raises ValueError: if the TDES key degenerates into Single DES
c R d}t dd D ]
}|| |z dz z }| dz |z S )N )range)key_byteparityis t/builddir/build/BUILD/imunify360-venv-2.6.2/opt/imunify360/venv/lib64/python3.11/site-packages/Crypto/Cipher/DES3.pyparity_bytez&adjust_key_parity..parity_byteI sB q! * *Ax1}))FF46)) zNot a valid TDES keyr c Z g | ]'}t t | (S )r r ).0xr s r
z%adjust_key_parity..R s1 EEEkk$q''2233EEEr Nr iiz(Triple DES key degenerates to single DES)lenkey_size
ValueErrorjoin)key_inkey_outr s @r adjust_key_parityr$ <