+
    ¢THi“6  ã                   óð   € R t ^ RIHtHt ^ RIHt ^ RIHt ^ RIH	u H
t ^ RIHtHtHt ^ RIHt . ROtRt ! R
 R]P(                  ]P*                  4      t ! R R]4      t ! R R	]P0                  4      tR# )zCisco password hashes)ÚhexlifyÚ	unhexlify)Úmd5)ÚwarnN)Úrepeat_stringÚright_pad_stringÚ
to_unicode)Úh64Ú	cisco_pixÚ	cisco_asaÚcisco_type7c                   óZ   a € ] tR t^t o RtR t^tRtRt^t	]
P                  tRtR tRtV tR# )r
   a6  
This class implements the password hash used by older Cisco PIX firewalls,
and follows the :ref:`password-hash-api`.
It does a single round of hashing, and relies on the username
as the salt.

This class only allows passwords <= 16 bytes, anything larger
will result in a :exc:`~passlib.exc.PasswordSizeError` if passed to :meth:`~cisco_pix.hash`,
and be silently rejected if passed to :meth:`~cisco_pix.verify`.

The :meth:`~passlib.ifc.PasswordHash.hash`,
:meth:`~passlib.ifc.PasswordHash.genhash`, and
:meth:`~passlib.ifc.PasswordHash.verify` methods
all support the following extra keyword:

:param str user:
    String containing name of user account this password is associated with.

    This is *required* in order to correctly hash passwords associated
    with a user account on the Cisco device, as it is used to salt
    the hash.

    Conversely, this *must* be omitted or set to ``""`` in order to correctly
    hash passwords which don't have an associated user account
    (such as the "enable" password).

.. versionadded:: 1.6

.. versionchanged:: 1.7.1

    Passwords > 16 bytes are now rejected / throw error instead of being silently truncated,
    to match Cisco behavior.  A number of :ref:`bugs <passlib-asa96-bug>` were fixed
    which caused prior releases to generate unverifiable hashes in certain cases.
TFc                ó`  € V P                   p\        V\        4      '       d   VP                  R4      pRp\	        V4      V P
                  8”  dj   V P                  '       dK   RV P                  V P
                  3,          p\        P                  P                  V P
                  VR7      hV\        ,           pV P                  pV'       dS   \        V\        4      '       d   VP                  R4      pV'       d   \	        V4      ^8  d   V\        V^4      ,          pV'       d   \	        V4      ^8”  d   ^ pM^p\        W4      pV'       d	   W,          p\        V4      P!                  4       p\#        R \%        V4       4       4      p\&        P(                  ! V4      P+                  R4      # )aï  
This function implements the "encrypted" hash format used by Cisco
PIX & ASA. It's behavior has been confirmed for ASA 9.6,
but is presumed correct for PIX & other ASA releases,
as it fits with known test vectors, and existing literature.

While nearly the same, the PIX & ASA hashes have slight differences,
so this function performs differently based on the _is_asa class flag.
Noteable changes from PIX to ASA include password size limit
increased from 16 -> 32, and other internal changes.
úutf-8Nz.Password too long (%s allows at most %d bytes))Úmsgc              3   óZ   "  € T F!  w  rV^,           ^,          '       g   K  Vx € K#  	  R# 5i)é   N© )Ú.0ÚiÚcs   &  Ú8/usr/lib/python3/dist-packages/passlib/handlers/cisco.pyÚ	<genexpr>Ú+cisco_pix._calc_checksum.<locals>.<genexpr>Ë   s"   é € ÐFÑ%6™T˜Q¸1¸q½5ÀA¿+¹+—q’qÓ%6ùs   ‚+¡
+Úascii)Ú_is_asaÚ
isinstanceÚstrÚencodeÚlenÚtruncate_sizeÚuse_defaultsÚnameÚuhÚexcÚPasswordSizeErrorÚ_DUMMY_BYTESÚuserr   r   r   ÚdigestÚbytesÚ	enumerater	   Úencode_bytesÚdecode)ÚselfÚsecretÚasaÚspoil_digestr   r'   Úpad_sizer(   s   &&      r   Ú_calc_checksumÚcisco_pix._calc_checksumS   s]  € ð �l‰lˆô �fœc×"Ò"Ø—]‘] 7Ó+ˆFð, ˆÜˆv‹;˜×+Ñ+Ô+Ø× × Ð àFØ—I‘IØ×&Ñ&ðJõ �ô —f‘f×.Ñ.¨t×/AÑ/AÀsÐ.ÓKÐKð "¤LÕ0ˆLð. �y‰yˆßÜ˜$¤×$Ò$Ø—{‘{ 7Ó+�ßœ#˜f›+¨Ô*Øœ-¨¨aÓ0Õ0�÷ ”3�v“; Ô#Ø‰HàˆHÜ! &Ó3ˆ÷
 àÕ"ˆFÜ�V“×#Ñ#Ó%ˆô ÑF¤Y¨vÔ%6ÓFÓFˆô
 ×Ò Ó'×.Ñ.¨wÓ7Ð7ó    r   N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r"   r    Útruncate_errorÚtruncate_verify_rejectÚchecksum_sizer#   ÚHASH64_CHARSÚchecksum_charsr   r2   Ú__static_attributes__Ú__classdictcell__)Ú__classdict__s   @r   r
   r
      sG   ø‡ € ñ!ðL €Dà€Mð €NØ!Ðð
 €MØ—_‘_€Nð €G÷}8ð }8r4   c                   ó&   € ] tR t^âtRtR t^ tRtRtR# )r   a¨  
This class implements the password hash used by Cisco ASA/PIX 7.0 and newer (2005).
Aside from a different internal algorithm, it's use and format is identical
to the older :class:`cisco_pix` class.

For passwords less than 13 characters, this should be identical to :class:`!cisco_pix`,
but will generate a different hash for most larger inputs
(See the `Format & Algorithm`_ section for the details).

This class only allows passwords <= 32 bytes, anything larger
will result in a :exc:`~passlib.exc.PasswordSizeError` if passed to :meth:`~cisco_asa.hash`,
and be silently rejected if passed to :meth:`~cisco_asa.verify`.

.. versionadded:: 1.7

.. versionchanged:: 1.7.1

    Passwords > 32 bytes are now rejected / throw error instead of being silently truncated,
    to match Cisco behavior.  A number of :ref:`bugs <passlib-asa96-bug>` were fixed
    which caused prior releases to generate unverifiable hashes in certain cases.
Tr   N)	r5   r6   r7   r8   r9   r"   r    r   r?   r   r4   r   r   r   â   s   † ñð2 €Dð
 €Mð
 „Gr4   c                   óð   a a€ ] tR tRt oRtR tRt]P                  t	^ t
^4t]RV 3R ll4       t]R 4       tRV 3R llt]RR l4       t]R 4       tR tR	 t]RR
 l4       tRt]V3R lR l4       tRtVtV ;t# )r   i	  a×  
This class implements the "Type 7" password encoding used by Cisco IOS,
and follows the :ref:`password-hash-api`.
It has a simple 4-5 bit salt, but is nonetheless a reversible encoding
instead of a real hash.

The :meth:`~passlib.ifc.PasswordHash.using` method accepts the following optional keywords:

:type salt: int
:param salt:
    This may be an optional salt integer drawn from ``range(0,16)``.
    If omitted, one will be chosen at random.

:type relaxed: bool
:param relaxed:
    By default, providing an invalid value for one of the other
    keywords will result in a :exc:`ValueError`. If ``relaxed=True``,
    and the error can be corrected, a :exc:`~passlib.exc.PasslibHashWarning`
    will be issued instead. Correctable errors include
    ``salt`` values that are out of range.

Note that while this class outputs digests in upper-case hexadecimal,
it will accept lower-case as well.

This class also provides the following additional method:

.. automethod:: decode
c                óž   <a€ \         SV `  ! R/ VB pSe7   VP                  SVP                  R4      R7      o\	        V3R l4      Vn        V# )NÚrelaxed)rE   c                  ó   <€ S # ©Nr   ©Úsalts   €r   Ú<lambda>Ú#cisco_type7.using.<locals>.<lambda>@  s   ø€ ¹r4   r   )ÚsuperÚusingÚ
_norm_saltÚgetÚstaticmethodÚ_generate_salt)ÚclsrI   ÚkwdsÚsubclsÚ	__class__s   &f, €r   rM   Úcisco_type7.using;  sJ   ù€ ä‘’Ñ& Ñ&ˆØÒØ×$Ñ$ T°4·8±8¸IÓ3FÐ$ÓGˆDÜ$0´Ó$>ˆFÔ!Øˆr4   c                óÚ   € \        VR R4      p\        V4      ^8  d    \        P                  P	                  V 4      h\        VR,          4      pV ! W!R,          P                  4       R7      # )r   Úhash:Né   N:rY   NN©rI   Úchecksum)r   r   r#   r$   ÚInvalidHashErrorÚintÚupper)rR   rX   rI   s   && r   Úfrom_stringÚcisco_type7.from_stringC  sS   € ä˜$ ¨Ó0ˆÜˆt‹9�qŒ=Ü—&‘&×)Ñ)¨#Ó.Ð.Ü�4˜•8‹}ˆÙ˜¨B¥x§~¡~Ó'7Ô8Ð8r4   c                óþ   <€ \         SV `  ! R/ VB  Ve   V P                  V4      pMOV P                  '       d3   V P	                  4       pV P                  V4      V8X  g   Q RV: 24       hM\        R4      hWn        R # )Nzgenerated invalid salt: zno salt specifiedr   )rL   Ú__init__rN   r!   rQ   Ú	TypeErrorrI   )r-   rI   rS   rU   s   &&,€r   rb   Úcisco_type7.__init__K  sv   ø€ Ü‰ÒÑ ˜4Ò ØÒØ—?‘? 4Ó(‰DØ××ÐØ×&Ñ&Ó(ˆDØ—?‘? 4Ó(¨DÔ0ÐUÐ4LÈTÉHÐ2UÓUÑ0äÐ/Ó0Ð0ØŽ	r4   c                ó2  € \        V\        4      '       g"   \        P                  P	                  VRR4      h^ Tu;8:  d   V P
                  8:  d    V#  RpV'       d0   \        V\        P                  4       V^ 8  d   ^ # V P
                  # \        V4      h)zm
validate & normalize salt value.
.. note::
    the salt for this algorithm is an integer 0-52, not a string
ÚintegerrI   z"salt/offset must be in 0..52 range)	r   r]   r#   r$   ÚExpectedTypeErrorÚmax_salt_valuer   ÚPasslibHashWarningÚ
ValueError)rR   rI   rE   r   s   &&& r   rN   Úcisco_type7._norm_saltV  s€   € ô ˜$¤×$Ò$Ü—&‘&×*Ñ*¨4°¸FÓCÐCØ�Ö*˜×*Ñ*Õ*ØˆKð +à2ˆßÜ�”b×+Ñ+Ô,Ø˜qœ�1Ð8 c×&8Ñ&8Ð8Ü˜‹oÐr4   c                 óB   € \         P                  P                  ^ ^4      # )é    )r#   ÚrngÚrandintr   r4   r   rQ   Úcisco_type7._generate_saltg  s   € ä�v‰v�~‰~˜a Ó$Ð$r4   c                ó@   € R V P                   V P                  3,          # )z%02d%srZ   )r-   s   &r   Ú	to_stringÚcisco_type7.to_stringk  s   € Ø˜4Ÿ9™9 d§m¡mÐ4Õ4Ð4r4   c                óÒ   € \        V\        4      '       d   VP                  R 4      p\        V P	                  WP
                  4      4      P                  R4      P                  4       # )r   r   )r   r   r   r   Ú_cipherrI   r,   r^   )r-   r.   s   &&r   r2   Úcisco_type7._calc_checksumn  sK   € ô �fœc×"Ò"Ø—]‘] 7Ó+ˆFÜ�t—|‘| F¯I©IÓ6Ó7×>Ñ>¸wÓG×MÑMÓOÐOr4   c                óØ   € V P                  V4      p\        VP                  P                  R4      4      pVP	                  WCP
                  4      pV'       d   VP                  V4      # T# )z¨decode hash, returning original password.

:arg hash: encoded password
:param encoding: optional encoding to use (defaults to ``UTF-8``).
:returns: password as unicode
r   )r_   r   r[   r   ru   rI   r,   )rR   rX   Úencodingr-   ÚtmpÚraws   &&&   r   r,   Úcisco_type7.decodeu  sS   € ð �‰˜tÓ$ˆÜ˜Ÿ™×,Ñ,¨WÓ5Ó6ˆØ�l‰l˜3§	¡	Ó*ˆß'/ˆs�z‰z˜(Ó#Ð8°SÐ8r4   z5dsfd;kfoA,.iyewrkldJKDHSUBsgvca69834ncxv9873254k;fg87c                ó&   <€ V ^8„  d   QhRS[ RS[/# )rY   ÚdatarI   )r)   r]   )ÚformatrA   s   "€r   Ú__annotate__Úcisco_type7.__annotate__†  s   ø€ ÷ 
ñ 
™5ð 
©ñ 
r4   c                óv   aaa€ V P                   o\        S4      o\        VVV3R l\        V4       4       4      # )z1xor static key against data - encrypts & decryptsc              3   óv   <"  € T F.  w  rV\        SSV,           S,          ,          4      ,          x € K0  	  R # 5irG   )Úord)r   ÚidxÚvalueÚkeyÚkey_sizerI   s   &  €€€r   r   Ú&cisco_type7._cipher.<locals>.<genexpr>Š  s1   øé € ð 
ÙHW¹*¸#ˆE”C˜˜T C�Z¨8Õ3Õ4Ó5×5Ò5Ëùs   ƒ69)Ú_keyr   r)   r*   )rR   r}   rI   r†   r‡   s   &&f@@r   ru   Úcisco_type7._cipher…  s6   ú€ ð �h‰hˆÜ�s“8ˆÜö 
ÜHQÐRVÌó
ó 
ð 	
r4   rH   rG   )F)r   )r5   r6   r7   r8   r9   r"   Úsetting_kwdsr#   ÚUPPER_HEX_CHARSr>   Úmin_salt_valuerh   ÚclassmethodrM   r_   rb   rN   rP   rQ   rr   r2   r,   r‰   ru   r?   r@   Ú__classcell__)rU   rA   s   @@r   r   r   	  sÁ   ù‡ € ñð@ €DØ€Lð
 ×'Ñ'€Nð €NØ€Nàöó ðð ñ9ó ð9÷	ð óó ðð  ñ%ó ð%ò5òPð ó
9ó ð
9ð C€Dà÷
ó ÷
ð 
r4   )r
   r   r   s    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ)r9   Úbinasciir   r   Úhashlibr   Úwarningsr   Úpasslib.utils.handlersÚutilsÚhandlersr#   Úpasslib.utilsr   r   r   Úpasslib.utils.binaryr	   Ú__all__r&   ÚHasUserContextÚStaticHandlerr
   r   ÚGenericHandlerr   r   r4   r   Ú<module>rœ      sl   ðÙ ç 'Ý Ý ç #Ð #ß EÑ EÝ $ò€ð €ôz8�×!Ñ! 2×#3Ñ#3ô z8ôX$�	ô $ôNC
�"×#Ñ#ö C
r4   