/
var
/
opt
/
nydus
/
ops
/
oscrypto
/
_win
/
__pycache__
/
up file
home
� ;�j�x � �R � d dl mZmZmZmZ ddlmZ ddlmZm Z m Z mZmZm Z mZmZmZmZ ddlmZ ddlmZ ddlmZmZ e� Zed k( rdd lmZmZmZmZmZ nddl m!Z!m"Z"mZm#Z#m$Z$ g d�Z%d � Z&d� Z'd� Z(d� Z)d� Z*d� Z+d� Z,d� Z-d� Z.d� Z/d� Z0d� Z1d� Z2d� Z3d� Z4d� Z5d� Z6d� Z7d� Z8d � Z9y!)"� )�unicode_literals�division�absolute_import�print_function� )�pretty_message) �buffer_from_bytes�bytes_from_buffer�deref�new�null�pointer_set�struct�struct_bytes�unwrap�write_to_buffer� )� rand_bytes)�backend)� type_name�byte_cls� winlegacy)�advapi32� Advapi32Const�handle_error�open_context_handle�close_context_handle)�bcrypt�BcryptConstr �open_alg_handle�close_alg_handle)�aes_cbc_no_padding_decrypt�aes_cbc_no_padding_encrypt�aes_cbc_pkcs7_decrypt�aes_cbc_pkcs7_encrypt�des_cbc_pkcs5_decrypt�des_cbc_pkcs5_encrypt�rc2_cbc_pkcs5_decrypt�rc2_cbc_pkcs5_encrypt�rc4_decrypt�rc4_encrypt�tripledes_cbc_pkcs5_decrypt�tripledes_cbc_pkcs5_encryptc �L � t | � dvrt t dt | � � � �|st d� }n,t |� dk7 rt t dt |� � � �t |� dz dk7 rt t dt |� � � �|t d| ||d� fS ) a� Encrypts plaintext using AES in CBC mode with a 128, 192 or 256 bit key and no padding. This means the ciphertext must be an exact multiple of 16 bytes long. :param key: The encryption key - a byte string either 16, 24 or 32 bytes long :param data: The plaintext - a byte string :param iv: The initialization vector - either a byte string 16-bytes long or None to generate an IV :raises: ValueError - when any of the parameters contain an invalid value TypeError - when any of the parameters are of the wrong type OSError - when an error is returned by the OS crypto library :return: A tuple of two byte strings (iv, ciphertext) �� � � �o key must be either 16, 24 or 32 bytes (128, 192 or 256 bits) long - is %s r0 �: iv must be 16 bytes long - is %s r zJ data must be a multiple of 16 bytes long - is %s �aesF��len� ValueErrorr r �_encrypt��key�data�ivs �H/opt/nydus/tmp/pip-target-hb7welcc/lib/python/oscrypto/_win/symmetric.pyr# r# - s� � �2 �3�x�|�#��� � ��H� � � � � ��^�� �R��B���� � ��G� � � � �4�y�2�~����� � ��I� � � � ����T�2�u�5�6�6� c �� � t | � dvrt t dt | � � � �t |� dk7 rt t dt |� � � �t d| ||d� S )a[ Decrypts AES ciphertext in CBC mode using a 128, 192 or 256 bit key and no padding. :param key: The encryption key - a byte string either 16, 24 or 32 bytes long :param data: The ciphertext - a byte string :param iv: The initialization vector - a byte string 16-bytes long :raises: ValueError - when any of the parameters contain an invalid value TypeError - when any of the parameters are of the wrong type OSError - when an error is returned by the OS crypto library :return: A byte string of the plaintext r/ r3 r0 r4 r5 F�r7 r8 r �_decryptr: s r>