HEX
Server: Apache/2.4.58 (Ubuntu)
System: Linux ip-172-31-18-78 6.17.0-1017-aws #17~24.04.1-Ubuntu SMP Tue May 26 21:09:53 UTC 2026 aarch64
User: ubuntu (1000)
PHP: 8.2.31
Disabled: NONE
Upload Files
File: //lib/python3/dist-packages/rsa/__pycache__/cli.cpython-312.pyc
�

<�a�'���dZddlZddlZddlZddlZddlZddlZddlZeejjj��Z
ejejejefZdd�ZGd�dej$��ZGd�de�ZGd	�d
e�ZGd�de�ZGd
�de�Ze�Ze�Ze�Ze�Zy)zWCommandline scripts.

These scripts are called by the executables defined in setup.py.
�Nc�,�tjdd��}|jddd��|jdd	dd
��|jddd
d��|jtj
dd�\}}t
|�dk7r|j�td��	t|d�}td|ztj��tj|�\}}|jrttd|jztj��|j!|j"��}t%|jd�5}|j'|�ddd�|j!|j"��}|j(rYtd|j(ztj��t%|j(d�5}|j'|�ddd�ytdtj��tj*j,j'|�y#t$rB}|j�td|dztj��td�|�d}~wwxYw#1swY��xYw#1swYyxYw)zKey generator.zusage: %prog [options] keysizez/Generates a new RSA key pair of "keysize" bits.��usage�descriptionz--pubout�stringz�Output filename for the public key. The public key is not saved if this option is not present. You can use pyrsa-priv2pub to create the public key file later.��type�help�-oz--outz`Output filename for the private key. The key is written to stdout if this option is not present.z--formz7key format of the private and public keys - default PEM��PEM�DERr
�r
�choices�default�NrzNot a valid number: %s��filezGenerating %i-bit keyzWriting public key to %s)�format�wbzWriting private key to %szWriting private key to stdout)�optparse�OptionParser�
add_option�
parse_args�sys�argv�len�
print_help�
SystemExit�int�
ValueError�print�stderr�rsa�newkeys�pubout�
save_pkcs1�form�open�write�out�stdout�buffer)	�parser�cli�cli_args�keysize�ex�pub_key�priv_key�data�outfiles	         �)/usr/lib/python3/dist-packages/rsa/cli.py�keygenr8!s>���
"�
"�.�E��F�
����
�>��������
�;�	������
F���	���'�'�������5�O�S�(�
�8�}���������m��$��h�q�k�"��
�
!�G�
+�#�*�*�=��+�+�g�.��W�h��z�z�
�(�3�:�:�5�C�J�J�G��!�!����!�2��
�#�*�*�d�
#�	 �w��M�M�$��	 ����c�h�h��/�D�
�w�w�
�)�C�G�G�3�#�*�*�E�
�#�'�'�4�
 �	 �G��M�M�$��	 �	 �	�-�C�J�J�?��
�
������%��1�$�����
�&��!��4�3�:�:�F���m��#��$��	 �	 ��	 �	 �s0�%H/�I=�J
�/	I:�8=I5�5I:�=J�
Jc	��eZdZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZ
ejZdd�Zej&dedej*j,dedej2fd��Zdd�Zdej8ej<ej>e ffd�Z!de de dej*j,fd�Z"de defd�Z#dede dd
fd�Z$y
)�CryptoOperationz9CLI callable that operates with input, output, and a key.�publicz'usage: %%prog [options] %(keyname)s_key��decrypt�	decrypted�
decryptingzEName of the file to %(operation)s. Reads from stdin if not specified.zjName of the file to write the %(operation_past)s file to. Written to stdout if this option is not present.rT�returnNc���|j|jjz|_|j|jjz|_|j|jjz|_y)N)r�	__class__�__dict__�
input_help�output_help)�selfs r7�__init__zCryptoOperation.__init__wsS���Z�Z�$�.�.�"9�"9�9��
��/�/�D�N�N�,C�,C�C����+�+�d�n�n�.E�.E�E����indata�keyr0c��y)z�Performs the program's operation.

        Implement in a subclass.

        :returns: the data to write to the output.
        N�)rFrIrJr0s    r7�perform_operationz!CryptoOperation.perform_operation|s�rHc�|�|j�\}}|j|d|j�}|j|j�}t|jj�tj��|j|||�}|jr|j||j�yy)zRuns the program.rrN)�	parse_cli�read_key�keyform�read_infile�inputr"�operation_progressive�titlerr#rM�
has_output�
write_outfile�output)rFr/r0rJrI�outdatas      r7�__call__zCryptoOperation.__call__�s����.�.�*���h��m�m�H�Q�K����5���!�!�#�)�)�,��
�d�(�(�.�.�0�s�z�z�B��(�(���h�?���?�?����w��
�
�3�rHc���tj|j|j��}|j	ddd|j
��|jr|j	ddd|j��|j	dd	|jzd
d��|jtjd
d�\}}t|�|jk7r|j�td
��||fS)zFParse the CLI options

        :returns: (cli_opts, cli_args)
        rz-iz--inputrrrz--outputz	--keyformz&Key format of the %s key - default PEMrr
rrN)rrrrrrDrVrE�keynamerrrr�expected_cli_argsrr)rFr.r/r0s    r7rOzCryptoOperation.parse_cli�s����&�&�T�Z�Z�T�EU�EU�V�����$�	��t����O��?�?����d�J�X�D�DT�DT��U�����9�D�L�L�H�"��		�	
�!�+�+�C�H�H�Q�R�L�9���h��x�=�D�2�2�2������Q�-���H�}�rH�filenamerQc���td|j�d|��tj��t	|d�5}|j�}ddd�|jj|�S#1swY�%xYw)zReads a public or private key.zReading z
 key from r�rbN)r"r\rr#r)�read�	key_class�
load_pkcs1)rFr^rQ�keyfile�keydatas     r7rPzCryptoOperation.read_key�s`��	�$�,�,��A��
�
�S�
�(�D�
!�	%�W��l�l�n�G�	%��~�~�(�(��'�:�:�	%�	%�s�A-�-A6�innamec�,�|rDtd|ztj��t|d�5}|j	�cddd�Stdtj��tj
jj	�S#1swY�LxYw)zRead the input filezReading input from %srr`NzReading input from stdin)r"rr#r)ra�stdinr-)rFrf�infiles   r7rRzCryptoOperation.read_infile�st����)�F�2����D��f�d�#�
%�v��{�{�}�
%�
%�	�(�s�z�z�:��y�y���$�$�&�&�	
%�
%�s�B
�
BrY�outnamec�2�|rEtd|ztj��t|d�5}|j	|�ddd�ytdtj��tj
jj	|�y#1swYyxYw)zWrite the output filezWriting output to %srrNzWriting output to stdout)r"rr#r)r*r,r-)rFrYrjr6s    r7rWzCryptoOperation.write_outfile�sv����(�7�2����D��g�t�$�
'���
�
�g�&�
'�
'�
�,�3�:�:�>��J�J���#�#�G�,�	
'�
'�s�B
�
B�r@N)%�__name__�
__module__�__qualname__�__doc__r\rr�	operation�operation_pastrTrDrEr]rVr$�	PublicKeyrbrG�abc�abstractmethod�bytesrJ�AbstractKey�	Indexable�typing�AnyrMrZ�Tupler�Values�List�strrOrPrRrWrLrHr7r:r:ds��C��G�5�E��K��I� �N�(��[�J�	?�����J��
�
�I�F�
	������"%�'�'�"5�"5��AJ��	������
4��6�<�<�������S�9I�(I�J��8;��;�s�;�s�w�w�7J�7J�;�	'�#�	'�%�	'�	-�U�	-�S�	-�T�	-rHr:)�	metaclassc	�h�eZdZdZdZdZdZdZdZ	d
de	de
jjd	e
d
e	fd�Zy)�EncryptOperationzEncrypts a file.r;zWEncrypts a file. The file must be shorter than the key length in order to be encrypted.�encrypt�	encrypted�
encryptingrIr3r0r@c�z�t|tjj�sJ�tj||�S)zEncrypts files.)�
isinstancer$rJrsr�)rFrIr3r0s    r7rMz"EncryptOperation.perform_operation�s/���'�3�7�7�#4�#4�5�5�5��{�{�6�7�+�+rHN�rL)rmrnrorpr\rrqrrrTrvr$rJrwrxrMrLrHr7r�r��sZ����G�d���I� �N�(��RT�,��,�&)�g�g�&9�&9�,�EN�,�	�,rHr�c	��eZdZdZdZdZdZdZdZe	jZ	d
dede	jjd	ed
efd�Zy)�DecryptOperationzDecrypts a file.�privatezgDecrypts a file. The original file must be shorter than the key length in order to have been encrypted.r=r>r?rIr4r0r@c�z�t|tjj�sJ�tj||�S)zDecrypts files.)r�r$rJ�
PrivateKeyr=)rFrIr4r0s    r7rMz"DecryptOperation.perform_operation�s/���(�C�G�G�$6�$6�7�7�7��{�{�6�8�,�,rHNr�)rmrnrorpr\rrqrrrTr$r�rbrvrJrwrxrMrLrHr7r�r��se����G�	:���I� �N�(�����I�SU�-��-�'*�w�w�':�':�-�FO�-�	�-rHr�c��eZdZdZdZdZddj
e�zZdZ	dZ
dZejZd	Zd
Zdedej$j&d
edefd�Zy)�
SignOperationz
Signs a file.r�z/usage: %%prog [options] private_key hash_methodzCSigns a file, outputs the signature. Choose the hash method from %s�, �sign�	signature�Signing�z\Name of the file to write the signature to. Written to stdout if this option is not present.rIr4r0r@c���t|tjj�sJ�|d}|tvr!tddj
t�z��tj|||�S)zSigns files.rz%Invalid hash method, choose one of %sr�)r�r$rJr��HASH_METHODSr�joinr�)rFrIr4r0�hash_methods     r7rMzSignOperation.perform_operations]���(�C�G�G�$6�$6�7�7�7��q�k���l�*��D�t�y�y�Q]�G^�^�_�_��x�x���+�6�6rHN)rmrnrorpr\rr�r�rrqrrrTr$r�rbr]rErvrJrwrxrMrLrHr7r�r��s�����G�=�E�	��9�9�\�2�	3���I� �N�%�����I���	3��

7��
7�'*�w�w�':�':�
7�FO�
7�	�
7rHr�c��eZdZdZdZdZdZdZdZdZ	e
jZdZ
d	Zd
ede
j j"ded
dfd�Zy)�VerifyOperationzVerify a signature.r;z1usage: %%prog [options] public_key signature_filezsVerifies a signature, exits with status 0 upon success, prints an error message and exits with status 1 upon error.�verify�verified�	Verifyingr�FrIr3r0r@Nc�p�t|tjj�sJ�|d}t	|d�5}|j�}ddd�	tj||�tdtj��y#1swY�=xYw#tj$r}td�|�d}~wwxYw)zVerifies files.rr`NzVerification failed.zVerification OKr)r�r$rJrsr)rar��VerificationErrorrr"rr#)rFrIr3r0�signature_file�sigfiler�r2s        r7rMz!VerifyOperation.perform_operation+s����'�3�7�7�#4�#4�5�5�5�!�!���
�.�$�
'�	'�7�����I�	'�	=��J�J�v�y�'�2�	��c�j�j�1�	'�	'��
�$�$�	=��3�4�"�<��	=�s#�B�B�B�B5�$B0�0B5)rmrnrorpr\rrrqrrrTr$rsrbr]rVrvrJrwrxrMrLrHr7r�r�so����G�?�E�	F���I��N�'���
�
�I����J�2��2�&)�g�g�&9�&9�2�EN�2�	
�2rHr�rl)rprtrryrr$�rsa.key�	rsa.pkcs1�sorted�pkcs1r��keys�Unionr{r}r~rxr8�ABCMetar:r�r�r�r�r�r=r�r�rLrHr7�<module>r�s����
�
�
��
����c�i�i�,�,�1�1�3�4���L�L����v�{�{�3�'7�7�8�	�@&�Fk-����k-�\,��,�&-��-�*7�O�7�B 2�o� 2�F�
��
�
�����	�	�rH