ok

Mini Shell

Direktori : /proc/self/root/lib64/python2.7/site-packages/M2Crypto/SSL/
Upload File :
Current File : //proc/self/root/lib64/python2.7/site-packages/M2Crypto/SSL/TwistedProtocolWrapper.pyo

�

�1Mc@s\dZdddddgZddljjZddlZddlmZdd	lm	Z	dd
l
mZddlZddlm
Z
mZddlmZd
�Zddejjej�d�Zddejjej�d�Zddejjed�Zddejjdd�Zddd��YZddd��YZdefd��YZdS(sv
Make Twisted use M2Crypto for SSL

Copyright (c) 2004-2007 Open Source Applications Foundation.
All rights reserved.
t
connectSSLt
connectTCPt	listenSSLt	listenTCPtTLSProtocolWrapperi����N(tProtocolWrapper(t
ITLSTransport(t
implements(tm2tX509(tCheckercCsdS(Ni((tpeerX509texpectedHost((sI/usr/lib64/python2.7/site-packages/M2Crypto/SSL/TwistedProtocolWrapper.pyt"_alwaysSucceedsPostConnectionChecksic	s=tj|�}��fd�|_|j|||||�S(s~
    A convenience function to start an SSL/TLS connection using Twisted.
    
    See IReactorSSL interface in Twisted. 
    cs%t||ddddd�d��S(NtstartPassThroughitclientitcontextFactorytpostConnectionCheck(R(tfactorytwrappedProtocol(RR(sI/usr/lib64/python2.7/site-packages/M2Crypto/SSL/TwistedProtocolWrapper.pyt<lambda>$s(tpoliciestWrappingFactorytprotocolR(	thosttportRRttimeouttbindAddresstreactorRtwrappingFactory((RRsI/usr/lib64/python2.7/site-packages/M2Crypto/SSL/TwistedProtocolWrapper.pyRs	cs:tj|�}�fd�|_|j|||||�S(s�
    A convenience function to start a TCP connection using Twisted. 

    NOTE: You must call startTLS(ctx) to go into SSL/TLS mode.

    See IReactorTCP interface in Twisted. 
    cs%t||ddddddd��S(NRiRRR(RtNone(RR(R(sI/usr/lib64/python2.7/site-packages/M2Crypto/SSL/TwistedProtocolWrapper.pyR9s(RRRR(RRRRRRRR((RsI/usr/lib64/python2.7/site-packages/M2Crypto/SSL/TwistedProtocolWrapper.pyR.s
itcs:tj|�}��fd�|_|j||||�S(s~
    A convenience function to listen for SSL/TLS connections using Twisted. 

    See IReactorSSL interface in Twisted. 
    cs%t||ddddd�d��S(NRiRRR(R(RR(RR(sI/usr/lib64/python2.7/site-packages/M2Crypto/SSL/TwistedProtocolWrapper.pyRLs(RRRR(RRRtbacklogt	interfaceRRR((RRsI/usr/lib64/python2.7/site-packages/M2Crypto/SSL/TwistedProtocolWrapper.pyRCscs7tj|�}�fd�|_|j||||�S(s�
    A convenience function to listen for TCP connections using Twisted. 
    
    NOTE: You must call startTLS(ctx) to go into SSL/TLS mode.

    See IReactorTCP interface in Twisted. 
    cs%t||ddddddd��S(NRiRiRR(RR(RR(R(sI/usr/lib64/python2.7/site-packages/M2Crypto/SSL/TwistedProtocolWrapper.pyRas(RRRR(RRR R!RRR((RsI/usr/lib64/python2.7/site-packages/M2Crypto/SSL/TwistedProtocolWrapper.pyRVs
t	_BioProxycBs2eZdZejZd�Zd�Zd�ZRS(s�
    The purpose of this class is to eliminate the __del__ method from
    TLSProtocolWrapper, and thus letting it be garbage collected.
    cCs
||_dS(N(tbio(tselfR#((sI/usr/lib64/python2.7/site-packages/M2Crypto/SSL/TwistedProtocolWrapper.pyt__init__sscCs|jS(N(R#(R$((sI/usr/lib64/python2.7/site-packages/M2Crypto/SSL/TwistedProtocolWrapper.pyt_ptrvscCs&|jdk	r"|j|j�ndS(N(R#Rtm2_bio_free_all(R$((sI/usr/lib64/python2.7/site-packages/M2Crypto/SSL/TwistedProtocolWrapper.pyt__del__ys(	t__name__t
__module__t__doc__Rtbio_free_allR'R%R&R((((sI/usr/lib64/python2.7/site-packages/M2Crypto/SSL/TwistedProtocolWrapper.pyR"ks
			t	_SSLProxycBs2eZdZejZd�Zd�Zd�ZRS(s�
    The purpose of this class is to eliminate the __del__ method from
    TLSProtocolWrapper, and thus letting it be garbage collected.
    cCs
||_dS(N(tssl(R$R.((sI/usr/lib64/python2.7/site-packages/M2Crypto/SSL/TwistedProtocolWrapper.pyR%�scCs|jS(N(R.(R$((sI/usr/lib64/python2.7/site-packages/M2Crypto/SSL/TwistedProtocolWrapper.pyR&�scCs&|jdk	r"|j|j�ndS(N(R.Rtm2_ssl_free(R$((sI/usr/lib64/python2.7/site-packages/M2Crypto/SSL/TwistedProtocolWrapper.pyR(�s(	R)R*R+Rtssl_freeR/R%R&R((((sI/usr/lib64/python2.7/site-packages/M2Crypto/SSL/TwistedProtocolWrapper.pyR-~s
			cBs�eZdZee�d�Zd�Zd�Zd�Zd�Z	d�Z
d�Zd�Zd	�Z
d
�Zd�Zdd
d�Zdd�ZRS(s�
    A SSL/TLS protocol wrapper to be used with Twisted. Typically
    you would not use this class directly. Use connectTCP, 
    connectSSL, listenTCP, listenSSL functions defined above,
    which will hook in this class.
    cCs�||_||_d|_d|_d|_d|_||_d|_|dkr`t	|_
n	||_
|s�|j|j��ndS(s�
        @param factory:
        @param wrappedProtocol:
        @param startPassThrough:    If true we won't encrypt at all. Need to
                                    call startTLS() later to switch to SSL/TLS.
        @param client:              True if this should be a client protocol.
        @param contextFactory:      Factory that creates SSL.Context objects.
                                    The called function is getContext().
        @param postConnectionCheck: The post connection check callback that
                                    will be called just after connection has
                                    been established but before any real data
                                    has been exchanged. The first argument to
                                    this function is an X509 object, the second
                                    is the expected host name string.
        RiN(
RRtdatat	encryptedt
tlsStartedtcheckedtisClientt	helloDoneRR
RtstartTLSt
getContext(R$RRRRRR((sI/usr/lib64/python2.7/site-packages/M2Crypto/SSL/TwistedProtocolWrapper.pyR%�s									cCsst|dd�r9d|_d|_d|_d|_nd|_d|_d|_d|_	d|_
d|_dS(sI
        Clear this instance, after which it is ready for reuse.
        R3iRiN(tgetattrRtsslBioR.tinternalBiot
networkBioR1R2R3R4R5R6(R$((sI/usr/lib64/python2.7/site-packages/M2Crypto/SSL/TwistedProtocolWrapper.pytclear�s								cCs�|jrtd�n||_tjtj��|_tj|jd�ttjtj���|_	tj|j	j
�d�tj|j|j	j
��ttjtj���|_
ttj|jj��|_|jr�tj|jj
��ntj|jj
��tj|jj
�|j|j�tj|j
j
�|jj
�tj�tj|jj
��}tj|jj
�|tjBtjB�d|_dS(sq
        Start SSL/TLS. If this is not called, this instance just passes data
        through untouched.
        sTLS already startediiN(R3t	ExceptiontctxRtbio_newt	bio_s_bioR;tbio_set_write_buf_sizeR"R<R&tbio_make_bio_pairt	bio_f_sslR:R-tssl_newR.R5tssl_set_connect_statetssl_set_accept_statetssl_set_biotbio_set_ssltbio_noclosetssl_get_modetssl_set_modetSSL_MODE_ENABLE_PARTIAL_WRITEt#SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER(R$R?tmode((sI/usr/lib64/python2.7/site-packages/M2Crypto/SSL/TwistedProtocolWrapper.pyR7�s(			"(
cCs�|jstj||�dSy,|j|�}tj||�d|_WnGtjjk
r�}tj	|j
j��|jdf|_|�nXdS(Nii(
R3Rtwritet_encryptR6tM2CryptotBIOtBIOErrorRtssl_get_verify_resultR.R&targs(R$R1t
encryptedDatate((sI/usr/lib64/python2.7/site-packages/M2Crypto/SSL/TwistedProtocolWrapper.pyRPs	
(cCs@|js&tj|dj|��dS|jdj|��dS(NR(R3Rt
writeSequencetjoinRP(R$R1((sI/usr/lib64/python2.7/site-packages/M2Crypto/SSL/TwistedProtocolWrapper.pyRYs	cCstj|�dS(N(RtloseConnection(R$((sI/usr/lib64/python2.7/site-packages/M2Crypto/SSL/TwistedProtocolWrapper.pyR[scCs:tj|�|jr6|jr6|jr6|j�ndS(N(RtconnectionMadeR3R5R6t_clientHello(R$((sI/usr/lib64/python2.7/site-packages/M2Crypto/SSL/TwistedProtocolWrapper.pyR\s
cCs�|jstj||�dS|j|7_yhxa|j�}|j�|j�}tj||�tj||�|dkr2|dkr2Pq2q2WnGtj	j
k
r�}tj|j
j��|jdf|_|�nXdS(NRi(R3RtdataReceivedR2t_decryptt_checkRQRPRRRSRTRRUR.R&RV(R$R1t
decryptedDataRWRX((sI/usr/lib64/python2.7/site-packages/M2Crypto/SSL/TwistedProtocolWrapper.pyR^ s 	
(cCs|j�tj||�dS(N(R=RtconnectionLost(R$treason((sI/usr/lib64/python2.7/site-packages/M2Crypto/SSL/TwistedProtocolWrapper.pyRb:s
cCs�|jr�tj|jj��r�tj|jj��}|dk	r[tj|d�}n|jrw|j	j
d}n|j	j�j}|j
||�s�tjd�nd|_ndS(Niispost connection check(R4Rtssl_is_init_finishedR.R&tssl_get_peer_certRR	R5t	transporttaddrtgetPeerRRR
tSSLVerificationError(R$tx509R((sI/usr/lib64/python2.7/site-packages/M2Crypto/SSL/TwistedProtocolWrapper.pyR`>s"	cCs}y/|jdd�}tj||�d|_WnGtjjk
rx}tj|j	j
��|jdf|_|�nXdS(NtclientHelloii(RQRRPR6RRRSRTRRUR.R&RV(R$RWRX((sI/usr/lib64/python2.7/site-packages/M2Crypto/SSL/TwistedProtocolWrapper.pyR]Ks
(RicCs	d}|j|7_|jj�}|jj�}tj}tj}tj}tj}	tj	}
x�||�}|dkr�|jdks�|r�|||j�}|dkr�q�|j||_n|	|�}
|
r|
||
�}|dk	r||7}qqcPqc|S(NRi(R1R:R&R<Rtbio_ctrl_get_write_guaranteet	bio_writetbio_should_retrytbio_ctrl_pendingtbio_readR(R$R1RkRWt	sslBioPtrR<tm2bio_ctrl_get_write_guaranteetm2bio_writetm2bio_should_retrytm2bio_ctrl_pendingt
m2bio_readtgtrtpendingtd((sI/usr/lib64/python2.7/site-packages/M2Crypto/SSL/TwistedProtocolWrapper.pyRQXs0					!
cCs|j|7_d}|jj�}|jj�}tj}tj}tj}tj}tj	}	x�||�}
|
dkr�|jdkr�|||j�}|dkr�q�|j||_n||�}|r�|	||�}
|
dk	r�||
7}q�qcPqc|S(NRi(R2R:R&R<RRlRmRnRoRpR(R$R1RaRqR<RrRsRtRuRvRwRxRyRz((sI/usr/lib64/python2.7/site-packages/M2Crypto/SSL/TwistedProtocolWrapper.pyR_zs0					
(R)R*R+RRR%R=R7RPRYR[R\R^RbR`R]RQR_(((sI/usr/lib64/python2.7/site-packages/M2Crypto/SSL/TwistedProtocolWrapper.pyR�s
	,		(							
	
"(((R+t__all__ttwisted.protocols.policiest	protocolsRttwisted.internet.reactorttwistedRttwisted.internet.interfacesRtzope.interfaceRRRRR	tM2Crypto.SSLR
R
RtinternetRRRRRR"R-R(((sI/usr/lib64/python2.7/site-packages/M2Crypto/SSL/TwistedProtocolWrapper.pyt<module>s6						

Zerion Mini Shell 1.0