%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python2.7/site-packages/salt/utils/
Upload File :
Create Path :
Current File : //lib/python2.7/site-packages/salt/utils/rsax931.pyo

�
���^c@@s�dZddlmZmZmZddlZddlZddlZddlZ	ddl
Z	ddlmZm
Z
mZmZmZmZddlmZdZdZdZd	�Zd
�Ze�ZdZdefd
��YZdefd��YZdS(uE
Create and verify ANSI X9.31 RSA signatures using OpenSSL libcrypto
i(tabsolute_importtprint_functiontunicode_literalsN(tcdlltc_char_ptc_inttc_void_ptpointertcreate_string_buffer(tfind_libraryiii�cC@s�tjjd�r%tjtd��Sttdt�r�tj	jj
�r�tjtjtj
jtj
jtj�d��d�Std�}|r�tj	jj�r�tjd�tjd�}t|�dkr�|dnd
}n|rztj	jj�rztj
jd	�rFtjd
�}t|�dkr=|dnd
}qztjd�}t|�dkrq|dnd
}n|r�tj|�Std��d
S(u 
    Load OpenSSL libcrypto
    uwinulibeay32ufrozenu
libcrypto.so*iucryptou/opt/local/lib/libcrypto.so*u/opt/tools/lib/libcrypto.so*u
/opt/salt/libu/opt/salt/lib/libcrypto.so*u/opt/freeware/lib/libcrypto.so*uCannot locate OpenSSL libcryptoN(tsystplatformt
startswithRtLoadLibrarytstrtgetattrtFalsetsalttutilst
is_smartostglobtostpathtjointdirnamet
executableR	tis_sunostlentNonetis_aixtisdirtOSError(tlib((s6/usr/lib/python2.7/site-packages/salt/utils/rsax931.pyt_load_libcryptos&$%%%
cC@sQt�}y>|j}t|�r-|�}n|dkrF|j�nWn%tk
rn|j�|j�nXd|j_t	|j_
t	f|j_t	|j_
ttf|j_t	|j_
t	f|j_t	t	t	t	f|j_t	|j_
t	t	t	t	f|j_t	|j_
tttt	tf|j_tttt	tf|j_|S(u>
    Set up libcrypto argtypes and initialize the library
    i((R!tOpenSSL_version_numtcallabletOPENSSL_init_cryptotAttributeErrortOPENSSL_no_configt!OPENSSL_add_all_algorithms_noconftRSA_newtargtypesRtrestypetRSA_freetRSA_sizetargtypeRRtBIO_new_mem_buftBIO_freetPEM_read_bio_RSAPrivateKeytPEM_read_bio_RSA_PUBKEYtRSA_private_encrypttRSA_public_decrypt(t	libcryptotopenssl_version_num((s6/usr/lib/python2.7/site-packages/salt/utils/rsax931.pyt_init_libcrypto=s0		

it
RSAX931SignercB@s)eZdZd�Zd�Zd�ZRS(uB
    Create ANSI X9.31 RSA signatures using OpenSSL libcrypto
    cC@stjjj|d�}tj|t|��|_ttj	��|_
tj|jt|j
�dd�s{td��ndS(uo
        Init an RSAX931Signer instance

        :param str keydata: The RSA private key in PEM format
        uasciiuinvalid RSA private keyN(RRtstringutilstto_bytesR4R.Rt_bioRR(t_rsaR0RRt
ValueError(tselftkeydata((s6/usr/lib/python2.7/site-packages/salt/utils/rsax931.pyt__init__js
$cC@s$tj|j�tj|j�dS(N(R4R/R:R+R;(R=((s6/usr/lib/python2.7/site-packages/salt/utils/rsax931.pyt__del__vscC@swttj|j��}tjjj|�}tjt	|�|||jt
�}|dkrltd��n|d|!S(u�
        Sign a message (digest) using the private key

        :param str msg: The message (digest) to sign
        :rtype: str
        :return: The signature, or an empty string if the encryption failed
        iuUnable to encrypt message(RR4R,R;RRR8R9R2RtRSA_X931_PADDINGR<(R=tmsgtbuftsize((s6/usr/lib/python2.7/site-packages/salt/utils/rsax931.pytsignzs	$(t__name__t
__module__t__doc__R?R@RE(((s6/usr/lib/python2.7/site-packages/salt/utils/rsax931.pyR7fs		tRSAX931VerifiercB@s)eZdZd�Zd�Zd�ZRS(uB
    Verify ANSI X9.31 RSA signatures using OpenSSL libcrypto
    cC@s�tjjj|d�}|jdd�}tj|t|��|_t	tj
��|_tj|jt
|j�dd�s�td��ndS(up
        Init an RSAX931Verifier instance

        :param str pubdata: The RSA public key in PEM format
        uasciisRSA tuinvalid RSA public keyN(RRR8R9treplaceR4R.RR:RR(R;R1RRR<(R=tpubdata((s6/usr/lib/python2.7/site-packages/salt/utils/rsax931.pyR?�s$cC@s$tj|j�tj|j�dS(N(R4R/R:R+R;(R=((s6/usr/lib/python2.7/site-packages/salt/utils/rsax931.pyR@�scC@swttj|j��}tjjj|�}tjt	|�|||jt
�}|dkrltd��n|d|!S(u-
        Recover the message (digest) from the signature using the public key

        :param str signed: The signature created with the private key
        :rtype: str
        :return: The message (digest) recovered from the signature, or an empty
            string if the decryption failed
        iuUnable to decrypt message(RR4R,R;RRR8R9R3RRAR<(R=tsignedRCRD((s6/usr/lib/python2.7/site-packages/salt/utils/rsax931.pytverify�s
$(RFRGRHR?R@RN(((s6/usr/lib/python2.7/site-packages/salt/utils/rsax931.pyRI�s	
	(RHt
__future__RRRRR
Rtsalt.utils.platformRtsalt.utils.stringutilstctypesRRRRRRtctypes.utilR	tOPENSSL_INIT_ADD_ALL_CIPHERStOPENSSL_INIT_ADD_ALL_DIGESTStOPENSSL_INIT_NO_LOAD_CONFIGR!R6R4RAtobjectR7RI(((s6/usr/lib/python2.7/site-packages/salt/utils/rsax931.pyt<module>s".	#	#	%

Zerion Mini Shell 1.0