'Decrypt data in CBC mode'

def decrypt(self, data):

    block_size = self.block_size
    if ((len(data) % block_size) != 0):
        raise ValueError, 'Ciphertext    length    must    be    multiple    of    16'
    data = array('B', data)
    IV = self.IV
    for offset in xrange(0, len(data), block_size):
        ctext = data[offset:(offset + block_size)]
        block = ctext[:]
        self.cipher.decrypt_block(block)
        for i in xrange(block_size):
            block[i] ^= IV[i]
        data[offset:(offset + block_size)] = block
        IV = ctext
    self.IV = IV
    return data.tostring()
