crypto/algorithms/pureaescipher.py
def _decryptBlock(self, iput, key, size):
        '''
        decrypts a 128 bit input block against the given key of size specified
        '''
        output = [0] * 16
        # the number of rounds
        nbrRounds = 0
        # the 128 bit block to decode
        block = [0] * 16
        # set the number of rounds
        if size == self.keySize["SIZE_128"]: nbrRounds = 10
        elif size == self.keySize["SIZE_192"]: nbrRounds = 12
        elif size == self.keySize["SIZE_256"]: nbrRounds = 14
        else: return None

        # the expanded keySize
        expandedKeySize = 16*(nbrRounds+1)

        # Set the block values, for the block:
        # a0,0 a0,1 a0,2 a0,3
        # a1,0 a1,1 a1,2 a1,3
        # a2,0 a2,1 a2,2 a2,3
        # a3,0 a3,1 a3,2 a3,3
        # the mapping order is a0,0 a1,0 a2,0 a3,0 a0,1 a1,1 ... a2,3 a3,3

        # iterate over the columns
        for i in range(4):
            # iterate over the rows
            for j in range(4):
                block[(i+(j*4))] = iput[(i*4)+j]
        # expand the key into an 176, 208, 240 bytes key
        expandedKey = self._expandKey(key, size, expandedKeySize)
        # decrypt the block using the expandedKey
        block = self._aesMainInv(block, expandedKey, nbrRounds)
        # unmap the block again into the output
        for k in range(4):
            # iterate over the rows
            for l in range(4):
                output[(k*4)+l] = block[(k+(l*4))]
        return output

        decrypts a 128 bit input block against the given key of size specified
        
decrypts a 128 bit input block against the given key of size specified
decrypts a 128 bit input block against the given key of size specified
def _decryptBlock(self, iput, key, size):
        output = [0] * 16
        nbrRounds = 0
        block = [0] * 16
        if size == self.keySize["SIZE_128"]: nbrRounds = 10
        elif size == self.keySize["SIZE_192"]: nbrRounds = 12
        elif size == self.keySize["SIZE_256"]: nbrRounds = 14
        else: return None
        expandedKeySize = 16*(nbrRounds+1)
        for i in range(4):
            for j in range(4):
                block[(i+(j*4))] = iput[(i*4)+j]
        expandedKey = self._expandKey(key, size, expandedKeySize)
        block = self._aesMainInv(block, expandedKey, nbrRounds)
        for k in range(4):
            for l in range(4):
                output[(k*4)+l] = block[(k+(l*4))]
        return output
def _decryptBlock ( self , iput , key , size ) : output = [ 0 ] * 16 nbrRounds = 0 block = [ 0 ] * 16 if size == self . keySize [ "SIZE_128" ] : nbrRounds = 10 elif size == self . keySize [ "SIZE_192" ] : nbrRounds = 12 elif size == self . keySize [ "SIZE_256" ] : nbrRounds = 14 else : return None expandedKeySize = 16 * ( nbrRounds + 1 ) for i in range ( 4 ) : for j in range ( 4 ) : block [ ( i + ( j * 4 ) ) ] = iput [ ( i * 4 ) + j ] expandedKey = self . _expandKey ( key , size , expandedKeySize ) block = self . _aesMainInv ( block , expandedKey , nbrRounds ) for k in range ( 4 ) : for l in range ( 4 ) : output [ ( k * 4 ) + l ] = block [ ( k + ( l * 4 ) ) ] return output
decrypts a 128 bit input block against the given key of size specified
decrypts a 128 bit input block against the given key of size specified
'''
        decrypts a 128 bit input block against the given key of size specified
        ''' # the number of rounds # the 128 bit block to decode # set the number of rounds # the expanded keySize # Set the block values, for the block: # a0,0 a0,1 a0,2 a0,3 # a1,0 a1,1 a1,2 a1,3 # a2,0 a2,1 a2,2 a2,3 # a3,0 a3,1 a3,2 a3,3 # the mapping order is a0,0 a1,0 a2,0 a3,0 a0,1 a1,1 ... a2,3 a3,3 # iterate over the columns # iterate over the rows # expand the key into an 176, 208, 240 bytes key # decrypt the block using the expandedKey # unmap the block again into the output # iterate over the rows
self
iput
key
size