Your IP : 172.28.240.42


Current Path : /usr/lib/python2.7/dist-packages/Crypto/PublicKey/
Upload File :
Current File : //usr/lib/python2.7/dist-packages/Crypto/PublicKey/ElGamal.pyc


pZc@skdZddlTddlmZdefdYZd
dZdZde	fd	YZ
e
Zd
S(s$Id$i(t*(tnumberterrorcBseZRS((t__name__t
__module__(((s</usr/lib/python2.7/dist-packages/Crypto/PublicKey/ElGamal.pyRscCs}t}|r|dnxItt|d|}d|d|_tj|jd|rPqq|r{|dnxttjd|j|d|j|_|jd	krq~n|jd|jdkrq~ntj	|j|j}|jd|dkrq~nPq~|r)|dntjd|jd||_
|r[|dnt|j|j
|j|_|S(
sgenerate(bits:int, randfunc:callable, progress_func:callable)

    Generate an ElGamal key of length 'bits', using 'randfunc' to get
    random data and 'progress_func', if present, to display
    the progress of the key generation.
    sp
iitrandfuncsg
isx
sy
(ii(t
ElGamalobjtbignumtgetPrimetpRtisPrimetpowtgetRandomRangetgtinversetxty(tbitsRt
progress_functobjtqtginv((s</usr/lib/python2.7/dist-packages/Crypto/PublicKey/ElGamal.pytgenerate#s6	

*

cCslt}t|dkr*tdnx;tt|D]'}|j|}t||||q=W|S(sconstruct(tuple:(long,long,long,long)|(long,long,long,long,long)))
             : ElGamalobj
    Construct an ElGamal key from a 3- or 4-tuple of numbers.
    iis%argument for construct() wrong length(ii(Rtlent
ValueErrortrangetkeydatatsetattr(ttupleRtitfield((s</usr/lib/python2.7/dist-packages/Crypto/PublicKey/ElGamal.pyt	constructZs	
RcBsYeZddddgZdZdZdZdZdZd	Zd
Z	RS(R	R
RRcCsEt|j||j}|t|j||j|j}||fS(N(RR
R	R(tselftMtKtatb((s</usr/lib/python2.7/dist-packages/Crypto/PublicKey/ElGamal.pyt_encryptks#cCs_t|dstdnt|d|j|j}|dt||j|j}|S(NRs(Private key not available in this objectii(thasattrt	TypeErrorRRR	R(R R!taxt	plaintext((s</usr/lib/python2.7/dist-packages/Crypto/PublicKey/ElGamal.pyt_decryptps
!cCst|dstdn|jd}t||dkrOtdnt|j||j}||j||}x|dkr||}qW|t|||}||fS(NRs(Private key not available in this objectisBad K value: GCD(K,p-1)!=1i(	R&R'R	tGCDRRR
RR(R R!R"tp1R#ttR$((s</usr/lib/python2.7/dist-packages/Crypto/PublicKey/ElGamal.pyt_signws
cCs|ddks'|d|jdkr+dSt|j|d|j}|t|d|d|j|j}t|j||j}||krdSdS(Nii(R	RRR
(R R!tsigtv1tv2((s</usr/lib/python2.7/dist-packages/Crypto/PublicKey/ElGamal.pyt_verifys'(cCstj|jdS(sBReturn the maximum number of bits that can be handled by this key.i(RtsizeR	(R ((s</usr/lib/python2.7/dist-packages/Crypto/PublicKey/ElGamal.pyR3scCst|drdSdSdS(sQReturn a Boolean denoting whether the object contains
        private components.RiiN(R&(R ((s</usr/lib/python2.7/dist-packages/Crypto/PublicKey/ElGamal.pythas_privatescCst|j|j|jfS(s?Return a new key object containing only the public information.(RR	R
R(R ((s</usr/lib/python2.7/dist-packages/Crypto/PublicKey/ElGamal.pyt	publickeys(
RRRR%R*R.R2R3R4R5(((s</usr/lib/python2.7/dist-packages/Crypto/PublicKey/ElGamal.pyRhs				
		N(t__revision__tCrypto.PublicKey.pubkeytCrypto.UtilRt	ExceptionRtNoneRRtpubkeyRtobject(((s</usr/lib/python2.7/dist-packages/Crypto/PublicKey/ElGamal.pyt<module>s
7	6