ó
øÐLac           @   s  d  Z  d d l Z d d l m Z d d l m Z m Z m Z m Z m Z d d g Z	 d Z
 d Z d	 Z d
 Z d Z d Z e a a a a d „  Z d „  Z e j d ƒ Z d „  Z d „  Z d „  Z d „  Z e d d d ƒ Z d „  Z d „  Z d d d „ Z  d d d „ Z! d S(   s£  passlib.crypto.des -- DES block encryption routines

History
=======
These routines (which have since been drastically modified for python)
are based on a Java implementation of the des-crypt algorithm,
found at `<http://www.dynamic.net.au/christos/crypt/UnixCrypt2.txt>`_.

The copyright & license for that source is as follows::

    UnixCrypt.java 0.9 96/11/25
    Copyright (c) 1996 Aki Yoshida. All rights reserved.
    Permission to use, copy, modify and distribute this software
    for non-commercial or commercial purposes and without fee is
    hereby granted provided that this copyright notice appears in
    all copies.

    ---

    Unix crypt(3C) utility
    @version 0.9, 11/25/96
    @author  Aki Yoshida

    ---

    modified April 2001
    by Iris Van den Broeke, Daniel Deville

    ---
    Unix Crypt.
    Implements the one way cryptography used by Unix systems for
    simple password protection.
    @version $Id: UnixCrypt2.txt,v 1.1.1.1 2005/09/13 22:20:13 christos Exp $
    @author Greg Wilkins (gregw)

The netbsd des-crypt implementation has some nice notes on how this all works -
    http://fxr.googlebit.com/source/lib/libcrypt/crypt.c?v=NETBSD-CURRENT
iÿÿÿÿN(   t   exc(   t   join_byte_valuest   byte_elem_valuet   irangeR   t	   int_typest   expand_des_keyt   des_encrypt_blockiÿÿÿ Iÿÿÿÿÿÿÿ l   ÿÿÿÿ l   þ~ý}û{÷w Il   ÿÿósçg c       G   C   sf  dîdïdðdñdòdódôdõdöd÷dødùdúdûdüdýf }  dþdÿd ddddddddd	d
dddf } ddddddddddddddddf } |  | f | | f | | f | | f | | f | | f | | f | | f f a  ddd d!d"d#d$d%f a d&d'd(d)d*d+d,d-f a d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=f a díS(>  s3   delay loading tables until they are actually neededi    i    i    i    i   i $  i   i $  I        I       I       I     €  I     €  I    €  I    €  I       I       I      I      I     € I     € I    € I    € i@   i    i@   i    i@   i    i@   I       I       I      I       I      I       	I      	I       @I      @I       HI      HI       AI      AI       II      Ii   I       I      i   i  I      I     I     @  I       I     @ I      € I     @€ I      €I     @€I    €   I    €@  I    €  I    €@ I    € € I    €@€ I    € €I    €@€i   i   i  i   @i   Pi  @i  PI       I       I      I       I      I      I     I       I      I      I     I      I     I     I    i€   i   i€  i  € i€ € i  ˆ i€ ˆ i   I        I       I       I      I       I      I        I       I        I       I     0  I    0  I     0  I    0  i  @ i   i  @i   i @ i  i @i €  I      @ I €    @ I    @   I €  @   I    @ @ I €  @ @ l            l           l           l          l           l          l          l         i @  i   i@  i   i@  i   i@  I       I       I      I       I      I      I     I        I       I      ! I     ! I       I      I      !I     !I       I       I      i   I      I      I     I   €    I       I   €   I       I   €   I      I   €  I       I   €   I      I   €  I      I   €  I     I   € i   I      i (  I       I (     i  I      I     i   i ( I      I (    I  €    I   €   I  @    I  @€    I  @€   I      I   ˆ    I   ˆ   i  @I  @   I  @ˆ    I  @ˆ   i@  i  i   i€  i  i  @i  @i @i€  @i  @i€ @i @i   i   i$   i$  I      I       I      I      I     I$      I$     i€  I      I €     I€     I       I €      I€      I      0 I     0 I €    0 I€    0 I     H  I     P  I       I     X  I     @ @I      @I     H @I      @I     P @I      @I     X @i @  I @     I       I @     I @     I       I @     I      I @    I      I @    I      I       I      I      I      I     I      I     I      I     I      @ I    € @ I    €   I    € @ I     @ I       I     @ I       I     @ I       I     @ l            I       l       €    l       €    I       l           l          ( I       I       l       €   l       €  ( I     € I    @€  I    @  I    @€ I      I    € I    D   I    D€  I    D  I    D€ I     € I      ˆ I      I     ˆ I      € I     $  I     $€ I       I      ˆ I     $ I     $ˆ i  i @€ I  €€    I @ €    I @€€    i  „ i @ i @„ I  €    I  „€    I @€    I @„€    i  @I       i€   I€      I€      i   I      I      i€  i€  I€     I€     I       I      I      I     i  I      I     i  i I     I    i  I@      I       I@      i@€  I €     I@€     i €  i@€  I €     I@€     i   I      I      I      l           l           l           l           l           l           I      I       I      I      
 I      I      
I      I      
I      I      
i  @ I  @   @ I      @ I  @   @ I  @    I       I  @    I      @I  @   @I      @I  @   @I      € I    € € I        I    €   I    €   I        I        I    €   I    €   I       I       @I      @I      @I     @  I     D  I     D  I     @ @I     D @I     D @I    @   I    @  I     (  I    @(  I        I    @   I     ˆ  I    @ˆ  I     ¨  I    @¨  I       I      I      I      I      I      I      I     I     I     I      I      I      I     I      I       I      I     I      I     i € iˆ€ I   €   I €€   I€ €   Iˆ€€   I  €    I ˆ€    I€€    Iˆˆ€    I  ˆ€   I ˆˆ€   I€ˆ€   Iˆˆˆ€   I     € I    €  I    ˆ€ I€      I€    €I€   € I€   ˆ€l         @  l         @ l         D  l         D l   €     @@ l   €     @D l   €     D@ l   €     DD i  i i  i  i i  i i iI      I      I     I      I     I      I     I     I    i    i    i    i    i    i    i    i    i    I        I        I        I        I        I        I        I        I        i@  I@      ID@     i  @i@@I@ @   ID@@   i @ iD@ I@@    IDD@    i D@iDD@I@D@   IDDD@   I    @  I   @   I   D@  I      @I    @@I   @ @I   D@@I     @ I    D@ I   @@ I   DD@ I     D@I    DD@I   @D@I   DDD@I   €€ I   €€ I   €€ I   €   I   €   I     € I     € I     € I   €€ I   €   I@ € I   €  i@ I@     I    € I@  €  I@    I      I@ €  I@  € I   € i@ I @@  I@    I  @   I   @  I @    I @@   I@@  I      I@@   I  @  I€ @  I      I€@  i @I€    I€ @   I @   I€     I€     I€@   I  @   I € @ I €    I €  @ I    @ I €    I €     I    @ I €  @ I € @ I     @ I€    @I      @I€      I€    @I      @I€    @I        I€      i€  I      @I€    @I       I@     I@  @ I@   @ I    @  I@     I@      I   @  I   @  I@  @ I@   @ l       @  I  €    l       € @  I        l       @  I  €    l      ‚ @  I  €    l      ‚ @  l       € @  l         @  I      I      I      I     I      I      I     I     I     I    i   i   i  i   i  i  i i   i  i  i i  i i iI    €€  I     €€ I    €€€ l           l           l          l           l          l          l         I      I      I      I     I      I      I     I      I     I     I    i€€  i €€ i€€€ I€  €    I € €    I€€ €    I€ €€    I €€€    I€€€€    i  i  i  i i  i  i i  i i iI      I      I     I      I      I     I     I     I    i   i   i  i   i  i  i i   i  i  i i  i i iI    @@  I     @@ I    @@@ I    @  @I    @@ @I      @@I    @ @@I     @@@I    @@@@I      I      I      I     I      I      I     I      I     I     I    i@@  i@ @ i @@ i@@@ i@  @i @ @i@@ @i  @@i@ @@i @@@i@@@@i  i  i i  i  i i  i i iN(   i    i    i    i    i    i    i    i    i   i   i $  i $  i   i   i $  i $  (   i    I        I       I       I     €  I     €  I    €  I    €  I       I       I      I      I     € I     € I    € I    € (   i    i    i@   i@   i    i    i@   i@   i    i    i@   i@   i    i    i@   i@   (   i    I       I       I      I       I      I       	I      	I       @I      @I       HI      HI       AI      AI       II      I(   i    i    i   i   I       I       I      I      i   i   i  i  I      I      I     I     (   i    I     @  I       I     @ I      € I     @€ I      €I     @€I    €   I    €@  I    €  I    €@ I    € € I    €@€ I    € €I    €@€(   i    i    i   i   i   i   i  i  i   @i   @i   Pi   Pi  @i  @i  Pi  P(   i    I       I       I      I       I      I      I     I       I      I      I     I      I     I     I    (   i    i    i€   i€   i   i   i€  i€  i  € i  € i€ € i€ € i  ˆ i  ˆ i€ ˆ i€ ˆ (   i    i   I        I       I       I      I       I      I        I       I        I       I     0  I    0  I     0  I    0  (   i    i    i  @ i  @ i   i   i  @i  @i   i   i @ i @ i  i  i @i @(   i    i €  I      @ I €    @ I    @   I €  @   I    @ @ I €  @ @ l            l           l           l          l           l          l          l         (   i    i    i @  i @  i   i   i@  i@  i   i   i@  i@  i   i   i@  i@  (   i    I       I       I      I       I      I      I     I        I       I      ! I     ! I       I      I      !I     !(   i    i    I       I       I       I       I      I      i   i   I      I      I      I      I     I     (   i    I   €    I       I   €   I       I   €   I      I   €  I       I   €   I      I   €  I      I   €  I     I   € (   i    i    i    i    i    i    i    i    i   i   i   i   i   i   i   i   (   i    i   I       I      i    i (  I       I (     i   i  I      I     i   i ( I      I (    (   i    i    i    i    I       I       I       I       i  € i  € i  € i  € I  €    I  €    I  €    I  €    (   i    I       I   €    I   €   i  @ I  @    I  @€    I  @€   i   I      I   ˆ    I   ˆ   i  @I  @   I  @ˆ    I  @ˆ   (   i    i    i    i    i@   i@   i@   i@   i   i   i   i   i@  i@  i@  i@  (   i    i   i   i  i€   i   i€  i  i   @i  @i  @i @i€  @i  @i€ @i @(   i    i    i    i    i   i   i   i   i   i   i   i   i   i   i   i   (   i    i   i    i   i   i  i$   i$  I       I      I       I      I      I     I$      I$     (   i    i   i €  i€  I       I      I €     I€     I        I       I €      I€      I      0 I     0 I €    0 I€    0 (   i    I     @  I       I     H  I       I     P  I       I     X  I       @I     @ @I      @I     H @I      @I     P @I      @I     X @(   i    i @  i    i @  I       I @     I       I @     I       I @     I       I @     I      I @    I      I @    (   i    I       I       I      I       I      I       I      I       I      I      I     I      I     I      I     (   i    I      @ I        I      @ I    €   I    € @ I    €   I    € @ I       I     @ I       I     @ I       I     @ I       I     @ (   i    I       l            l            I        I       l       €    l       €    I       I       l           l          ( I       I       l       €   l       €  ( (   i    I     €  I       I     € I    @   I    @€  I    @  I    @€ I       I    €  I      I    € I    D   I    D€  I    D  I    D€ (   i    I      € I       I     € I       I      ˆ I      I     ˆ I        I      € I     $  I     $€ I       I      ˆ I     $ I     $ˆ (   i    i    i    i    i   i   i   i   i   i   i   i   i  i  i  i  (   i    i  € i @  i @€ I   €    I  €€    I @ €    I @€€    i   i  „ i @ i @„ I  €    I  „€    I @€    I @„€    (   i    i    i    i    i   i   i   i   i   @i   @i   @i   @i  @i  @i  @i  @(   i    i    I       I       i€   i€   I€      I€      i   i   I      I      i€  i€  I€     I€     (   i    i    i    i    i    i    i    i    I       I       I       I       I       I       I       I       (   i    i   I       I      i   i  I      I     i   i  I      I     i  i I     I    (   i    i    i    i    i   i   i   i   i   i   i   i   i  i  i  i  (   i    i@   I       I@      i    i@   I       I@      i €  i@€  I €     I@€     i €  i@€  I €     I@€     (   i    i   i   i   I       I      I      I      l            l           l           l           l            l           l           l           (   i    I       I       I      I       I      I       I      I       I      
 I      I      
I      I      
I      I      
(   i    i  @ i    i  @ I      @ I  @   @ I      @ I  @   @ I       I  @    I       I  @    I      @I  @   @I      @I  @   @(   i    I      € I    €   I    € € I        I      € I    €   I    € € I        I        I    €   I    €   I        I        I    €   I    €   (   i    I        I       I       I       @I       @I      @I      @I     @  I     @  I     D  I     D  I     @ @I     @ @I     D @I     D @(   i    I    @   I        I    @   I       I    @  I     (  I    @(  I     €  I    @€  I        I    @   I     ˆ  I    @ˆ  I     ¨  I    @¨  (   i    I       I       I       I       I      I      I      I       I      I      I      I      I     I     I     (   i    I       I       I      I       I      I      I     I       I      I       I      I      I     I      I     (   i    i € i€  iˆ€ I   €   I €€   I€ €   Iˆ€€   I  €    I ˆ€    I€€    Iˆˆ€    I  ˆ€   I ˆˆ€   I€ˆ€   Iˆˆˆ€   (   i    I     € I    €  I    ˆ€ I€      I€    €I€   € I€   ˆ€l         @  l         @ l         D  l         D l   €     @@ l   €     @D l   €     D@ l   €     DD (   i    i   i   i  i   i  i  i i   i  i  i i  i i i(   i    I       I       I      I       I      I      I     I       I      I      I     I      I     I     I    (   i    i    i    i    i    i    i    i    i    i    i    i    i    i    i    i    (   i    I        I        I        I        I        I        I        I        I        I        I        I        I        I        I        (   i    i@  I@      ID@     i  @i@@I@ @   ID@@   i @ iD@ I@@    IDD@    i D@iDD@I@D@   IDDD@   (   i    I    @  I   @   I   D@  I      @I    @@I   @ @I   D@@I     @ I    D@ I   @@ I   DD@ I     D@I    DD@I   @D@I   DDD@(@   I   €€ I   €   i    I   €€ i    I   €€ I   €   i    I   €€ I   €€ I   €   I     € I     € i    i    I   €   I   €   i    I     € I   €€ I   €€ I   €   I     € I     € i    I     € I   €€ I   €   I     € I     € I   €   i    i    I   €€ I     € I   €   I   €€ I   €   I     € I     € I   €   I     € I   €€ i    I   €€ i    i    I   €   I   €€ I   €€ I   €   I     € i    I     € I   €   i    I   €   i    I     € I   €€ i    I   €   I     € I   €€ (@   I@ € i    I   €  i@ I@     I    € I@  €  I   €  I    €  I@    I       I@  €  I      I@ €  i@ I       i   I@  € I@    I    €  I   € i@  i    I      I@  € I   € I@ €  I@     i@  i   I    € I@ € I      I@ €  I@  €  I   € I@ € I      I@     i    i@  I    € i   I@    I    €  i@  I   € I@  € I@ €  I    €  i    I@     I       I@ € I   €  i@ I@    i   I    € I@  €  I@  € I       i@ I   €  (@   i@ I @@  I       I@    I  @   i @ I@    I   @  I @    I   @   I @@   i   I@@  I      i   I@@   i    I  @   I @@  I       I      I@@  I   @   i@ I@@   I @    I  @  I @@   I   @  i    i @ I  @  I @@  I       i   I   @   I      I  @   I @@   I@    i    I @@  I   @  I@@   I  @   i @ I@@  i   I  @  i@ i @ I@@  I   @   I @    I@    I   @  I @    i    I@@   I      i@ I  @  I       I @@   (@   I€ @  I      I€      I€@  i    i @I€    I€ @   I @   I€     i   I€     I€     I€ @  i  @i   I€@   I  @   I       I€      I  @   I€    i @I       I€     i    I€ @   I @   I      I€@   I€@  i  @I€@   I€     i  @I€     I  @   I      I€      i @I€    i    I       I€ @   i    I€@   I @   I       i   I€@  I€ @  i  @I€@  I€      I      I€ @  I€ @   I  @   i @I€    I€     i   I€     I @   (@   i € I       I     @ I € @ I €    I €  @ I    @ I €    I       I        I €     I    @ I €  @ I €    I € @ i    I    @ i € I       I     @ I €  @ I    @ i    I €     I        I €  @ I € @ I       I €    I     @ I     @ I € @ I € @ I €  @ I       I €    I       I        I €     I €  @ i € I    @ I € @ i    I    @ i € I     @ I       I €  @ I     @ i    I € @ I €    I € @ I     @ I       I    @ I €    I €  @ I     @ I        I    @ I €    I €     (@   I€    @I      @i    I€      I      @I        I€    @i    I      @I€    @I        i€  I€      I€    @i€  I      @i    I€    @I€    @i    I        I      @I€      I€    @I€    @i€  i€  I      @I      @I        I      @I€      I      @i€  I€      I      @I€      I      @i    I€      i€  I        I€    @i    I      @I€    @I        I      @I€    @I        i    I€    @I€    @i€  I      @i    I        I€    @I€    @I€      i€  I      @I      @I€    @(@   I    @  I        I       I@     I@  @ I@   @ I    @  i    i   I@     I@      I   @  I@      I   @  I   @  I@      I@     I    @  I@   @ I@  @ i    I       I@     I    @  I@  @ I@   @ I   @  I@      I@   @ I@  @ I        i   I@   @ I   @  I@  @ I@      I    @  I        i   I@  @ I@     I@   @ I    @  i    I        I@     I@      I       i    I@     I       I    @  I@      I    @  I@  @ i   I   @  I@      I@   @ I@  @ I@     I   @  I   @  I@   @ (@   l       @  I  €    l       € @  i    I        l       @  I  €    l      ‚ @  l         @  i    I  €    l       € @  l      ‚ @  l       € @  l         @  I  €    I        l      ‚ @  l       @  I        l      ‚ @  l         @  i    I  €    i    I  €    l       € @  l       @  I  €    I        I  €    l         @  I  €    I        l         @  l      ‚ @  l       € @  i    i    I  €    l       @  l       € @  I        l       @  I  €    l         @  l       @  I        l      ‚ @  I  €    I  €    l         @  I  €    l       € @  l       € @  I  €    l         @  I  €    l      ‚ @  i    i    l       @  I        l      ‚ @  (   i    I        I        I        I        I        I        I        I        I        I        I        I        I        I        I        (   i    I       I       I      I       I      I      I     I       I      I      I     I      I     I     I    (   i    i    i    i    i    i    i    i    i    i    i    i    i    i    i    i    (   i    i   i   i  i   i  i  i i   i  i  i i  i i i(   i    I    €   I     €  I    €€  I      € I    € € I     €€ I    €€€ l            l           l           l          l           l          l          l         (   i    I       I       I      I       I      I      I     I       I      I      I     I      I     I     I    (   i    i€   i €  i€€  i  € i€ € i €€ i€€€ I   €    I€  €    I € €    I€€ €    I  €€    I€ €€    I €€€    I€€€€    (   i    i   i   i  i   i  i  i i   i  i  i i  i i i(   i    I       I       I      I       I      I      I     I       I      I      I     I      I     I     I    (   i    I       I       I      I       I      I      I     I       I      I      I     I      I     I     I    (   i    i   i   i  i   i  i  i i   i  i  i i  i i i(   i    i   i   i  i   i  i  i i   i  i  i i  i i i(   i    I    @   I     @  I    @@  I      @ I    @ @ I     @@ I    @@@ I       @I    @  @I     @ @I    @@ @I      @@I    @ @@I     @@@I    @@@@(   i    I       I       I      I       I      I      I     I       I      I      I     I      I     I     I    (   i    i@   i @  i@@  i  @ i@ @ i @@ i@@@ i   @i@  @i @ @i@@ @i  @@i@ @@i @@@i@@@@(   i    i   i   i  i   i  i  i i   i  i  i i  i i i(   t   PCXROTt   IE3264t   SPEt   CF6464(   t   PC1ROTt   PC2ROTAt   PC2ROTB(    (    sM   /var/www/html/packages/venv/lib/python3.8/site-packages/passlib/crypto/des.pyt   _load_tablesQ   sH   
                                                	                                                	                                                		                        	                                                                                                                        		                                                c         C   s7   d } x* | D]" } | | |  d @O} |  d L}  q W| S(   sd   Returns the permutation of the given 32-bit or 64-bit code with
    the specified permutation table.i    i   i   (    (   t   ct   pt   outt   r(    (    sM   /var/www/html/packages/venv/lib/python3.8/site-packages/passlib/crypto/des.pyt   _permute9  s
    s   >Qc         C   s   t  j |  ƒ S(   N(   t   _uint64_structt   pack(   t   value(    (    sM   /var/www/html/packages/venv/lib/python3.8/site-packages/passlib/crypto/des.pyt   _pack64J  s    c         C   s   t  j |  ƒ d S(   Ni    (   R   t   unpack(   R   (    (    sM   /var/www/html/packages/venv/lib/python3.8/site-packages/passlib/crypto/des.pyt	   _unpack64M  s    c         C   s   t  j |  ƒ d S(   Ni   (   R   R   (   R   (    (    sM   /var/www/html/packages/venv/lib/python3.8/site-packages/passlib/crypto/des.pyt   _pack56P  s    c         C   s   t  j d |  ƒ d S(   Ns    i    (   R   R   (   R   (    (    sM   /var/www/html/packages/venv/lib/python3.8/site-packages/passlib/crypto/des.pyt	   _unpack56S  s    i1   iùÿÿÿc            sº   t  ˆ  t ƒ r3 t ˆ  ƒ d k r” t d ƒ ‚ q” na t  ˆ  t ƒ r ˆ  d k  sZ ˆ  t k ri t d ƒ ‚ n  t t t ˆ  ƒ ƒ ƒ St	 j
 ˆ  d d ƒ ‚ t ˆ  ƒ ‰  t ‡  f d †  t Dƒ ƒ S(   sD   convert DES from 7 bytes to 8 bytes (by inserting empty parity bits)i   s   key must be 7 bytes in sizei    s'   key must be 56-bit non-negative integers   bytes or intt   keyc         3   s!   |  ] } ˆ  | ?d  @d >Vq d S(   i   i   N(    (   t   .0t   shift(   R   (    sM   /var/www/html/packages/venv/lib/python3.8/site-packages/passlib/crypto/des.pys	   <genexpr>u  s    (   t
   isinstancet   bytest   lent
   ValueErrorR   t   INT_56_MASKR   R   R   R    t   ExpectedTypeErrorR   R   t   _EXPAND_ITER(   R   (    (   R   sM   /var/www/html/packages/venv/lib/python3.8/site-packages/passlib/crypto/des.pyR   c  s    c         C   sù   t  |  t ƒ rF t |  ƒ d k r0 t d ƒ ‚ n  t t t |  ƒ ƒ ƒ St  |  t ƒ r |  d k  sm |  t k r” t d ƒ ‚ q” n t	 j
 |  d d ƒ ‚ |  d L}  d } d } x6 | d k  râ | |  d	 @| >O} |  d L}  | d
 7} q­ W| t @sõ t ‚ | S(   sG   convert DES key from 8 bytes to 7 bytes (by discarding the parity bits)i   s   key must be 8 bytes in sizei    s'   key must be 64-bit non-negative integers   bytes or intR   i   i8   i   i   (   R   R    R!   R"   R   t   shrink_des_keyR   R   t   INT_64_MASKR    R$   t   AssertionError(   R   t   resultt   offset(    (    sM   /var/www/html/packages/venv/lib/python3.8/site-packages/passlib/crypto/des.pyR&   w  s"    

i    i   c         C   sè   t  |  t ƒ r` t |  ƒ d k r0 t |  ƒ }  n! t |  ƒ d k rQ t d ƒ ‚ n  t |  ƒ }  n t j |  d d ƒ ‚ t  | t ƒ r´ t | ƒ d k r¥ t d ƒ ‚ n  t | ƒ } n t j | d d ƒ ‚ t |  | | | ƒ } t	 | ƒ S(   s£  encrypt single block of data using DES, operates on 8-byte strings.

    :arg key:
        DES key as 7 byte string, or 8 byte string with parity bits
        (parity bit values are ignored).

    :arg input:
        plaintext block to encrypt, as 8 byte string.

    :arg salt:
        Optional 24-bit integer used to mutate the base DES algorithm in a
        manner specific to :class:`~passlib.hash.des_crypt` and its variants.
        The default value ``0`` provides the normal (unsalted) DES behavior.
        The salt functions as follows:
        if the ``i``'th bit of ``salt`` is set,
        bits ``i`` and ``i+24`` are swapped in the DES E-box output.

    :arg rounds:
        Optional number of rounds of to apply the DES key schedule.
        the default (``rounds=1``) provides the normal DES behavior,
        but :class:`~passlib.hash.des_crypt` and its variants use
        alternate rounds values.

    :raises TypeError: if any of the provided args are of the wrong type.
    :raises ValueError:
        if any of the input blocks are the wrong size,
        or the salt/rounds values are out of range.

    :returns:
        resulting 8-byte ciphertext block.
    i   i   s   key must be 7 or 8 bytesR    R   s   input block must be 8 bytest   input(
   R   R    R!   R   R"   R   R    R$   t   des_encrypt_int_blockR   (   R   R+   t   saltt   roundsR)   (    (    sM   /var/www/html/packages/venv/lib/python3.8/site-packages/passlib/crypto/des.pyR     s    !c         C   sœ  | d k  r t  d ƒ ‚ n  | d k  s3 | t k rB t  d ƒ ‚ n  t |  t ƒ si t j |  d d ƒ ‚ n' |  d k  s |  t k r t  d ƒ ‚ n  t | t ƒ s· t j | d d ƒ ‚ n' | d k  sÏ | t k rÞ t  d	 ƒ ‚ n  t d$ k rô t	 ƒ  n  t
 \ } } } } } }	 }
 } d
 „  } t | |  ƒ ƒ } | d @d >| d @d >B| d @d ?B| d @d ?B} | d k rxd } } nN | d ?d @| d @B} t | t ƒ } | d ?d @| d ?d @B} t | t ƒ } x”| r\| d 8} xp| D]h\ } } | d ?| A| @} | d >| A| A| A} | | | d ?d @| | d ?d @A| | d ?d @A| | d ?d @A| | d ?d @A|	 | d ?d @A|
 | d ?d @A| | d ?d @AN} | d ?| A| @} | d >| A| A| A} | | | d ?d @| | d ?d @A| | d ?d @A| | d ?d @A| | d ?d @A|	 | d ?d @A|
 | d ?d @A| | d ?d @AN} qàW| | } } qÉW| d ?d @| d >d  @B| d! ?d" @B| d >d# @B} t | t ƒ S(%   s­  encrypt single block of data using DES, operates on 64-bit integers.

    this function is essentially the same as :func:`des_encrypt_block`,
    except that it operates on integers, and will NOT automatically
    expand 56-bit keys if provided (since there's no way to detect them).

    :arg key:
        DES key as 64-bit integer (the parity bits are ignored).

    :arg input:
        input block as 64-bit integer

    :arg salt:
        optional 24-bit integer used to mutate the base DES algorithm.
        defaults to ``0`` (no mutation applied).

    :arg rounds:
        optional number of rounds of to apply the DES key schedule.
        defaults to ``1``.

    :raises TypeError: if any of the provided args are of the wrong type.
    :raises ValueError:
        if any of the input blocks are the wrong size,
        or the salt/rounds values are out of range.

    :returns:
        resulting ciphertext as 64-bit integer.
    i   s   rounds must be positive integeri    s(   salt must be 24-bit non-negative integert   intR   s'   key must be 64-bit non-negative integerR+   s)   input must be 64-bit non-negative integerc         s   sL   xE t  D]= \ } } t |  | ƒ } t | | ƒ }  | t @|  t @f Vq Wd S(   sC   given 64-bit key, iterates over the 8 (even,odd) key schedule pairsN(   R   R   t   _KS_MASK(   t   ks_oddt   p_event   p_oddt   ks_even(    (    sM   /var/www/html/packages/venv/lib/python3.8/site-packages/passlib/crypto/des.pyt   _iter_key_schedule  s    i?   i   iÀ  i   i ð i   i  ü i   i   Iªªªª    iUUUUi    i:   i2   i*   i"   i   i
   i   I    i!   l       ÀC‡ i#   iIðððð    N(   R"   t   INT_24_MASKR   R   R    R$   R'   R   t   NoneR   R	   t   listR   R   R
   (   R   R+   R-   R.   t   SPE0t   SPE1t   SPE2t   SPE3t   SPE4t   SPE5t   SPE6t   SPE7R5   t   ks_listt   Lt   RR4   R1   t   kt   Bt   C(    (    sM   /var/www/html/packages/venv/lib/python3.8/site-packages/passlib/crypto/des.pyR,   Ç  sP    "
	#	
ƒ‡#("   t   __doc__t   structt   passlibR    t   passlib.utils.compatR   R   R   R   t   __all__R6   R#   R'   t   _KDATA_MASKt   _KPARITY_MASKR0   R7   R   R   R	   R
   R   R   t   StructR   R   R   R   R   R%   R   R&   R   R,   (    (    (    sM   /var/www/html/packages/venv/lib/python3.8/site-packages/passlib/crypto/des.pyt   <module>&   s2   	(		ÿ é							8