| Server IP : 217.160.0.135 / Your IP : 216.73.217.85 Web Server : Apache System : Linux www 6.18.52-i1-ampere #1203 SMP Mon Sep 14 18:29:59 CEST 2026 aarch64 User : sws1074145052 ( 1074145052) PHP Version : 8.3.32 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /usr/lib/python3/dist-packages/Cryptodome/Cipher/__pycache__/ |
Upload File : |
�
8�tc� � �J � d Z dgZddlmZ ddlmZ G d� de� � Zd� ZdS )z
OpenPGP mode.
�OpenPgpMode� )�_copy_bytes)�get_random_bytesc �$ � e Zd ZdZd� Zd� Zd� ZdS )r az OpenPGP mode.
This mode is a variant of CFB, and it is only used in PGP and
OpenPGP_ applications. If in doubt, use another mode.
An Initialization Vector (*IV*) is required.
Unlike CFB, the *encrypted* IV (not the IV itself) is
transmitted to the receiver.
The IV is a random data block. For legacy reasons, two of its bytes are
duplicated to act as a checksum for the correctness of the key, which is now
known to be insecure and is ignored. The encrypted IV is therefore 2 bytes
longer than the clean IV.
.. _OpenPGP: http://tools.ietf.org/html/rfc4880
:undocumented: __init__
c �d � |j | _ d| _ |j ||j fd| j z | j dz d�|��}t d d |� � }t |� � | j k r&|� ||dd � z � � | _ nat |� � | j dz k r%|| _ |� |� � d d� }n!t d| j | j dz fz � � �|x| _
| _ |j ||j f| j | j d � | j dz d�|��| _ d S )NF� � )�IV�segment_size���� z4Length of IV must be %d or %d bytes for MODE_OPENPGP)
�
block_size�_done_first_block�new�MODE_CFBr �len�encrypt�
_encrypted_IV�decrypt�
ValueError�ivr
�_cipher)�self�factory�keyr �
cipher_params� IV_ciphers �A/usr/lib/python3/dist-packages/Cryptodome/Cipher/_mode_openpgp.py�__init__zOpenPgpMode.__init__= s� � � "�,���!&��� �G�K���(�)� #�T�_�4�%)�_�q�%8� )� )�
(�)� )� � ��t�R�
(�
(�� �r�7�7�d�o�%�%�!*�!2�!2�2��2�3�3��<�!@�!@�D���
��W�W���!�+�
+�
+�!#�D�� �"�"�2�&�&�s��s�+�B�B�� 1� $����1�1D�E�F� G� G�
G� ����$�'� #�w�{��#�,�-� $�1�4�?�2B�2C�2C�D�)-��1�)<� -� -�
,�-� -����� c �j � | j � |� � }| j s| j |z }d| _ |S )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.
:Return:
the encrypted data, as a byte string.
It is as long as *plaintext* with one exception:
when encrypting the first message chunk,
the encypted IV is prepended to the returned ciphertext.
T)r r r r )r � plaintext�ress r r zOpenPgpMode.encryptg s>