# Path: crysp/poly.py
# class Poly(SubPoly):
# 
#   def __getitem__(self,i):
#       if isinstance(i,int):
#           return Poly(self.ival[i],self.size)
#       elif isinstance(i,slice):
#           return Poly(self.span(i),self.size)
#       else:
#           return Poly([self.ival[j] for j in i],self.size)
# 
# Path: crysp/salsa20.py
# class Salsa20(object):
#     def __init__(self,K=None,rounds=20):
#     def hash(self,m):
#     def keystream(self,v):
#     def enc(self,v,m):
#     def dec(self,v,c):
#     def quarterround(self,y):
#     def rowround(self,y):
#     def columnround(self,x):
#     def doubleround(self,x):
#     def core(self,X,dround=10):
#         L = Bits(m,bitorder=1).split(32)
#         X = Poly([x.int() for x in L],size=32)
#         C = []
#         Z = X
#             Z = self.doubleround(Z)


from crysp.bits import *
from crysp.poly import Poly
from crysp.utils.operators import *
from crysp import salsa20
# -*- coding: utf-8 -*-

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


cM    = salsa20.rMinv
cMinv = salsa20.rM
rM    = [0,5,10,15,1,6,11,12,2,7,8,13,3,4,9,14]
rMinv = [rM.index(x) for x in range(16)]

class Chacha(salsa20.Salsa20):

    def __init__(self,K=None,rounds=8):
        super().__init__(K,rounds)
        # modified init from Salsa20 to Chacha:
        if K is not None:
            consts = self.p[0,5,10,15]

# Path: crysp/poly.py
# class Poly(SubPoly):
# 
#   def __getitem__(self,i):
#       if isinstance(i,int):
#           return Poly(self.ival[i],self.size)
#       elif isinstance(i,slice):
#           return Poly(self.span(i),self.size)
#       else:
#           return Poly([self.ival[j] for j in i],self.size)
# 
# Path: crysp/salsa20.py
# class Salsa20(object):
#     def __init__(self,K=None,rounds=20):
#     def hash(self,m):
#     def keystream(self,v):
#     def enc(self,v,m):
#     def dec(self,v,c):
#     def quarterround(self,y):
#     def rowround(self,y):
#     def columnround(self,x):
#     def doubleround(self,x):
#     def core(self,X,dround=10):
#         L = Bits(m,bitorder=1).split(32)
#         X = Poly([x.int() for x in L],size=32)
#         C = []
#         Z = X
#             Z = self.doubleround(Z)


# Path: crysp/chacha.py
from crysp.bits import *
from crysp.poly import Poly
from crysp.utils.operators import *
from crysp import salsa20

# -*- coding: utf-8 -*-

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


cM    = salsa20.rMinv
cMinv = salsa20.rM
rM    = [0,5,10,15,1,6,11,12,2,7,8,13,3,4,9,14]
rMinv = [rM.index(x) for x in range(16)]

class Chacha(salsa20.Salsa20):

    def __init__(self,K=None,rounds=8):
        super().__init__(K,rounds)
        # modified init from Salsa20 to Chacha:
        if K is not None:
            consts = self.p[0,5,10,15]

            self.p = Poly(0,size=32,dim=16)