# Path: crysp/utils/operators.py
# def ror(x,n):
#     return (x>>n | x<<(x.size-n))
# 
# def rol(x,n):
#     return (x<<n | x>>(x.size-n))
# 
# def concat(L,bigend=False):
#     if len(L)==1: return L[0]
#     if bigend: L = reversed(L)
#     return reduce(lambda x,y: x//y, L)


from crysp.bits import *
from crysp.utils.operators import ror,rol,concat
# This code is part of crysp
# Copyright (C) 2009 Axel Tillequin (bdcht3@gmail.com)
# published under GPLv2 license


# -----------------------------------------------------------------------------
# Serpent-1 block cipher primitive
class Serpent(object):
    size = 128
    blocksize = 128


# Path: crysp/utils/operators.py
# def ror(x,n):
#     return (x>>n | x<<(x.size-n))
# 
# def rol(x,n):
#     return (x<<n | x>>(x.size-n))
# 
# def concat(L,bigend=False):
#     if len(L)==1: return L[0]
#     if bigend: L = reversed(L)
#     return reduce(lambda x,y: x//y, L)


# Path: crysp/serpent.py
from crysp.bits import *
from crysp.utils.operators import ror,rol,concat

# This code is part of crysp
# Copyright (C) 2009 Axel Tillequin (bdcht3@gmail.com)
# published under GPLv2 license


# -----------------------------------------------------------------------------
# Serpent-1 block cipher primitive
class Serpent(object):
    size = 128
    blocksize = 128


    def __init__(self,K):