ó J(Zc@s’dZddlTddlmZddlmZmZddlmZddl Tde fd„ƒYZ d„Z d d „Zd d d „ƒYZd S(s$Id$iÿÿÿÿ(t*(tnumber(t bytes_to_longt long_to_bytes(tSHAterrorcBseZRS((t__name__t __module__(((s7/tmp/pip-build-LvEk9W/pycrypto/Crypto/PublicKey/_DSA.pyR$scCs/|dƒ}tj|ƒjƒ}tjtt|ƒdƒƒjƒ}tdƒ}xutddƒD]d}t||ƒt||ƒA}|dkrŸ|dB}n|dkr¸|dB}n|d|}qbWxt|ƒsæ|d}qÍWt ddƒ|kot dd ƒknr||fSt d ƒ‚dS( Niiii€iiilŸl sBad q value generated( RtnewtdigestRRtbignumtrangetbordtisPrimetpowt RuntimeError(trandfunctSthash1thash2tqtitc((s7/tmp/pip-build-LvEk9W/pycrypto/Crypto/PublicKey/_DSA.pyt generateQ's  %     . cCsñ|dkrtdƒ‚ntƒ}|r7|dƒnx£t|ƒ\}|_t|ddƒd}ddi}}}|jd?d@} ttdƒ| ƒ} ttdƒ|dƒ} xú|d krµxNtd|dƒD]9} tt j |t |ƒt | ƒƒj ƒƒ|| || } q>W| | }||d|jd}| |kr™t |ƒr™Pn|d||d}}q¼W|d krÆPn|r:|d ƒq:q:W||_t|d|jƒd}|r|d ƒnx`t||ƒƒ|d}t|||ƒ}d|ko]|dknr|dkrPqqW||_|r’|dƒnx9t|dƒƒ}d|koÁ|jknr•Pq•q•W|t|||ƒ|_|_|S(sègenerate(bits:int, randfunc:callable, progress_func:callable) Generate a DSA key of length 'bits', using 'randfunc' to get random data and 'progress_func', if present, to display the progress of the key generation. i sKey length < 160 bitssp,q iiiiiiiÿÿÿÿl s4096 multiples failed sh,g sx,y i(t ValueErrortDSAobjRRtdivmodRR R RRRtbstrR R tptgtxty(tbitsRt progress_functobjRtntCtNtVtbtpowbtpowL1tktWtXRtpowerthRR((s7/tmp/pip-build-LvEk9W/pycrypto/Crypto/PublicKey/_DSA.pyt generate_py9sZ   7    ,  RcBseZRS((RR(((s7/tmp/pip-build-LvEk9W/pycrypto/Crypto/PublicKey/_DSA.pyRqsN((t __revision__tCrypto.PublicKey.pubkeyt Crypto.UtilRtCrypto.Util.numberRRt Crypto.HashRtCrypto.Util.py3compatt ExceptionRRtNoneR/R(((s7/tmp/pip-build-LvEk9W/pycrypto/Crypto/PublicKey/_DSA.pyts    8