Ejemplo n.º 1
0
    def __init__(self,
                 key=None,
                 padding=padWithPadLen(),
                 keySize=16,
                 blockSize=16,
                 tapRound=6,
                 extraRounds=6):
        """ key, keysize, blockSize same as Rijndael, tapROund is feedback tap, """
        self.tapRound = tapRound  # <------- !!! change from Rijndael !!!
        self.extraRounds = extraRounds  # <------- !!! change from Rijndael !!!
        self.name = 'ICEDOLL'
        self.keySize = keySize
        self.strength = keySize
        self.blockSize = blockSize  # blockSize is in bytes
        self.padding = padding  # change default to noPadding() to get normal ECB behavior

        assert (keySize % 4 == 0 and NrTable[4].has_key(
            keySize / 4)), 'key size must be 16,20,24,29 or 32 bytes'
        assert (blockSize % 4 == 0 and NrTable.has_key(
            blockSize / 4)), 'block size must be 16,20,24,29 or 32 bytes'

        self.Nb = self.blockSize / 4  # Nb is number of columns of 32 bit words
        self.Nk = keySize / 4  # Nk is the key length in 32-bit words
        self.Nr = NrTable[self.Nb][
            self.Nk] + extraRounds  # <------- !!! change from Rijndael !!!

        if key != None:
            self.setKey(key)
Ejemplo n.º 2
0
    def __init__(self, key = None, padding = padWithPadLen(), keySize=16):
        """ Initialize AES, keySize is in bytes """
        if  not (keySize == 16 or keySize == 24 or keySize == 32) :
            raise BadKeySizeError, 'Illegal AES key size, must be 16, 24, or 32 bytes'

        Rijndael.__init__( self, key, padding=padding, keySize=keySize, blockSize=16 )

        self.name       = 'AES'
Ejemplo n.º 3
0
    def __init__(self, key=None, padding=padWithPadLen(), keySize=16):
        """ Initialize AES, keySize is in bytes """
        if not (keySize == 16 or keySize == 24 or keySize == 32):
            raise BadKeySizeError, 'Illegal AES key size, must be 16, 24, or 32 bytes'

        Rijndael.__init__(self,
                          key,
                          padding=padding,
                          keySize=keySize,
                          blockSize=16)

        self.name = 'AES'
Ejemplo n.º 4
0
 def __init__(self, blockCipherInstance, padding = padWithPadLen()):
     """ CBC algorithms are created by initializing with a BlockCipher instance """
     self.baseCipher = blockCipherInstance
     self.name       = self.baseCipher.name + '_CBC'
     self.blockSize  = self.baseCipher.blockSize
     self.keySize    = self.baseCipher.keySize
     self.padding    = padding
     self.baseCipher.padding = noPadding()   # baseCipher should NOT pad!!
     self.r          = Random()            # for IV generation, currently uses
                                           # mediocre standard distro version     <----------------
     import time
     newSeed = time.ctime()+str(self.r)    # seed with instance location
     self.r.seed(newSeed)                  # to make unique
     self.reset()
Ejemplo n.º 5
0
 def __init__(self, blockCipherInstance, padding = padWithPadLen()):
     """ CBC algorithms are created by initializing with a BlockCipher instance """
     self.baseCipher = blockCipherInstance
     self.name       = self.baseCipher.name + '_CBC'
     self.blockSize  = self.baseCipher.blockSize
     self.keySize    = self.baseCipher.keySize
     self.padding    = padding
     self.baseCipher.padding = noPadding()   # baseCipher should NOT pad!!
     self.r          = Random()            # for IV generation, currently uses
                                           # mediocre standard distro version     <----------------
     import time
     newSeed = time.ctime()+str(self.r)    # seed with instance location
     self.r.seed(newSeed)                  # to make unique
     self.reset()
Ejemplo n.º 6
0
    def __init__(self, key=None, padding=padWithPadLen(), keySize=16, blockSize=16):
        self.name = 'RIJNDAEL'
        self.keySize = keySize
        self.strength = keySize * 8
        self.blockSize = blockSize  # blockSize is in bytes
        self.padding = padding  # change default to noPadding() to get normal ECB behavior

        assert (keySize % 4 == 0 and NrTable[4].has_key(keySize / 4)), 'key size must be 16,20,24,29 or 32 bytes'
        assert (blockSize % 4 == 0 and NrTable.has_key(blockSize / 4)), 'block size must be 16,20,24,29 or 32 bytes'

        self.Nb = self.blockSize / 4  # Nb is number of columns of 32 bit words
        self.Nk = keySize / 4  # Nk is the key length in 32-bit words
        self.Nr = NrTable[self.Nb][self.Nk]  # The number of rounds (Nr) is a function of
        # the block (Nb) and key (Nk) sizes.
        if key != None:
            self.setKey(key)
Ejemplo n.º 7
0
    def __init__(self,key=None,padding=padWithPadLen(),keySize=16,blockSize=16,tapRound=6,extraRounds=6):
        """ key, keysize, blockSize same as Rijndael, tapROund is feedback tap, """
        self.tapRound    = tapRound     # <------- !!! change from Rijndael !!!
        self.extraRounds = extraRounds  # <------- !!! change from Rijndael !!!
        self.name        = 'ICEDOLL'
        self.keySize     = keySize
        self.strength    = keySize
        self.blockSize   = blockSize  # blockSize is in bytes
        self.padding     = padding    # change default to noPadding() to get normal ECB behavior

        assert( keySize%4==0 and NrTable[4].has_key(keySize/4)),'key size must be 16,20,24,29 or 32 bytes'
        assert( blockSize%4==0 and NrTable.has_key(blockSize/4)), 'block size must be 16,20,24,29 or 32 bytes'

        self.Nb = self.blockSize/4          # Nb is number of columns of 32 bit words
        self.Nk = keySize/4                 # Nk is the key length in 32-bit words
        self.Nr = NrTable[self.Nb][self.Nk]+extraRounds # <------- !!! change from Rijndael !!!

        if key != None:
            self.setKey(key)
Ejemplo n.º 8
0
    def __init__(self,
                 key=None,
                 padding=padWithPadLen(),
                 keySize=16,
                 blockSize=16):
        self.name = 'RIJNDAEL'
        self.keySize = keySize
        self.strength = keySize * 8
        self.blockSize = blockSize  # blockSize is in bytes
        self.padding = padding  # change default to noPadding() to get normal ECB behavior

        assert (keySize % 4 == 0 and NrTable[4].has_key(
            keySize / 4)), 'key size must be 16,20,24,29 or 32 bytes'
        assert (blockSize % 4 == 0 and NrTable.has_key(
            blockSize / 4)), 'block size must be 16,20,24,29 or 32 bytes'

        self.Nb = self.blockSize / 4  # Nb is number of columns of 32 bit words
        self.Nk = keySize / 4  # Nk is the key length in 32-bit words
        self.Nr = NrTable[self.Nb][
            self.Nk]  # The number of rounds (Nr) is a function of
        # the block (Nb) and key (Nk) sizes.
        if key != None:
            self.setKey(key)
Ejemplo n.º 9
0
 def __init__(self, key=None, padding=padWithPadLen(), keySize=16):
     CBC.__init__(self, AES(key, noPadding(), keySize), padding)
     self.name = 'AES_CBC'
Ejemplo n.º 10
0
 def __init__(self, key=None, padding=padWithPadLen(), keySize=16):
     CBC.__init__( self, AES(key, noPadding(), keySize), padding)
     self.name       = 'AES_CBC'