HEX
Server: LiteSpeed
System: Linux server.nevid-deploma.com 4.18.0-553.111.1.lve.el8.x86_64 #1 SMP Fri Mar 13 13:42:17 UTC 2026 x86_64
User: smilepac (1037)
PHP: 8.1.34
Disabled: NONE
Upload Files
File: //opt/cppython/lib/python3.8/site-packages/rsa/__pycache__/cli.cpython-38.pyc
U

JD�g�'�@s�dZddlZddlZddlZddlZddlZddlZddlZeej	j
���Z
ejej
ejefZdd�dd�ZGdd�dejd�ZGd	d
�d
e�ZGdd�de�ZGd
d�de�ZGdd�de�Ze�Ze�Ze�Ze�ZdS)zWCommandline scripts.

These scripts are called by the executables defined in setup.py.
�N��returnc	
Cs�tjddd�}|jdddd�|jdd	dd
d�|jddd
dd�|�tjdd��\}}t|�dkrv|��td��zt	|d�}WnJt
k
r�}z,|��td|dtjd�td�|�W5d}~XYnXtd|tjd�t
�|�\}}|j�r>td|jtjd�|j|jd�}t|jd��}|�|�W5QRX|j|jd�}|j�r�td|jtjd�t|jd��}|�|�W5QRXntdtjd�tjj�|�dS)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��PEMZDERr
�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�rsaZnewkeysZpuboutZ
save_pkcs1�form�open�write�out�stdout�buffer)	�parser�cli�cli_argsZkeysize�ex�pub_key�priv_key�data�outfile�r2�4/opt/cppython/lib/python3.8/site-packages/rsa/cli.py�keygen!sZ����r4c@s�eZdZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZ
ejZdd
�dd�Zejeejjeejd�dd��Zdd
�dd�Zejejeje fd
�dd�Z!e e ejjd�dd�Z"e ed�dd�Z#ee dd�dd�Z$dS) �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.rTNrcCs4|j|jj|_|j|jj|_|j|jj|_dS)N)r�	__class__�__dict__�
input_help�output_help)�selfr2r2r3�__init__wszCryptoOperation.__init__)�indata�keyr,rcCsdS)z�Performs the program's operation.

        Implement in a subclass.

        :returns: the data to write to the output.
        Nr2)r?rArBr,r2r2r3�perform_operation|sz!CryptoOperation.perform_operationcCsd|��\}}|�|d|j�}|�|j�}t|j��tj	d�|�
|||�}|jr`|�||j
�dS)zRuns the program.rrN)�	parse_cli�read_key�keyform�read_infile�inputr!�operation_progressive�titlerr"rC�
has_output�
write_outfile�output)r?r+r,rBrA�outdatar2r2r3�__call__�szCryptoOperation.__call__cCs�tj|j|jd�}|jddd|jd�|jr@|jddd|jd�|jdd	|jd
dd�|�	t
jd
d��\}}t|�|j
kr�|��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)rrrrrr=rKr>�keynamerrrr�expected_cli_argsrr)r?r*r+r,r2r2r3rD�s�zCryptoOperation.parse_cli)�filenamerFrc	CsDtd|j|ftjd�t|d��}|��}W5QRX|j�||�S)zReads a public or private key.zReading %s key from %sr�rb)r!rPrr"r%�read�	key_classZ
load_pkcs1)r?rRrF�keyfileZkeydatar2r2r3rE�szCryptoOperation.read_key)�innamerc
CsV|r<td|tjd�t|d��}|��W5QR�SQRXtdtjd�tjj��S)zRead the input filezReading input from %srrSzReading input from stdin)r!rr"r%rT�stdinr))r?rW�infiler2r2r3rG�szCryptoOperation.read_infile)rN�outnamerc	CsX|r8td|tjd�t|d��}|�|�W5QRXntdtjd�tjj�|�dS)zWrite the output filezWriting output to %srrzWriting output to stdoutN)r!rr"r%r&r(r))r?rNrZr1r2r2r3rL�szCryptoOperation.write_outfile)%�__name__�
__module__�__qualname__�__doc__rPrr�	operation�operation_pastrIr=r>rQrKr#�	PublicKeyrUr@�abc�abstractmethod�bytesrB�AbstractKey�	Indexable�typing�AnyrCrO�Tupler�Values�List�strrDrErGrLr2r2r2r3r5ds2��
 	r5)�	metaclassc@s>eZdZdZdZdZdZdZdZde	e
jje
e	d�d	d
�ZdS)
�EncryptOperationzEncrypts a file.r6zWEncrypts a file. The file must be shorter than the key length in order to be encrypted.�encryptZ	encryptedZ
encryptingr2�rAr.r,rcCst|tjj�st�t�||�S)zEncrypts files.)�
isinstancer#rBra�AssertionErrorro)r?rAr.r,r2r2r3rC�sz"EncryptOperation.perform_operationN)r2)r[r\r]r^rPrr_r`rIrdr#rBrerfrCr2r2r2r3rn�s���rnc@sDeZdZdZdZdZdZdZdZe	j
Zdee	j
jeed�d	d
�ZdS)
�DecryptOperationzDecrypts a file.�privatezgDecrypts a file. The original file must be shorter than the key length in order to have been encrypted.r8r9r:r2�rAr/r,rcCst|tjj�st�t�||�S)zDecrypts files.)rqr#rB�
PrivateKeyrrr8)r?rAr/r,r2r2r3rC�sz"DecryptOperation.perform_operationN)r2)r[r\r]r^rPrr_r`rIr#rvrUrdrBrerfrCr2r2r2r3rs�s���rsc@sXeZdZdZdZdZdd�e�ZdZ	dZ
dZej
Zd	Zd
Zeejjeed�dd
�ZdS)�
SignOperationz
Signs a file.rtz/usage: %%prog [options] private_key hash_methodzCSigns a file, outputs the signature. Choose the hash method from %s�, �sign�	signatureZSigning�z\Name of the file to write the signature to. Written to stdout if this option is not present.rucCsBt|tjj�st�|d}|tkr4tdd�t���t�|||�S)zSigns files.rz%Invalid hash method, choose one of %srx)	rqr#rBrvrr�HASH_METHODSr�joinry)r?rAr/r,Zhash_methodr2r2r3rCs
zSignOperation.perform_operationN)r[r\r]r^rPrr}r|rr_r`rIr#rvrUrQr>rdrBrerfrCr2r2r2r3rw�s&����rwc@sNeZdZdZdZdZdZdZdZdZ	e
jZdZ
d	Zee
jjed
d�dd
�Zd
S)�VerifyOperationzVerify a signature.r6z1usage: %%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.�verifyZverifiedZ	Verifyingr{FNrpc
Cs�t|tjj�st�|d}t|d��}|��}W5QRXzt�|||�Wn.tjk
rx}zt	d�|�W5d}~XYnXt
dtjd�dS)zVerifies files.rrSzVerification failed.NzVerification OKr)
rqr#rBrarrr%rTrZVerificationErrorrr!rr")r?rAr.r,Zsignature_fileZsigfilerzr-r2r2r3rC+sz!VerifyOperation.perform_operation)r[r\r]r^rPrrr_r`rIr#rarUrQrKrdrBrerfrCr2r2r2r3r~s ��r~)r^rbrrgrr#Zrsa.keyZ	rsa.pkcs1�sortedZpkcs1r|�keys�Unionrirkrlrfr4�ABCMetar5rnrsrwr~ror8ryrr2r2r2r3�<module>s&Cn!#