HEX
Server: LiteSpeed
System: Linux srv146.niagahoster.com 4.18.0-553.30.1.lve.el8.x86_64 #1 SMP Tue Dec 3 01:21:19 UTC 2024 x86_64
User: kodi1989 (1633)
PHP: 8.1.34
Disabled: symlink,shell_exec,exec,popen,system,dl,passthru,escapeshellarg,escapeshellcmd,show_source,pcntl_exec
Upload Files
File: //opt/alt/python37/lib/python3.7/site-packages/rsa/__pycache__/cli.cpython-37.pyc
B

��f�'�@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��yt	|d�}WnJt
k
r�}z,|��td|dtjd�td�|�Wdd}~XYnXtd|tjd�t
�|�\}}|j�r>td|jtjd�|j|jd�}t|jd��}|�|�WdQRX|j|jd�}|j�r�td|jtjd�t|jd��}|�|�WdQRXntdtj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�helpz-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�rsaZnewkeysZpuboutZ
save_pkcs1�form�open�write�out�stdout�buffer)	�parser�cli�cli_argsZkeysize�ex�pub_key�priv_key�data�outfile�r,�8/opt/alt/python37/lib/python3.7/site-packages/rsa/cli.py�keygen!sRr.c@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.rTN)rcCs4|j|jj|_|j|jj|_|j|jj|_dS)N)r�	__class__�__dict__�
input_help�output_help)�selfr,r,r-�__init__wszCryptoOperation.__init__)�indata�keyr&rcCsdS)z�Performs the program's operation.

        Implement in a subclass.

        :returns: the data to write to the output.
        Nr,)r9r;r<r&r,r,r-�perform_operation|s	z!CryptoOperation.perform_operationcCsd|��\}}|�|d|j�}|�|j�}t|j��tj	d�|�
|||�}|jr`|�||j
�dS)zRuns the program.r)r
N)�	parse_cli�read_key�keyform�read_infile�inputr�operation_progressive�titlerrr=�
has_output�
write_outfile�output)r9r%r&r<r;�outdatar,r,r-�__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)
        )rrz-iz--inputr)rrz-oz--outputz	--keyformz&Key format of the %s key - default PEM)rr	r)rr
rrN)rrrrrr7rEr8�keynamerrrr�expected_cli_argsrr)r9r$r%r&r,r,r-r>�szCryptoOperation.parse_cli)�filenamer@rc	CsDtd|j|ftjd�t|d��}|��}WdQRX|j�||�S)zReads a public or private key.zReading %s key from %s)r
�rbN)rrJrrr�read�	key_classZ
load_pkcs1)r9rLr@�keyfileZkeydatar,r,r-r?�szCryptoOperation.read_key)�innamerc	CsJ|r0td|tjd�t|d��
}|��SQRXtdtjd�tjj��S)zRead the input filezReading input from %s)r
rMNzReading input from stdin)rrrrrN�stdinr#)r9rQ�infiler,r,r-rA�szCryptoOperation.read_infile)rH�outnamerc	CsX|r8td|tjd�t|d��}|�|�WdQRXntdtjd�tjj�|�dS)zWrite the output filezWriting output to %s)r
rNzWriting output to stdout)rrrrr r"r#)r9rHrTr+r,r,r-rF�szCryptoOperation.write_outfile)%�__name__�
__module__�__qualname__�__doc__rJrr�	operation�operation_pastrCr7r8rKrEr�	PublicKeyrOr:�abc�abstractmethod�bytesr<�AbstractKey�	Indexable�typing�Anyr=rI�Tupler�Values�List�strr>r?rArFr,r,r,r-r/ds*
 	r/)�	metaclassc@s>eZdZdZdZdZdZdZdZde	e
jje
e	d�d	d
�ZdS)
�EncryptOperationzEncrypts a file.r0zWEncrypts a file. The file must be shorter than the key length in order to be encrypted.�encryptZ	encryptedZ
encryptingr,)r;r(r&rcCst|tjj�st�t�||�S)zEncrypts files.)�
isinstancerr<r[�AssertionErrorri)r9r;r(r&r,r,r-r=�sz"EncryptOperation.perform_operationN)r,)rUrVrWrXrJrrYrZrCr^rr<r_r`r=r,r,r,r-rh�srhc@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.r2r3r4r,)r;r)r&rcCst|tjj�st�t�||�S)zDecrypts files.)rjrr<�
PrivateKeyrkr2)r9r;r)r&r,r,r-r=�sz"DecryptOperation.perform_operationN)r,)rUrVrWrXrJrrYrZrCrrnrOr^r<r_r`r=r,r,r,r-rl�srlc@sXeZdZdZdZdZdd�e�ZdZ	dZ
dZej
Zd	Zd
Zeejjeed�dd
�ZdS)�
SignOperationz
Signs a file.rmz/usage: %%prog [options] private_key hash_methodzCSigns a file, outputs the signature. Choose the hash method from %sz, �sign�	signatureZSigning�z\Name of the file to write the signature to. Written to stdout if this option is not present.)r;r)r&rcCsBt|tjj�st�|d}|tkr4tdd�t���t�|||�S)zSigns files.rz%Invalid hash method, choose one of %sz, )	rjrr<rnrk�HASH_METHODSr�joinrp)r9r;r)r&Zhash_methodr,r,r-r=s
zSignOperation.perform_operationN)rUrVrWrXrJrrtrsrrYrZrCrrnrOrKr8r^r<r_r`r=r,r,r,r-ro�s
roc@sNeZdZdZdZdZdZdZdZdZ	e
jZdZ
d	Zee
jjed
d�dd
�Zd
S)�VerifyOperationzVerify a signature.r0z1usage: %%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	VerifyingrrFN)r;r(r&rc
Cs�t|tjj�st�|d}t|d��}|��}WdQRXyt�|||�Wn.tjk
rx}zt	d�|�Wdd}~XYnXt
dtjd�dS)zVerifies files.rrMNzVerification failed.zVerification OK)r
)
rjrr<r[rkrrNrvZVerificationErrorrrrr)r9r;r(r&Zsignature_fileZsigfilerqr'r,r,r-r=+sz!VerifyOperation.perform_operation)rUrVrWrXrJrrrYrZrCrr[rOrKrEr^r<r_r`r=r,r,r,r-rus
ru)rXr\rrarrZrsa.keyZ	rsa.pkcs1�sortedZpkcs1rs�keys�Unionrcrerfr`r.�ABCMetar/rhrlrorurir2rprvr,r,r,r-�<module>s&Cn!#