private byte[] DoCipherOperation(Cipher cipher, byte[] data)
        {
            Requires.NotNull(cipher, nameof(cipher));
            Requires.NotNull(data, nameof(data));

            // Android returns null when given an empty input.
            if (this.Padding != SymmetricAlgorithmPadding.PKCS7 && data.Length == 0)
            {
                return data;
            }

            try
            {
                return this.CanStreamAcrossTopLevelCipherOperations
                    ? cipher.Update(data)
                    : cipher.DoFinal(data);
            }
            catch (IllegalBlockSizeException ex)
            {
                throw new ArgumentException("Illegal block size.", ex);
            }
        }