1 //------------------------------------------------------------------------------ 2 // <copyright file="SqlAes256CbcAlgorithm.cs" company="Microsoft"> 3 // Copyright (c) Microsoft Corporation. All rights reserved. 4 // </copyright> 5 // <owner current="true" primary="true">balnee</owner> 6 // <owner current="true" primary="false">krishnib</owner> 7 //------------------------------------------------------------------------------ 8 namespace System.Data.SqlClient 9 { 10 using System; 11 using System.Collections.Generic; 12 using System.Data.SqlClient; 13 using System.Diagnostics; 14 using System.IO; 15 using System.Runtime.CompilerServices; 16 using System.Security.Cryptography; 17 18 /// <summary> 19 /// This class implements AES_256_CBC algorithm. 20 /// </summary> 21 internal class SqlAes256CbcAlgorithm : SqlAeadAes256CbcHmac256Algorithm 22 { 23 /// <summary> 24 /// Algorithm Name 25 /// </summary> 26 internal new const string AlgorithmName = @"AES_256_CBC"; 27 28 /// <summary> 29 /// Initializes a new instance of SqlAes256CbcAlgorithm algorithm with a given key and encryption type 30 /// </summary> 31 /// <param name="encryptionKey"> 32 /// Root encryption key from which three other keys will be derived 33 /// </param> 34 /// <param name="encryptionType">Encryption Type, accepted values are Deterministic and Randomized. 35 /// For Deterministic encryption, a synthetic IV will be genenrated during encryption 36 /// For Randomized encryption, a random IV will be generated during encryption. 37 /// </param> 38 /// <param name="algorithmVersion"> 39 /// Algorithm version 40 /// </param> SqlAes256CbcAlgorithm(SqlAeadAes256CbcHmac256EncryptionKey encryptionKey, SqlClientEncryptionType encryptionType, byte algorithmVersion)41 internal SqlAes256CbcAlgorithm(SqlAeadAes256CbcHmac256EncryptionKey encryptionKey, SqlClientEncryptionType encryptionType, byte algorithmVersion) 42 :base(encryptionKey, encryptionType, algorithmVersion) 43 { } 44 45 /// <summary> 46 /// Encryption Algorithm 47 /// Simply call the base class, indicating we don't need an authentication tag. 48 /// </summary> 49 /// <param name="plainText">Plaintext data to be encrypted</param> 50 /// <returns>Returns the ciphertext corresponding to the plaintext.</returns> EncryptData(byte[] plainText)51 internal override byte[] EncryptData(byte[] plainText) { 52 return EncryptData(plainText, hasAuthenticationTag: false); 53 } 54 55 /// <summary> 56 /// Decryption Algorithm 57 /// Simply call the base class, indicating we don't have an authentication tag. 58 /// </summary> 59 /// <param name="cipherText"></param> 60 /// <returns></returns> DecryptData(byte[] cipherText)61 internal override byte[] DecryptData(byte[] cipherText) { 62 return base.DecryptData(cipherText, hasAuthenticationTag: false); 63 } 64 } 65 } 66