File "sslproto.cpython-34.pyc"

Full Path: /home/attunedd/public_html/byp/izo/con7ext_sym404/rintoar.txt/opt/alt/python34/lib64/python3.4/asyncio/__pycache__/sslproto.cpython-34.pyc
File size: 20.8 KB
MIME-type: text/x-bytecode.python
Charset: 8 bit


j fbc
@sddlZddlZyddlZWnek
rBdZYnXddlmZddlmZddlmZddlm	Z	ddZ
d	d
ZdZdZ
d
ZdZGdddeZGdddejejZGdddejZdS)N)compat)	protocols)
transports)loggercCs|rtdnttdrEtj}|sd|_qnLtjtj}|jtjO_|jtj	O_|j
tj|_|S)Nz(Server side SSL needs a valid SSLContextcreate_default_contextF)
ValueErrorhasattrsslrcheck_hostnameZ
SSLContextZPROTOCOL_SSLv23ZoptionsZOP_NO_SSLv2ZOP_NO_SSLv3Zset_default_verify_pathsZ
CERT_REQUIREDverify_mode)server_sideserver_hostname
sslcontextr5/opt/alt/python34/lib64/python3.4/asyncio/sslproto.py_create_transport_contexts
rcCs
ttdS)N	MemoryBIO)r	r
rrrr_is_sslproto_available$srZ	UNWRAPPEDZDO_HANDSHAKEZWRAPPEDZSHUTDOWNc@seZdZdZdZdddZeddZed	d
ZeddZ	ed
dZ
dddZdddZddZ
dddZdddZdS)_SSLPipeaAn SSL "Pipe".

    An SSL pipe allows you to communicate with an SSL/TLS protocol instance
    through memory buffers. It can be used to implement a security layer for an
    existing connection where you don't have access to the connection's file
    descriptor, or for some reason you don't want to use it.

    An SSL pipe can be in "wrapped" and "unwrapped" mode. In unwrapped mode,
    data is passed through untransformed. In wrapped mode, application level
    data is encrypted to SSL record level data and vice versa. The SSL record
    level is the lowest level in the SSL protocol suite and is what travels
    as-is over the wire.

    An SslPipe initially is in "unwrapped" mode. To start SSL, call
    do_handshake(). To shutdown SSL again, call unwrap().
    iNcCsj||_||_||_t|_tj|_tj|_d|_	d|_
d|_d|_dS)a
        The *context* argument specifies the ssl.SSLContext to use.

        The *server_side* argument indicates whether this is a server side or
        client side transport.

        The optional *server_hostname* argument can be used to specify the
        hostname you are connecting to. You may only specify this parameter if
        the _ssl module supports Server Name Indication (SNI).
        NF)
_context_server_side_server_hostname
_UNWRAPPED_stater
r	_incoming	_outgoing_sslobj
_need_ssldata
_handshake_cb_shutdown_cb)selfcontextr
rrrr__init__Cs							z_SSLPipe.__init__cCs|jS)z*The SSL context passed to the constructor.)r)r"rrrr#Ysz_SSLPipe.contextcCs|jS)z^The internal ssl.SSLObject instance.

        Return None if the pipe is not wrapped.
        )r)r"rrr
ssl_object^sz_SSLPipe.ssl_objectcCs|jS)zgWhether more record level data is needed to complete a handshake
        that is currently in progress.)r)r"rrrneed_ssldatafsz_SSLPipe.need_ssldatacCs
|jtkS)zj
        Whether a security layer is currently in effect.

        Return False during handshake.
        )r_WRAPPED)r"rrrwrappedlsz_SSLPipe.wrappedcCs|jtkrtdn|jj|j|jd|jd|j|_	t
|_||_|jddd\}}t
|dkst|S)aLStart the SSL handshake.

        Return a list of ssldata. A ssldata element is a list of buffers

        The optional *callback* argument can be used to install a callback that
        will be called when the handshake is complete. The callback will be
        called with None if successful, else an exception instance.
        z"handshake in progress or completedr
ronly_handshakeTr)rrRuntimeErrorrZwrap_biorrrrr
_DO_HANDSHAKEr feed_ssldatalenAssertionError)r"callbackssldataappdatarrrdo_handshakeus					z_SSLPipe.do_handshakecCs|jtkrtdn|jtkr<tdn|jttfksWtt|_||_|jd\}}|gks|dgkst|S)a1Start the SSL shutdown sequence.

        Return a list of ssldata. A ssldata element is a list of buffers

        The optional *callback* argument can be used to install a callback that
        will be called when the shutdown is complete. The callback will be
        called without arguments.
        zno security layer presentzshutdown in progressr))	rrr+	_SHUTDOWNr'r,r/r!r-)r"r0r1r2rrrshutdowns			!z_SSLPipe.shutdowncCsG|jj|jd\}}|gksC|dgksCtdS)zSend a potentially "ragged" EOF.

        This method will raise an SSL_ERROR_EOF exception if the EOF is
        unexpected.
        r)N)rZ	write_eofr-r/)r"r1r2rrrfeed_eofs
z_SSLPipe.feed_eofFcCs8|jtkr1|r!|g}ng}g|fSd|_|rS|jj|ng}g}y	|jtkr|jjt|_|j	r|j	dn|r||fSn|jtkrx|jj
|j}|j||sPqqWno|jt
kr?|jjd|_t|_|jrg|jqgn(|jtkrg|j|jj
nWntjtjfk
r}zrt|ddtjtjtjfkr|jtkr|j	r|j	|nn|jtjk|_WYdd}~XnX|jjr.|j|jj
n||fS)aFeed SSL record level data into the pipe.

        The data must be a bytes instance. It is OK to send an empty bytes
        instance. This can be used to get ssldata for a handshake initiated by
        this endpoint.

        Return a (ssldata, appdata) tuple. The ssldata element is a list of
        buffers containing SSL data that needs to be sent to the remote SSL.

        The appdata element is a list of buffers containing plaintext data that
        needs to be forwarded to the application. The appdata list may contain
        an empty buffer indicating an SSL "close_notify" alert. This alert must
        be acknowledged by calling shutdown().
        FNerrno)rrrrwriter,rr3r'r readmax_sizeappendr4Zunwrapr!r
SSLErrorCertificateErrorgetattrSSL_ERROR_WANT_READSSL_ERROR_WANT_WRITESSL_ERROR_SYSCALLr7rpending)r"datar*r2r1chunkexcrrrr-sV
	
		


			(z_SSLPipe.feed_ssldatarcCsd|kot|kns(t|jtkru|t|kr_||dg}ng}|t|fSg}t|}xd|_y9|t|kr||jj||d7}nWntj	k
rP}z_|j
dkrtj|_n|jtjtj
tjfkr)n|jtjk|_WYdd}~XnX|jjrv|j|jjn|t|ks|jrPqqW||fS)aFeed plaintext data into the pipe.

        Return an (ssldata, offset) tuple. The ssldata element is a list of
        buffers containing record level data that needs to be sent to the
        remote SSL instance. The offset is the number of plaintext bytes that
        were processed, which may be less than the length of data.

        NOTE: In case of short writes, this call MUST be retried with the SAME
        buffer passed into the *data* argument (i.e. the id() must be the
        same). This is an OpenSSL requirement. A further particularity is that
        a short write will always have offset == 0, because the _ssl module
        does not enable partial writes. And even though the offset is zero,
        there will still be encrypted data in ssldata.
        rNFZPROTOCOL_IS_SHUTDOWN)r.r/rr
memoryviewrrr8r
r<reasonr?r7r@rArrBr;r9)r"rCoffsetr1ZviewrErrrfeed_appdatas4(	'(z_SSLPipe.feed_appdatai)__name__
__module____qualname____doc__r:r$propertyr#r%r&r(r3r5r6r-rIrrrrr/s	
Jrc@seZdZddZdddZddZdd	ZejrWd
dZ	ndd
Z
ddZddddZddZ
ddZddZddZdS)_SSLProtocolTransportcCs(||_||_||_d|_dS)NF)_loop
_ssl_protocol
_app_protocol_closed)r"loopZssl_protocolapp_protocolrrrr$(s			z_SSLProtocolTransport.__init__NcCs|jj||S)z#Get optional transport information.)rQ_get_extra_info)r"namedefaultrrrget_extra_info/sz$_SSLProtocolTransport.get_extra_infocCs|jS)N)rS)r"rrr
is_closing3sz _SSLProtocolTransport.is_closingcCsd|_|jjdS)a
Close the transport.

        Buffered data will be flushed asynchronously.  No more data
        will be received.  After all buffered data is flushed, the
        protocol's connection_lost() method will (eventually) called
        with None as its argument.
        TN)rSrQ_start_shutdown)r"rrrclose6s	z_SSLProtocolTransport.closecCs.|js*tjd|t|jndS)Nzunclosed transport %r)rSwarningswarnResourceWarningr\)r"rrr__del__Es	z_SSLProtocolTransport.__del__cCs|jjjdS)zPause the receiving end.

        No data will be passed to the protocol's data_received()
        method until resume_reading() is called.
        N)rQ
_transport
pause_reading)r"rrrrbJsz#_SSLProtocolTransport.pause_readingcCs|jjjdS)zResume the receiving end.

        Data received will once again be passed to the protocol's
        data_received() method.
        N)rQraresume_reading)r"rrrrcRsz$_SSLProtocolTransport.resume_readingcCs|jjj||dS)aSet the high- and low-water limits for write flow control.

        These two values control when to call the protocol's
        pause_writing() and resume_writing() methods.  If specified,
        the low-water limit must be less than or equal to the
        high-water limit.  Neither value can be negative.

        The defaults are implementation-specific.  If only the
        high-water limit is given, the low-water limit defaults to an
        implementation-specific value less than or equal to the
        high-water limit.  Setting high to zero forces low to zero as
        well, and causes pause_writing() to be called whenever the
        buffer becomes non-empty.  Setting low to zero causes
        resume_writing() to be called only once the buffer is empty.
        Use of zero for either limit is generally sub-optimal as it
        reduces opportunities for doing I/O and computation
        concurrently.
        N)rQraset_write_buffer_limits)r"ZhighZlowrrrrdZsz-_SSLProtocolTransport.set_write_buffer_limitscCs|jjjS)z,Return the current size of the write buffer.)rQraget_write_buffer_size)r"rrrreosz+_SSLProtocolTransport.get_write_buffer_sizecCsWt|tttfs9tdjt|jn|sCdS|jj	|dS)zWrite some data bytes to the transport.

        This does not block; it buffers the data and arranges for it
        to be sent out asynchronously.
        z/data: expecting a bytes-like instance, got {!r}N)

isinstancebytes	bytearrayrF	TypeErrorformattyperJrQ_write_appdata)r"rCrrrr8ss	z_SSLProtocolTransport.writecCsdS)zAReturn True if this transport supports write_eof(), False if not.Fr)r"rrr
can_write_eofsz#_SSLProtocolTransport.can_write_eofcCs|jjdS)zClose the transport immediately.

        Buffered data will be lost.  No more data will be received.
        The protocol's connection_lost() method will (eventually) be
        called with None as its argument.
        N)rQ_abort)r"rrrabortsz_SSLProtocolTransport.abort)rJrKrLr$rYrZr\rZPY34r`rbrcrdrer8rmrorrrrrO%s	
rOc@seZdZdZddddZdddZdd	Zd
dZdd
ZddZ	ddZ
ddZdddZddZ
ddZddZddZddZd d!d"Zd#d$Zd%d&ZdS)'SSLProtocolzSSL protocol.

    Implementation of SSL on top of a socket using incoming and outgoing
    buffers which are ssl.MemoryBIO objects.
    FNcCstdkrtdn|s3t||}n||_|rU|rU||_n	d|_||_td||_tj	|_
d|_||_||_
||_t|j
||j|_d|_d|_d|_d|_d|_dS)Nzstdlib ssl module not availablerrF)r
r+rrr_sslcontextdict_extracollectionsdeque_write_backlog_write_buffer_size_waiterrPrRrO_app_transport_sslpipe_session_established
_in_handshake_in_shutdownra)r"rTrUrZwaiterr
rrrrr$s,	
											zSSLProtocol.__init__cCsa|jdkrdS|jjsT|dk	rA|jj|qT|jjdnd|_dS)N)rxZ	cancelledZ
set_exceptionZ
set_result)r"rErrr_wakeup_waiterszSSLProtocol._wakeup_waitercCs5||_t|j|j|j|_|jdS)zXCalled when the low-level connection is made.

        Start the SSL handshake.
        N)rarrqrrrz_start_handshake)r"	transportrrrconnection_mades
		zSSLProtocol.connection_madecCsD|jr.d|_|jj|jj|nd|_d|_dS)zCalled when the low-level connection is lost or closed.

        The argument is an exception object or None (the latter
        meaning a regular EOF is received or the connection was
        aborted or closed).
        FN)r{rP	call_soonrRconnection_lostrary)r"rErrrrs
			zSSLProtocol.connection_lostcCs|jjdS)z\Called when the low-level transport's buffer goes over
        the high-water mark.
        N)rR
pause_writing)r"rrrrszSSLProtocol.pause_writingcCs|jjdS)z^Called when the low-level transport's buffer drains below
        the low-water mark.
        N)rRresume_writing)r"rrrrszSSLProtocol.resume_writingcCsy|jj|\}}Wndtjk
r}zA|jjrbtjd||j|j	n|j
dSWYdd}~XnXx|D]}|jj|qWx2|D]*}|r|j
j|q|jPqWdS)zXCalled when some SSL data is received.

        The argument is a bytes object.
        z%r: SSL error %s (reason %s)N)rzr-r
r<rP	get_debugrwarningr7rGrnrar8rR
data_receivedr[)r"rCr1r2erDrrrrs	



zSSLProtocol.data_receivedc
Csyzd|jjr%tjd|n|jt|jsc|jj}|rctj	dqcnWd|j
jXdS)aCalled when the other end of the low-level stream
        is half-closed.

        If this returns a false value (including None), the transport
        will close itself.  If it returns a true value, closing the
        transport is up to the protocol.
        z%r received EOFz?returning true from eof_received() has no effect when using sslN)rPrrdebugr~ConnectionResetErrorr|rReof_receivedrrar\)r"Z	keep_openrrrrs
	zSSLProtocol.eof_receivedcCs1||jkr|j|S|jj||SdS)N)rsrarY)r"rWrXrrrrVszSSLProtocol._get_extra_infocCs'|jr
dSd|_|jddS)NTr))r}rl)r"rrrr[s		zSSLProtocol._start_shutdowncCs9|jj|df|jt|7_|jdS)Nr)rvr;rwr._process_write_backlog)r"rCrrrrl szSSLProtocol._write_appdatacCsm|jjr4tjd||jj|_n	d|_d|_|jjd|jj	|j
dS)Nz%r starts SSL handshakeTr)r)r)r)rPrrrtime_handshake_start_timer|rvr;rr)r"rrrr%s		zSSLProtocol._start_handshakecCsd|_|jj}yn|dk	r-|n|j}t|jds|jr|jjtj	krtj
||jqnWntk
r-}z|jj
rt|tjrtjd|ddqtjd|ddn|jjt|tr|j|dSWYdd}~XnX|jj
rm|jj|j}tjd||dn|jjd	|d
|jd|jd||jj|j|jd|_ |jj!|j"dS)
NFrz5%r: SSL handshake failed on verifying the certificateexc_infoTz%r: SSL handshake failedz%r: SSL handshake took %.1f msg@@peercertciphercompressionr%)#r|rzr%Zgetpeercertr	rqrrr
Z	CERT_NONEZmatch_hostname
BaseExceptionrPrrfr=rrrar\	Exceptionr~rrrrsupdaterrrRrryr{rr)r"Z
handshake_excZsslobjrrEZdtrrr_on_handshake_complete1sB					


	z"SSLProtocol._on_handshake_completecCs|jdkrdSy1x*tt|jD]}|jd\}}|ri|jj||\}}n?|r|jj|j}d}n|jj|j	}d}x|D]}|jj
|qW|t|kr ||f|jd<|jjst|jj
r|jjnPn|jd=|jt|8_q,WWnctk
r}zC|jrr|j|n|j|dt|tsnWYdd}~XnXdS)NrrzFatal error on SSL transport)raranger.rvrzrIr3rr5	_finalizer8r&r/Z_pausedrcrwrr|_fatal_errorrfr)r"irCrHr1rDrErrrrds:		

	z"SSLProtocol._process_write_backlogzFatal error on transportcCst|ttfrC|jjrrtjd||ddqrn/|jji|d6|d6|jd6|d6|jr|jj	|ndS)Nz%r: %srTmessageZ	exceptionrZprotocol)
rfBrokenPipeErrorrrPrrrZcall_exception_handlerraZ_force_close)r"rErrrrrs
	zSSLProtocol._fatal_errorcCs#|jdk	r|jjndS)N)rar\)r"rrrrszSSLProtocol._finalizec
Cs5|jdk	r1z|jjWd|jXndS)N)raror)r"rrrrnszSSLProtocol._abort)rJrKrLrMr$r~rrrrrrrVr[rlrrrrrrnrrrrrps$"

3,rp)rtr]r
ImportErrorrrrlogrrrrr,r'r4objectrZ_FlowControlMixinZ	TransportrOZProtocolrprrrr<module>s&
h