ó "9QRc @sdZddlZddlZddlmZmZmZddlmZddlmZmZm Z ddlm Z m Z m Z ddlm Z mZmZmZmZmZmZmZmZddlmZmZmZid e6d e6d e6Zydd lmZeZWnek r,eZn Xd ee|jj||ƒS|jj|||ƒSdS(Ns%sendto not allowed on instances of %s(R.RLRMR%R!tsendto(R<RGt flags_or_addrtaddr((sD/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/ssl.pyRQÓs   cCsˆ|jrq|dkr+td|jƒ‚nt|ƒ}d}x-||krl|j||ƒ}||7}q@W|Stj|||ƒSdS(Nis6non-zero flags not allowed in calls to sendall() on %s(R.RLRMRDRNRtsendall(R<RGROtamounttcountRP((sD/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/ssl.pyRTÜs   cCsO|jr8|dkr+td|jƒ‚n|j|ƒS|jj||ƒSdS(Nis3non-zero flags not allowed in calls to recv() on %s(R.RLRMRBR!trecv(R<tbuflenRO((sD/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/ssl.pyRWës   cCs¤|r!|dkr!t|ƒ}n|dkr6d}n|jrŠ|dkratd|jƒ‚n|j|ƒ}t|ƒ}|||*|S|jj|||ƒSdS(Niis8non-zero flags not allowed in calls to recv_into() on %s(R%RDR.RLRMRBR!t recv_into(R<tbuffertnbytesROt tmp_bufferRP((sD/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/ssl.pyRYõs      cCs6|jrtd|jƒ‚n|jj||ƒSdS(Ns'recvfrom not allowed on instances of %s(R.RLRMR!trecvfrom(R<RXRO((sD/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/ssl.pyR]s cCs9|jrtd|jƒ‚n|jj|||ƒSdS(Ns,recvfrom_into not allowed on instances of %s(R.RLRMR!t recvfrom_into(R<RZR[RO((sD/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/ssl.pyR^ s cCs|jr|jjƒSdSdS(Ni(R.tpending(R<((sD/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/ssl.pyR_s  cCs?|jr%|jjƒ}d|_|Stdt|ƒƒ‚dS(NsNo SSL wrapper around (R.tshutdownR%RLtstr(R<ts((sD/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/ssl.pytunwraps   cCsd|_tj||ƒdS(N(R%R.RR`(R<thow((sD/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/ssl.pyR`"s cCs;|jdkr(d|_tj|ƒn|jd8_dS(Ni(R;R%R.Rtclose(R<((sD/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/ssl.pyRe&s cCs|jjƒdS(sPerform a TLS/SSL handshake.N(R.R2(R<((sD/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/ssl.pyR2-sc Cs½|jrtdƒ‚ntj|jt|j|j|j|j |j |j ƒ|_ y*t j||ƒ|jr}|jƒnWn/tk r¯}|r|jSd|_ |‚nXt|_dS(Ns/attempt to connect already-connected SSLSocket!i(R-RLR0R1R!R,R3R4R5R6R7R8R.RtconnectR9R2R)R*R%R/(R<RSt return_errnoR@((sD/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/ssl.pyt _real_connect3s       cCs|j|tƒdS(sQConnects to remote ADDR, and then wraps the connection in an SSL channel.N(RhR,(R<RS((sD/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/ssl.pyRfHscCs|j|tƒS(sQConnects to remote ADDR, and then wraps the connection in an SSL channel.(RhR/(R<RS((sD/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/ssl.pyt connect_exMscCsstj|ƒ\}}t|d|jd|jdtd|jd|jd|jd|j d|j d |j ƒ |fS( s¿Accepts a new connection from a remote client, and returns a tuple containing that new connection wrapped with a server-side SSL channel, and the address of the remote client.R3R4R>R5R6R7R8R9R:( RtacceptR R3R4R/R5R6R7R8R9R:(R<tnewsockRS((sD/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/ssl.pyRjRs         triÿÿÿÿcCs%|jd7_t|||dtƒS(sMake and return a file-like object that works with the SSL connection. Just use the code from the socket module.iRe(R;RR/(R<tmodetbufsize((sD/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/ssl.pytmakefileesN(t__name__t __module__t__doc__R%R,RRR/R"RBRFRJRKRNRQRTRWRYR]R^R_RcR`ReR2RhRfRiRjRo(((sD/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/ssl.pyR ds6,              c Cs@t|d|d|d|d|d|d|d|d|d | ƒ S( NR3R4R>R5R6R7R9R:R8(R ( R=R3R4R>R5R6R7R9R:R8((sD/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/ssl.pyt wrap_socketrs   cCs%ddl}|j|j|dƒƒS(s¢Takes a date-time string in standard ASN1_print form ("MON DAY 24HOUR:MINUTE:SEC YEAR TIMEZONE") and return a Python time value in seconds past the epoch.iÿÿÿÿNs%b %d %H:%M:%S %Y GMT(ttimetmktimetstrptime(t cert_timeRt((sD/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/ssl.pytcert_time_to_seconds‚s s-----BEGIN CERTIFICATE-----s-----END CERTIFICATE-----cCscttdƒrBtj|ƒ}tdtj|dƒdtdStdtj|ƒtdSdS(s[Takes a certificate in binary DER format and returns the PEM version of it as a string.tstandard_b64encodes i@N(thasattrtbase64Ryt PEM_HEADERttextwraptfillt PEM_FOOTERt encodestring(tder_cert_bytestf((sD/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/ssl.pytDER_cert_to_PEM_certŽs$cCsw|jtƒs"tdtƒ‚n|jƒjtƒsJtdtƒ‚n|jƒttƒttƒ !}tj|ƒS(shTakes a certificate in ASCII PEM format and returns the DER-encoded version of it as a byte sequences(Invalid PEM encoding; must start with %ss&Invalid PEM encoding; must end with %s( t startswithR|RLtstriptendswithRRDR{t decodestring(tpem_cert_stringtd((sD/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/ssl.pytPEM_cert_to_DER_certžs   cCsx|\}}|dk r!t}nt}ttƒd|d|d|ƒ}|j|ƒ|jtƒ}|jƒt |ƒS(s÷Retrieve the certificate from the server at the specified address, and return it as a PEM-encoded string. If 'ca_certs' is specified, validate the server cert against it. If 'ssl_version' is specified, use it in the connection attempt.R6R5R7N( R%RRRsRRfRJR/ReRƒ(RSR6R7thosttportR5Rbtdercert((sD/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/ssl.pytget_server_certificate¬s     cCstj|dƒS(Ns (t_PROTOCOL_NAMEStget(t protocol_code((sD/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/ssl.pytget_protocol_name¿scCslt|dƒr|j}ntj|d||ttdƒ}y|jƒWntk r]n X|j ƒ|S(sŒA replacement for the old socket.ssl function. Designed for compability with Python 2.5 and earlier. Will disappear in Python 3.0.R!iN( RzR!R0R1RRR%R(R)R2(R=R3R4tssl_sock((sD/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/ssl.pytsslwrap_simpleÅs    (4RrR}R0RRRRRRRRRR R R R R RRRRRRRRRRR&t ImportErrorR%RRRRR)Rt _getnameinfoR{R*R'R R,R/RsRxR|RRƒRŠRŽR’R”(((sD/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/ssl.pyt8sL  @      "  ÿ