ó πöVc@s`dZddlZddlmZmZddlmZd„Zd„Zd„Z d„Z dS( s(Functions for generating random numbers.i˙˙˙˙N(tcommont transform(tbytecCsjt|dƒ\}}tj|ƒ}|dkrfttjdƒƒ}|d|L}t|ƒ|}n|S(sReads 'nbits' random bits. If nbits isn't a whole number of bytes, an extra byte will be appended with only the lower bits set. iii(tdivmodtosturandomtordR(tnbitstnbytestrbitst randomdatat randomvalue((s6/opt/awscli/lib/python2.7/site-packages/rsa/randnum.pytread_random_bitss cCs1t|ƒ}tj|ƒ}|d|d>O}|S(s8Reads a random integer of approximately nbits bits. i(R Rt bytes2int(RR tvalue((s6/opt/awscli/lib/python2.7/site-packages/rsa/randnum.pytread_random_int0s cCst|ƒ}|dBS(shReads a random odd integer of approximately nbits bits. >>> read_random_odd_int(512) & 1 1 i(R(RR((s6/opt/awscli/lib/python2.7/site-packages/rsa/randnum.pytread_random_odd_int>s cCsotj|ƒ}d}xStrjt|ƒ}||kr:Pn|r]|ddkr]|d8}n|d7}qW|S(sŢReturns a random integer x with 1 <= x <= maxvalue May take a very long time in specific situations. If maxvalue needs N bits to store, the closer maxvalue is to (2 ** N) - 1, the faster this function is. ii i(Rtbit_sizetTrueR(tmaxvalueRttriesR((s6/opt/awscli/lib/python2.7/site-packages/rsa/randnum.pytrandintKs    ( t__doc__RtrsaRRt rsa._compatRR RRR(((s6/opt/awscli/lib/python2.7/site-packages/rsa/randnum.pyts