private static SymmetricAlgorithm GetCipher()

in sdk/PowerBI.Api/Extensions/AuthenticatedEncryption.cs [278:300]


        private static SymmetricAlgorithm GetCipher(AeCipher aeCipher, byte[] keyEnc)
        {
            SymmetricAlgorithm symmetricAlgorithm;

            switch (aeCipher)
            {
                case AeCipher.Aes256CbcPkcs7:
                    symmetricAlgorithm = Aes.Create();
                    // While 256-bit, CBC, and PKCS7 are all the default values for these
                    // properties, being explicit helps comprehension more than it hurts
                    // performance.
                    symmetricAlgorithm.KeySize = 256;
                    symmetricAlgorithm.Mode = CipherMode.CBC;
                    symmetricAlgorithm.Padding = PaddingMode.PKCS7;
                    break;
                default:
                    // An algorithm we don't understand
                    throw new CryptographicException("Invalid Cipher algorithm");
            }

            symmetricAlgorithm.Key = keyEnc;
            return symmetricAlgorithm;
        }