+
    Dfj                         R t ^ RIt^ RIt^ RIt]! ]RR4      t]P                  t ! R R]	4      t
 ! R R]	4      t ! R R4      t]! 4       t]P                  t]P                  tA. R	OtR# )
zQ
Cryptographically secure random implementation, with fallback on normal random.
Ngetrandbitsc                       ] tR t^tRtRtR# )SecureRandomNotAvailablez<
Exception raised when no secure random algorithm is found.
 N__name__
__module____qualname____firstlineno____doc____static_attributes__r       :/usr/lib/python3/dist-packages/twisted/python/randbytes.pyr   r          r   r   c                       ] tR t^tRtRtR# )SourceNotAvailablezI
Internal exception used when a specific random source is not available.
r   Nr   r   r   r   r   r      r   r   r   c                      a  ] tR t^t o RtRt]tV 3R lR ltRV 3R lR lltV 3R lR lt	]
P                  t]! RR4      tV 3R	 lR
 ltV 3R lR ltRtV tR# )RandomFactoryz
Factory providing L{secureRandom} and L{insecureRandom} methods.

You shouldn't have to instantiate this class, use the module level
functions instead: it is an implementation detail and could be removed or
changed arbitrarily.
c                &   < V ^8  d   QhRS[ RS[/#    nbytesreturnintbytes)format__classdict__s   "r   __annotate__RandomFactory.__annotate__-   s     ( ( ( (r   c                x     \         P                  ! V4      #   \        \        3 d   p\	        T4      hRp?ii ; i)z?
Wrapper around C{os.urandom} that cleanly manage its absence.
N)osurandomAttributeErrorNotImplementedErrorr   )selfr   es   && r   
_osUrandomRandomFactory._osUrandom-   s7    	(::f%% 34 	($Q''	(s    949c                ,   < V ^8  d   QhRS[ RS[RS[/# )r   r   fallbackr   )r   boolr   )r   r   s   "r   r   r   6   s'     P P3 P$ P5 Pr   c                     V P                  V4      #   \         d     Mi ; iT'       d/   \        P                  ! R\        ^R7       T P                  T4      # \        R4      h)a#  
Return a number of secure random bytes.

@param nbytes: number of bytes to generate.
@type nbytes: C{int}
@param fallback: Whether the function should fallback on non-secure
    random or not.  Default to C{False}.
@type fallback: C{bool}

@return: a string of random bytes.
@rtype: C{str}
zPurandom unavailable - proceeding with non-cryptographically secure random source)category
stacklevelz!No secure random source available)r'   r   warningswarnRuntimeWarninginsecureRandomr   )r%   r   r*   s   &&&r   secureRandomRandomFactory.secureRandom6   sd    	??6**! 		 MMM'	 &&v..*+NOO    !!c                &   < V ^8  d   QhRS[ RS[/# r   r   )r   r   s   "r   r   r   S   s     H H H Hr   c                    V P                   e;   V P                  V^,          4      pRV^,          ,          V,          p\        V4      # \        R4      h)z#
Wrapper around C{os.getrandbits}.
z%%0%dxz#random.getrandbits is not available)r   _fromhexr   )r%   r   nhexBytess   &&  r   	_randBitsRandomFactory._randBitsS   sN     '  !,A FQJ/14HH%% !FGGr   r   c                &   < V ^8  d   QhRS[ RS[/# r   r   )r   r   s   "r   r   r   `   s     V V# V% Vr   c           
         RP                  \        V4       Uu. uF-  p\        \        P                  ! V P
                  4      .4      NK/  	  up4      # u upi )z&
Wrapper around the C{random} module.
r   )joinranger   randomchoice_BYTES)r%   r   is   && r   _randModuleRandomFactory._randModule`   s>     xxeFmTmdkk :;<mTUUTs   3Ac                &   < V ^8  d   QhRS[ RS[/# r   r   )r   r   s   "r   r   r   f   s     ( (S (U (r   c                j     V P                  V4      #   \         d     Mi ; iT P                  T4      # )z
Return a number of non secure random bytes.

@param nbytes: number of bytes to generate.
@type nbytes: C{int}

@return: a string of random bytes.
@rtype: C{str}
)r;   r   rE   )r%   r   s   &&r   r2   RandomFactory.insecureRandomf   s9    	>>&))! 		''r5   r   N)F)r   r   r	   r
   r   randomSourcesr   r'   r3   r;   r   	maketrans
_maketransrC   rE   r2   r   __classdictcell__)r   s   @r   r   r      se      MK( (P P:H H JS!FV V( (r   r   )r3   r2   r   )r   r!   rA   r/   getattrr   r   fromhexr8   RuntimeErrorr   r   r   factoryr3   r2   __all__r   r   r   <module>rS      s{   

 
  fmT2==|  U( U(p /##'' Ir   