Skip to content

Commit 22d1467

Browse files
[Cleanup] Remove unused algorithm classes. (#699)
1 parent 07ee9db commit 22d1467

File tree

11 files changed

+17
-184
lines changed

11 files changed

+17
-184
lines changed

src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,6 @@
150150
<Compile Include="..\..\src\Microsoft\Data\SqlClient\SqlAeadAes256CbcHmac256Factory.cs">
151151
<Link>Microsoft\Data\SqlClient\SqlAeadAes256CbcHmac256Factory.cs</Link>
152152
</Compile>
153-
<Compile Include="..\..\src\Microsoft\Data\SqlClient\SqlAes256CbcAlgorithm.cs">
154-
<Link>Microsoft\Data\SqlClient\SqlAes256CbcAlgorithm.cs</Link>
155-
</Compile>
156-
<Compile Include="..\..\src\Microsoft\Data\SqlClient\SqlAes256CbcFactory.cs">
157-
<Link>Microsoft\Data\SqlClient\SqlAes256CbcFactory.cs</Link>
158-
</Compile>
159153
<Compile Include="..\..\src\Microsoft\Data\SqlClient\SqlAuthenticationParameters.cs">
160154
<Link>Microsoft\Data\SqlClient\SqlAuthenticationParameters.cs</Link>
161155
</Compile>

src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlSecurityUtility.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,6 @@ private static string ValidateAndGetEncryptionAlgorithmName(byte cipherAlgorithm
150150
{
151151
return SqlAeadAes256CbcHmac256Algorithm.AlgorithmName;
152152
}
153-
else if (TdsEnums.AES_256_CBC == cipherAlgorithmId)
154-
{
155-
return SqlAes256CbcAlgorithm.AlgorithmName;
156-
}
157153
else
158154
{
159155
throw SQL.UnknownColumnEncryptionAlgorithmId(cipherAlgorithmId, GetRegisteredCipherAlgorithmIds());
@@ -241,7 +237,7 @@ internal static byte[] DecryptWithKey(byte[] cipherText, SqlCipherMetadata md, s
241237
}
242238

243239
/// <summary>
244-
/// <para> Decrypts the symmetric key and saves it in metadata. In addition, initializes
240+
/// <para> Decrypts the symmetric key and saves it in metadata. In addition, initializes
245241
/// the SqlClientEncryptionAlgorithm for rapid decryption.</para>
246242
/// </summary>
247243
internal static void DecryptSymmetricKey(SqlCipherMetadata md, string serverName)
@@ -253,7 +249,7 @@ internal static void DecryptSymmetricKey(SqlCipherMetadata md, string serverName
253249

254250
DecryptSymmetricKey(md.EncryptionInfo, serverName, out symKey, out encryptionkeyInfoChosen);
255251

256-
// Given the symmetric key instantiate a SqlClientEncryptionAlgorithm object and cache it in metadata
252+
// Given the symmetric key instantiate a SqlClientEncryptionAlgorithm object and cache it in metadata
257253
md.CipherAlgorithm = null;
258254
SqlClientEncryptionAlgorithm cipherAlgorithm = null;
259255
string algorithmName = ValidateAndGetEncryptionAlgorithmName(md.CipherAlgorithmId, md.CipherAlgorithmName); // may throw

src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsEnums.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ internal static class TdsEnums
134134
public const byte SQLDEBUG_CMD = 0x60;
135135
public const byte SQLLOGINACK = 0xad;
136136
public const byte SQLFEATUREEXTACK = 0xae; // TDS 7.4 - feature ack
137-
public const byte SQLSESSIONSTATE = 0xe4; // TDS 7.4 - connection resiliency session state
137+
public const byte SQLSESSIONSTATE = 0xe4; // TDS 7.4 - connection resiliency session state
138138
public const byte SQLENVCHANGE = 0xe3; // Environment change notification
139139
public const byte SQLSECLEVEL = 0xed; // Security level token ???
140140
public const byte SQLROWCRC = 0x39; // ROWCRC datastream???
@@ -210,8 +210,8 @@ public enum EnvChangeType : byte
210210
public const byte FEATUREEXT_FEDAUTH = 0x02;
211211
public const byte FEATUREEXT_TCE = 0x04;
212212
public const byte FEATUREEXT_GLOBALTRANSACTIONS = 0x05;
213-
// 0x06 is for x_eFeatureExtensionId_LoginToken
214-
// 0x07 is for x_eFeatureExtensionId_ClientSideTelemetry
213+
// 0x06 is for x_eFeatureExtensionId_LoginToken
214+
// 0x07 is for x_eFeatureExtensionId_ClientSideTelemetry
215215
public const byte FEATUREEXT_AZURESQLSUPPORT = 0x08;
216216
public const byte FEATUREEXT_DATACLASSIFICATION = 0x09;
217217
public const byte FEATUREEXT_UTF8SUPPORT = 0x0A;
@@ -272,7 +272,7 @@ public enum ActiveDirectoryWorkflow : byte
272272
public const byte MAX_NIC_SIZE = 6; // The size of a MAC or client address
273273
public const byte SQLVARIANT_SIZE = 2; // size of the fixed portion of a sql variant (type, cbPropBytes)
274274
public const byte VERSION_SIZE = 4; // size of the tds version (4 unsigned bytes)
275-
public const int CLIENT_PROG_VER = 0x06000000; // Client interface version
275+
public const int CLIENT_PROG_VER = 0x06000000; // Client interface version
276276
public const int YUKON_LOG_REC_FIXED_LEN = 0x5e;
277277
// misc
278278
public const int TEXT_TIME_STAMP_LEN = 8;
@@ -987,7 +987,6 @@ internal static string GetSniContextEnumName(SniContext sniContext)
987987
internal const long MAX_TCE_CIPHERTEXT_SIZE = 2147483648; // max size of encrypted blob- currently 2GB.
988988
internal const byte CustomCipherAlgorithmId = 0; // Id used for custom encryption algorithm.
989989

990-
internal const int AES_256_CBC = 1;
991990
internal const int AEAD_AES_256_CBC_HMAC_SHA256 = 2;
992991
internal const string ENCLAVE_TYPE_VBS = "VBS";
993992
internal const string ENCLAVE_TYPE_SGX = "SGX";

src/Microsoft.Data.SqlClient/netfx/src/Microsoft.Data.SqlClient.csproj

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -202,12 +202,6 @@
202202
<Compile Include="..\..\src\Microsoft\Data\SqlClient\SqlAeadAes256CbcHmac256Factory.cs">
203203
<Link>Microsoft\Data\SqlClient\SqlAeadAes256CbcHmac256Factory.cs</Link>
204204
</Compile>
205-
<Compile Include="..\..\src\Microsoft\Data\SqlClient\SqlAes256CbcAlgorithm.cs">
206-
<Link>Microsoft\Data\SqlClient\SqlAes256CbcAlgorithm.cs</Link>
207-
</Compile>
208-
<Compile Include="..\..\src\Microsoft\Data\SqlClient\SqlAes256CbcFactory.cs">
209-
<Link>Microsoft\Data\SqlClient\SqlAes256CbcFactory.cs</Link>
210-
</Compile>
211205
<Compile Include="..\..\src\Microsoft\Data\SqlClient\SqlAuthenticationParameters.cs">
212206
<Link>Microsoft\Data\SqlClient\SqlAuthenticationParameters.cs</Link>
213207
</Compile>

src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlSecurityUtility.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,6 @@ private static string ValidateAndGetEncryptionAlgorithmName(byte cipherAlgorithm
149149
{
150150
return SqlAeadAes256CbcHmac256Algorithm.AlgorithmName;
151151
}
152-
else if (TdsEnums.AES_256_CBC == cipherAlgorithmId)
153-
{
154-
return SqlAes256CbcAlgorithm.AlgorithmName;
155-
}
156152
else
157153
{
158154
throw SQL.UnknownColumnEncryptionAlgorithmId(cipherAlgorithmId, GetRegisteredCipherAlgorithmIds());

src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsEnums.cs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ internal static class TdsEnums
148148
public const byte SQLDEBUG_CMD = 0x60;
149149
public const byte SQLLOGINACK = 0xad;
150150
public const byte SQLFEATUREEXTACK = 0xae; // TDS 7.4 - feature ack
151-
public const byte SQLSESSIONSTATE = 0xe4; // TDS 7.4 - connection resiliency session state
151+
public const byte SQLSESSIONSTATE = 0xe4; // TDS 7.4 - connection resiliency session state
152152
public const byte SQLENVCHANGE = 0xe3; // Environment change notification
153153
public const byte SQLSECLEVEL = 0xed; // Security level token ???
154154
public const byte SQLROWCRC = 0x39; // ROWCRC datastream???
@@ -199,11 +199,11 @@ internal static class TdsEnums
199199
public const byte FEATUREEXT_TERMINATOR = 0xFF;
200200
public const byte FEATUREEXT_SRECOVERY = 0x01;
201201
public const byte FEATUREEXT_FEDAUTH = 0x02;
202-
// 0x03 is for x_eFeatureExtensionId_Rcs
202+
// 0x03 is for x_eFeatureExtensionId_Rcs
203203
public const byte FEATUREEXT_TCE = 0x04;
204204
public const byte FEATUREEXT_GLOBALTRANSACTIONS = 0x05;
205-
// 0x06 is for x_eFeatureExtensionId_LoginToken
206-
// 0x07 is for x_eFeatureExtensionId_ClientSideTelemetry
205+
// 0x06 is for x_eFeatureExtensionId_LoginToken
206+
// 0x07 is for x_eFeatureExtensionId_ClientSideTelemetry
207207
public const byte FEATUREEXT_AZURESQLSUPPORT = 0x08;
208208
public const byte FEATUREEXT_DATACLASSIFICATION = 0x09;
209209
public const byte FEATUREEXT_UTF8SUPPORT = 0x0A;
@@ -219,7 +219,7 @@ public enum FeatureExtension : uint
219219
GlobalTransactions = 1 << (TdsEnums.FEATUREEXT_GLOBALTRANSACTIONS - 1),
220220
AzureSQLSupport = 1 << (TdsEnums.FEATUREEXT_AZURESQLSUPPORT - 1),
221221
DataClassification = 1 << (TdsEnums.FEATUREEXT_DATACLASSIFICATION - 1),
222-
UTF8Support = 1 << (TdsEnums.FEATUREEXT_UTF8SUPPORT - 1),
222+
UTF8Support = 1 << (TdsEnums.FEATUREEXT_UTF8SUPPORT - 1),
223223
SQLDNSCaching = 1 << (TdsEnums.FEATUREEXT_SQLDNSCACHING - 1)
224224
}
225225

@@ -264,7 +264,7 @@ public enum ActiveDirectoryWorkflow : byte
264264
public const byte MAX_NIC_SIZE = 6; // The size of a MAC or client address
265265
public const byte SQLVARIANT_SIZE = 2; // size of the fixed portion of a sql variant (type, cbPropBytes)
266266
public const byte VERSION_SIZE = 4; // size of the tds version (4 unsigned bytes)
267-
public const int CLIENT_PROG_VER = 0x06000000; // Client interface version
267+
public const int CLIENT_PROG_VER = 0x06000000; // Client interface version
268268
public const int YUKON_LOG_REC_FIXED_LEN = 0x5e;
269269
// misc
270270
public const int TEXT_TIME_STAMP_LEN = 8;
@@ -610,8 +610,8 @@ public enum ActiveDirectoryWorkflow : byte
610610
// Login data validation Rules
611611
//
612612
internal const ushort MAXLEN_HOSTNAME = 128; // the client machine name
613-
internal const ushort MAXLEN_CLIENTID = 128;
614-
internal const ushort MAXLEN_CLIENTSECRET = 128;
613+
internal const ushort MAXLEN_CLIENTID = 128;
614+
internal const ushort MAXLEN_CLIENTSECRET = 128;
615615
internal const ushort MAXLEN_APPNAME = 128; // the client application name
616616
internal const ushort MAXLEN_SERVERNAME = 128; // the server name
617617
internal const ushort MAXLEN_CLIENTINTERFACE = 128; // the interface library name
@@ -951,7 +951,6 @@ internal enum FedAuthInfoId : byte
951951
internal const long MAX_TCE_CIPHERTEXT_SIZE = 2147483648; // max size of encrypted blob- currently 2GB.
952952
internal const byte CustomCipherAlgorithmId = 0; // Id used for custom encryption algorithm.
953953

954-
internal const int AES_256_CBC = 1;
955954
internal const int AEAD_AES_256_CBC_HMAC_SHA256 = 2;
956955
internal const string ENCLAVE_TYPE_VBS = "VBS";
957956
internal const string ENCLAVE_TYPE_SGX = "SGX";
@@ -1100,7 +1099,7 @@ public enum SqlAuthenticationMethod
11001099
ActiveDirectoryDeviceCodeFlow,
11011100
#if ADONET_CERT_AUTH
11021101
SqlCertificate
1103-
#endif
1102+
#endif
11041103
}
11051104
// This enum indicates the state of TransparentNetworkIPResolution
11061105
// The first attempt when TNIR is on should be sequential. If the first attempt failes next attempts should be parallel.

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlAeadAes256CbcHmac256EncryptionKey.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
namespace Microsoft.Data.SqlClient
88
{
99
/// <summary>
10-
/// Encryption key class containing 4 keys. This class is used by SqlAeadAes256CbcHmac256Algorithm and SqlAes256CbcAlgorithm
10+
/// Encryption key class containing 4 keys. This class is used by SqlAeadAes256CbcHmac256Algorithm
1111
/// 1) root key - Main key that is used to derive the keys used in the encryption algorithm
1212
/// 2) encryption key - A derived key that is used to encrypt the plain text and generate cipher text
1313
/// 3) mac_key - A derived key that is used to compute HMAC of the cipher text

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlAes256CbcAlgorithm.cs

Lines changed: 0 additions & 56 deletions
This file was deleted.

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlAes256CbcFactory.cs

Lines changed: 0 additions & 81 deletions
This file was deleted.

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlClientEncryptionAlgorithmFactoryList.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,8 @@ private SqlClientEncryptionAlgorithmFactoryList()
2121
{
2222
_encryptionAlgoFactoryList = new ConcurrentDictionary<string, SqlClientEncryptionAlgorithmFactory>(concurrencyLevel: 4 * Environment.ProcessorCount /* default value in ConcurrentDictionary*/, capacity: 2);
2323

24-
// Add wellknown algorithms
24+
// Add wellknown algorithm
2525
_encryptionAlgoFactoryList.TryAdd(SqlAeadAes256CbcHmac256Algorithm.AlgorithmName, new SqlAeadAes256CbcHmac256Factory());
26-
_encryptionAlgoFactoryList.TryAdd(SqlAes256CbcAlgorithm.AlgorithmName, new SqlAes256CbcFactory());
2726
}
2827

2928
internal static SqlClientEncryptionAlgorithmFactoryList GetInstance()

0 commit comments

Comments
 (0)