(password)
return k
Generate DES key schedule from ASCII password.
Generate DES key schedule from ASCII password.
Generate DES key schedule from ASCII password .
def _set_key(password):
    """Generate DES key schedule from ASCII password."""

    c,d = struct.unpack('<ii', password)
    c = (c & 0x7f7f7f7f) << 1
    d = (d & 0x7f7f7f7f) << 1

    d,c = _PERM_OP(d,c,4,0x0f0f0f0f)
    c = _HPERM_OP(c)
    d = _HPERM_OP(d)
    d,c = _PERM_OP(d,c,1,0x55555555)
    c,d = _PERM_OP(c,d,8,0x00ff00ff)
    d,c = _PERM_OP(d,c,1,0x55555555)

    # Any sign-extended bits are masked off.
    d = (((d & 0x000000ff) << 16) | (d & 0x0000ff00) |
         ((d & 0x00ff0000) >> 16) | ((c >> 4) & 0x0f000000))
    c = c & 0x0fffffff

    # Copy globals into local variables for loop.
    shifts2 = _shifts2
    skbc0, skbc1, skbc2, skbc3, skbd0, skbd1, skbd2, skbd3 = _skb

    k = [0] * (_ITERATIONS * 2)

    for i in xrange(_ITERATIONS):
        # Only operates on top 28 bits.
        if shifts2[i]:
            c = (c >> 2) | (c << 26)
            d = (d >> 2) | (d << 26)
        else:
            c = (c >> 1) | (c << 27)
            d = (d >> 1) | (d << 27)
        c = c & 0x0fffffff
        d = d & 0x0fffffff

        s = ( skbc0[  c      & 0x3f                    ] |
              skbc1[((c>> 6) & 0x03) | ((c>> 7) & 0x3c)] |
              skbc2[((c>>13) & 0x0f) | ((c>>14) & 0x30)] |
              skbc3[((c>>20) & 0x01) |
                    ((c>>21) & 0x06) | ((c>>22) & 0x38)] )

        t = ( skbd0[  d      & 0x3f                    ] |
              skbd1[((d>> 7) & 0x03) | ((d>> 8) & 0x3c)] |
              skbd2[((d>>15) & 0x3f)                   ] |
              skbd3[((d>>21) & 0x0f) | ((d>>22) & 0x30)] )

        k[2*i] = ((t << 16) | (s & 0x0000ffff)) & 0xffffffff
        s = (s >> 16) | (t & 0xffff0000)

        # Top bit of s may be 1.
        s = (s << 4) | ((s >> 28) & 0x0f)
        k[2*i + 1] = s & 0xffffffff

    return k
def _set_key ( password ) : c , d = struct . unpack ( '<ii' , password ) c = ( c & 0x7f7f7f7f ) << 1 d = ( d & 0x7f7f7f7f ) << 1 d , c = _PERM_OP ( d , c , 4 , 0x0f0f0f0f ) c = _HPERM_OP ( c ) d = _HPERM_OP ( d ) d , c = _PERM_OP ( d , c , 1 , 0x55555555 ) c , d = _PERM_OP ( c , d , 8 , 0x00ff00ff ) d , c = _PERM_OP ( d , c , 1 , 0x55555555 ) # Any sign-extended bits are masked off. d = ( ( ( d & 0x000000ff ) << 16 ) | ( d & 0x0000ff00 ) | ( ( d & 0x00ff0000 ) >> 16 ) | ( ( c >> 4 ) & 0x0f000000 ) ) c = c & 0x0fffffff # Copy globals into local variables for loop. shifts2 = _shifts2 skbc0 , skbc1 , skbc2 , skbc3 , skbd0 , skbd1 , skbd2 , skbd3 = _skb k = [ 0 ] * ( _ITERATIONS * 2 ) for i in xrange ( _ITERATIONS ) : # Only operates on top 28 bits. if shifts2 [ i ] : c = ( c >> 2 ) | ( c << 26 ) d = ( d >> 2 ) | ( d << 26 ) else : c = ( c >> 1 ) | ( c << 27 ) d = ( d >> 1 ) | ( d << 27 ) c = c & 0x0fffffff d = d & 0x0fffffff s = ( skbc0 [ c & 0x3f ] | skbc1 [ ( ( c >> 6 ) & 0x03 ) | ( ( c >> 7 ) & 0x3c ) ] | skbc2 [ ( ( c >> 13 ) & 0x0f ) | ( ( c >> 14 ) & 0x30 ) ] | skbc3 [ ( ( c >> 20 ) & 0x01 ) | ( ( c >> 21 ) & 0x06 ) | ( ( c >> 22 ) & 0x38 ) ] ) t = ( skbd0 [ d & 0x3f ] | skbd1 [ ( ( d >> 7 ) & 0x03 ) | ( ( d >> 8 ) & 0x3c ) ] | skbd2 [ ( ( d >> 15 ) & 0x3f ) ] | skbd3 [ ( ( d >> 21 ) & 0x0f ) | ( ( d >> 22 ) & 0x30 ) ] ) k [ 2 * i ] = ( ( t << 16 ) | ( s & 0x0000ffff ) ) & 0xffffffff s = ( s >> 16 ) | ( t & 0xffff0000 ) # Top bit of s may be 1. s = ( s << 4 ) | ( ( s >> 28 ) & 0x0f ) k [ 2 * i + 1 ] = s & 0xffffffff return k