
    g8                        S r  " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S	 S
\5      r " S S\5      r " S S\5      r	 " S S\5      r
 " S S\
5      r " S S\
5      r " S S\
5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S \5      r " S! S"\5      rS# rS$ rS% rS& rS1S( jrS1S) jrS1S* jrS2S+ jrS1S, jrS3S. jrS-rS4S/ jr  S5S0 jr!g')6z6passlib.exc -- exceptions & warnings raised by passlibc                       \ rS rSrSrS rSrg)UnknownBackendError   z
Error raised if multi-backend handler doesn't recognize backend name.
Inherits from :exc:`ValueError`.

.. versionadded:: 1.7
c                 l    Xl         X l        UR                  < SU< 3n[        R	                  X5        g )Nz: unknown backend: )hasherbackendname
ValueError__init__)selfr   r   messages       D/home/matz/Project1/venv/lib/python3.13/site-packages/passlib/exc.pyr
   UnknownBackendError.__init__   s(    /5{{GDD*    )r   r   N__name__
__module____qualname____firstlineno____doc__r
   __static_attributes__ r   r   r   r      s    +r   r   c                       \ rS rSrSrSrg)MissingBackendError   a~  Error raised if multi-backend handler has no available backends;
or if specifically requested backend is not available.

:exc:`!MissingBackendError` derives
from :exc:`RuntimeError`, since it usually indicates
lack of an external library or OS feature.
This is primarily raised by handlers which depend on
external libraries (which is currently just
:class:`~passlib.hash.bcrypt`).
r   Nr   r   r   r   r   r   r   r   r   r   r      s    	r   r   c                       \ rS rSrSrSrg)InternalBackendError#   z
Error raised if something unrecoverable goes wrong with backend call;
such as if ``crypt.crypt()`` returning a malformed hash.

.. versionadded:: 1.7.3
r   Nr   r   r   r   r   r   #       r   r   c                       \ rS rSrSrSrg)PasswordValueError,   an  
Error raised if a password can't be hashed / verified for various reasons.
This exception derives from the builtin :exc:`!ValueError`.

May be thrown directly when password violates internal invariants of hasher
(e.g. some don't support NULL characters).  Hashers may also throw more specific subclasses,
such as :exc:`!PasswordSizeError`.

.. versionadded:: 1.7.3
r   Nr   r   r   r   r!   r!   ,   s    	 	r   r!   c                   &    \ rS rSrSrSrSS jrSrg)PasswordSizeError:   a  
Error raised if a password exceeds the maximum size allowed
by Passlib (by default, 4096 characters); or if password exceeds
a hash-specific size limitation.

This exception derives from :exc:`PasswordValueError` (above).

Many password hash algorithms take proportionately larger amounts of time and/or
memory depending on the size of the password provided. This could present
a potential denial of service (DOS) situation if a maliciously large
password is provided to an application. Because of this, Passlib enforces
a maximum size limit, but one which should be *much* larger
than any legitimate password. :exc:`PasswordSizeError` derives
from :exc:`!ValueError`.

.. note::
    Applications wishing to use a different limit should set the
    ``PASSLIB_MAX_PASSWORD_SIZE`` environmental variable before
    Passlib is loaded. The value can be any large positive integer.

.. attribute:: max_size

    indicates the maximum allowed size.

.. versionadded:: 1.6
Nc                 D    Xl         Uc  Sn[        R                  X5        g )Nz%password exceeds maximum allowed size)max_sizer!   r
   )r   r'   msgs      r   r
   PasswordSizeError.__init__X   s     ;9C##D.r   )r'   N)r   r   r   r   r   r'   r
   r   r   r   r   r$   r$   :   s    6 H/r   r$   c                   "    \ rS rSrSrSS jrSrg)PasswordTruncateErrora   a=  
Error raised if password would be truncated by hash.
This derives from :exc:`PasswordSizeError` (above).

Hashers such as :class:`~passlib.hash.bcrypt` can be configured to raises
this error by setting ``truncate_error=True``.

.. attribute:: max_size

    indicates the maximum allowed size.

.. versionadded:: 1.7
Nc                     Uc  SUR                   UR                  4-  n[        R                  XR                  U5        g )Nz1Password too long (%s truncates to %d characters))r   truncate_sizer$   r
   )r   clsr(   s      r   r
   PasswordTruncateError.__init__p   s9    ;FHHc//01C""4):):C@r   r   r*   r   r   r   r   r,   r,   a   s    Ar   r,   c                       \ rS rSrSrSrg)PasslibSecurityErrorw   z
Error raised if critical security issue is detected
(e.g. an attempt is made to use a vulnerable version of a bcrypt backend).

.. versionadded:: 1.6.3
r   Nr   r   r   r   r3   r3   w   r   r   r3   c                   &    \ rS rSrSrSrSS jrSrg)
TokenError   a  
Base error raised by v:mod:`passlib.totp` when
a token can't be parsed / isn't valid / etc.
Derives from :exc:`!ValueError`.

Usually one of the more specific subclasses below will be raised:

* :class:`MalformedTokenError` -- invalid chars, too few digits
* :class:`InvalidTokenError` -- no match found
* :class:`UsedTokenError` -- match found, but token already used

.. versionadded:: 1.7
zToken not acceptableNc                 V    Uc  U R                   n[        R                  " X/UQ70 UD6  g r*   )_default_messager	   r
   )r   r(   argskwdss       r   r
   TokenError.__init__   s*    ;''CD555r   r   r*   )r   r   r   r   r   r9   r
   r   r   r   r   r6   r6      s     .6r   r6   c                       \ rS rSrSrSrSrg)MalformedTokenError   z
Error raised by :mod:`passlib.totp` when a token isn't formatted correctly
(contains invalid characters, wrong number of digits, etc)
zUnrecognized tokenr   Nr   r   r   r   r   r9   r   r   r   r   r>   r>      s     ,r   r>   c                       \ rS rSrSrSrSrg)InvalidTokenError   z{
Error raised by :mod:`passlib.totp` when a token is formatted correctly,
but doesn't match any tokens within valid range.
zToken did not matchr   Nr@   r   r   r   rB   rB      s     -r   rB   c                   &    \ rS rSrSrSrSrS rSrg)UsedTokenError   z
Error raised by :mod:`passlib.totp` if a token is reused.
Derives from :exc:`TokenError`.

.. autoattribute:: expire_time

.. versionadded:: 1.7
z5Token has already been used, please wait for another.Nc                 f    UR                  SS 5      U l        [        R                  " U /UQ70 UD6  g )Nexpire_time)poprH   r6   r
   )r   r:   r;   s      r   r
   UsedTokenError.__init__   s-    88M48D04040r   )rH   )	r   r   r   r   r   r9   rH   r
   r   r   r   r   rE   rE      s     O K1r   rE   c                   (    \ rS rSrSrSS jrS rSrg)UnknownHashError   aB  
Error raised by :class:`~passlib.crypto.lookup_hash` if hash name is not recognized.
This exception derives from :exc:`!ValueError`.

As of version 1.7.3, this may also be raised if hash algorithm is known,
but has been disabled due to FIPS mode (message will include phrase "disabled for fips").

As of version 1.7.4, this may be raised if a :class:`~passlib.context.CryptContext`
is unable to identify the algorithm used by a password hash.

.. versionadded:: 1.7

.. versionchanged: 1.7.3
    added 'message' argument.

.. versionchanged:: 1.7.4
    altered call signature.
Nc                 X    X l         Uc  SU-  nXl        [        R                  XU5        g )Nzunknown hash algorithm: %r)valuer   r	   r
   )r   r   rO   s      r   r
   UnknownHashError.__init__   s+    
?2U:GD51r   c                     U R                   $ r*   )r   )r   s    r   __str__UnknownHashError.__str__   s    ||r   )r   rO   NN)r   r   r   r   r   r
   rR   r   r   r   r   rL   rL      s    $2r   rL   c                       \ rS rSrSrSrg)PasslibWarning   zlbase class for Passlib's user warnings,
derives from the builtin :exc:`UserWarning`.

.. versionadded:: 1.6
r   Nr   r   r   r   rV   rV          r   rV   c                       \ rS rSrSrSrg)PasslibConfigWarning   a   Warning issued when non-fatal issue is found related to the configuration
of a :class:`~passlib.context.CryptContext` instance.

This occurs primarily in one of two cases:

* The CryptContext contains rounds limits which exceed the hard limits
  imposed by the underlying algorithm.
* An explicit rounds value was provided which exceeds the limits
  imposed by the CryptContext.

In both of these cases, the code will perform correctly & securely;
but the warning is issued as a sign the configuration may need updating.

.. versionadded:: 1.6
r   Nr   r   r   r   rZ   rZ      s    r   rZ   c                       \ rS rSrSrSrg)PasslibHashWarning   a  Warning issued when non-fatal issue is found with parameters
or hash string passed to a passlib hash class.

This occurs primarily in one of two cases:

* A rounds value or other setting was explicitly provided which
  exceeded the handler's limits (and has been clamped
  by the :ref:`relaxed<relaxed-keyword>` flag).

* A malformed hash string was encountered which (while parsable)
  should be re-encoded.

.. versionadded:: 1.6
r   Nr   r   r   r   r]   r]      s    r   r]   c                       \ rS rSrSrSrg)PasslibRuntimeWarningi  a$  Warning issued when something unexpected happens during runtime.

The fact that it's a warning instead of an error means Passlib
was able to correct for the issue, but that it's anomalous enough
that the developers would love to hear under what conditions it occurred.

.. versionadded:: 1.6
r   Nr   r   r   r   r`   r`     s    r   r`   c                       \ rS rSrSrSrg)PasslibSecurityWarningi  zlSpecial warning issued when Passlib encounters something
that might affect security.

.. versionadded:: 1.6
r   Nr   r   r   r   rb   rb     rX   r   rb   c                 ,    U (       a  U R                   $ S$ )Nz	<unnamed>)r   handlers    r   	_get_namerf   "  s    "7<<33r   c                     U R                   nUR                  (       a-  UR                  S;  a  UR                  < SUR                  < 3$ U c  gUR                  $ )z<return pretty-printed string containing name of value's type)__builtin__builtins.None)	__class__r   r   )rO   r0   s     r   	type_namerm   (  sC    
//C
~~#..0KK..#,,77	||r   c                 D    [        U 5      n[        U< SU< SU< 35      $ )zGerror message when param was supposed to be one type, but found anotherz	 must be z, not )rm   	TypeError)rO   expectedparamr   s       r   ExpectedTypeErrorrr   2  s      UDxFGGr   c                     [        U SU5      $ )z<error message when param was supposed to be unicode or byteszunicode or bytes)rr   rO   rq   s     r   ExpectedStringErrorru   8  s    U$6>>r   Nc                 @    [        U 5      n[        SU< SU< S35      $ )zEraised when verify() method gets passed config string instead of hashz	expected z hash, got z config string insteadrf   r	   re   r   s     r   MissingDigestErrorry   ?  s#    WDD" # #r   c                 4    [        U 5      n[        SU-  5      $ )zFraised by OS crypt() supporting hashes, which forbid NULLs in passwordz(%s does not allow NULL bytes in password)rf   r!   rx   s     r   NullPasswordErrorr{   E  s    WDH4OPPr   c                 0    [        S[        U 5      -  5      $ )z5error raised if unrecognized hash provided to handlerznot a valid %s hash)r	   rf   rd   s    r   InvalidHashErrorr}   M  s    +i.@@AAr   c                 V    S[        U 5      -  nU(       a
  U< SU< S3n[        U5      $ )zAerror raised if recognized-but-malformed hash provided to handlerzmalformed %s hashz ()rw   )re   reasontexts      r   MalformedHashErrorr   Q  s)    7!33D &)dr   c                     [        U S5      $ )zJerror raised if hash was recognized but contained zero-padded rounds fieldzzero-padded rounds)r   rd   s    r   ZeroPaddedRoundsErrorr   X  s    g';<<r   Fc                 R    U R                   nU(       a  SOSnSX#4-  n[        X5      $ )z@error raised if hash was recognized, but checksum was wrong sizebytescharszchecksum must be exactly %d %s)checksum_sizer   )re   rawr   unitr   s        r   ChecksumSizeErrorr   _  s0     ))M7wD-0EEFg..r   c                     [         (       d  U b  [        U [        5      (       a  [        U 5      $ SU< S[	        U 5      < S3$ )a  
helper used to display sensitive data (hashes etc) within error messages.
currently returns placeholder test UNLESS unittests are running,
in which case the real value is displayed.

mainly useful to prevent hashes / secrets from being exposed in production tracebacks;
while still being visible from test failures.

NOTE: api subject to change, may formalize this more in the future.
< z value omitted>)ENABLE_DEBUG_ONLY_REPR
isinstanceboolreprtypert   s     r   debug_only_reprr   p  s9     *UD2I2IE{ 3J&+T%[99r   c           	      t    [        U 5      nU< SU< S[        U5      < S[        U5      < 3n[        U5      e)z
helper to generate standard message when ``crypt.crypt()`` returns invalid result.
takes care of automatically masking contents of config & hash outside of UTs.
z returned invalid z hash: config=z hash=)rf   r   r   )re   confighashsourcer   r(   s         r   CryptBackendErrorr     s4     WD40/$2GIC
s
##r   r*   rT   )F)r   )zcrypt.crypt())"r   r	   r   RuntimeErrorr   r   r!   r$   r,   r3   r6   r>   rB   rE   rL   UserWarningrV   rZ   r]   r`   rb   rf   rm   rr   ru   ry   r{   r}   r   r   r   r   r   r   r   r   r   <module>r      s&   <+* +"
, 
< 	 	"/* "/NA- A,< 6 60,* ,-
 -1Z 1(z B[ > "  N ^ "4H?#QB=/  :" -	$r   