Size should be an int. I see repeated use of getInt(ivSize), yet only one direct use of the size as a byte array, which happens when you prepend the size to the ciphertext output. It's clearer and more efficient to simply store the size as an int, then convert to bytes in the one case you need it.