Skip to content

Commit

Permalink
[Cleanup] Remove unused algorithm classes. (dotnet#699)
Browse files Browse the repository at this point in the history
  • Loading branch information
cheenamalhotra authored and TrayanZapryanov committed Aug 31, 2020
1 parent 8524259 commit 3f71017
Show file tree
Hide file tree
Showing 11 changed files with 17 additions and 184 deletions.
Expand Up @@ -150,12 +150,6 @@
<Compile Include="..\..\src\Microsoft\Data\SqlClient\SqlAeadAes256CbcHmac256Factory.cs">
<Link>Microsoft\Data\SqlClient\SqlAeadAes256CbcHmac256Factory.cs</Link>
</Compile>
<Compile Include="..\..\src\Microsoft\Data\SqlClient\SqlAes256CbcAlgorithm.cs">
<Link>Microsoft\Data\SqlClient\SqlAes256CbcAlgorithm.cs</Link>
</Compile>
<Compile Include="..\..\src\Microsoft\Data\SqlClient\SqlAes256CbcFactory.cs">
<Link>Microsoft\Data\SqlClient\SqlAes256CbcFactory.cs</Link>
</Compile>
<Compile Include="..\..\src\Microsoft\Data\SqlClient\SqlAuthenticationParameters.cs">
<Link>Microsoft\Data\SqlClient\SqlAuthenticationParameters.cs</Link>
</Compile>
Expand Down
Expand Up @@ -150,10 +150,6 @@ private static string ValidateAndGetEncryptionAlgorithmName(byte cipherAlgorithm
{
return SqlAeadAes256CbcHmac256Algorithm.AlgorithmName;
}
else if (TdsEnums.AES_256_CBC == cipherAlgorithmId)
{
return SqlAes256CbcAlgorithm.AlgorithmName;
}
else
{
throw SQL.UnknownColumnEncryptionAlgorithmId(cipherAlgorithmId, GetRegisteredCipherAlgorithmIds());
Expand Down Expand Up @@ -241,7 +237,7 @@ internal static byte[] DecryptWithKey(byte[] cipherText, SqlCipherMetadata md, s
}

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

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

// Given the symmetric key instantiate a SqlClientEncryptionAlgorithm object and cache it in metadata
// Given the symmetric key instantiate a SqlClientEncryptionAlgorithm object and cache it in metadata
md.CipherAlgorithm = null;
SqlClientEncryptionAlgorithm cipherAlgorithm = null;
string algorithmName = ValidateAndGetEncryptionAlgorithmName(md.CipherAlgorithmId, md.CipherAlgorithmName); // may throw
Expand Down
Expand Up @@ -134,7 +134,7 @@ internal static class TdsEnums
public const byte SQLDEBUG_CMD = 0x60;
public const byte SQLLOGINACK = 0xad;
public const byte SQLFEATUREEXTACK = 0xae; // TDS 7.4 - feature ack
public const byte SQLSESSIONSTATE = 0xe4; // TDS 7.4 - connection resiliency session state
public const byte SQLSESSIONSTATE = 0xe4; // TDS 7.4 - connection resiliency session state
public const byte SQLENVCHANGE = 0xe3; // Environment change notification
public const byte SQLSECLEVEL = 0xed; // Security level token ???
public const byte SQLROWCRC = 0x39; // ROWCRC datastream???
Expand Down Expand Up @@ -210,8 +210,8 @@ public enum EnvChangeType : byte
public const byte FEATUREEXT_FEDAUTH = 0x02;
public const byte FEATUREEXT_TCE = 0x04;
public const byte FEATUREEXT_GLOBALTRANSACTIONS = 0x05;
// 0x06 is for x_eFeatureExtensionId_LoginToken
// 0x07 is for x_eFeatureExtensionId_ClientSideTelemetry
// 0x06 is for x_eFeatureExtensionId_LoginToken
// 0x07 is for x_eFeatureExtensionId_ClientSideTelemetry
public const byte FEATUREEXT_AZURESQLSUPPORT = 0x08;
public const byte FEATUREEXT_DATACLASSIFICATION = 0x09;
public const byte FEATUREEXT_UTF8SUPPORT = 0x0A;
Expand Down Expand Up @@ -272,7 +272,7 @@ public enum ActiveDirectoryWorkflow : byte
public const byte MAX_NIC_SIZE = 6; // The size of a MAC or client address
public const byte SQLVARIANT_SIZE = 2; // size of the fixed portion of a sql variant (type, cbPropBytes)
public const byte VERSION_SIZE = 4; // size of the tds version (4 unsigned bytes)
public const int CLIENT_PROG_VER = 0x06000000; // Client interface version
public const int CLIENT_PROG_VER = 0x06000000; // Client interface version
public const int YUKON_LOG_REC_FIXED_LEN = 0x5e;
// misc
public const int TEXT_TIME_STAMP_LEN = 8;
Expand Down Expand Up @@ -987,7 +987,6 @@ internal static string GetSniContextEnumName(SniContext sniContext)
internal const long MAX_TCE_CIPHERTEXT_SIZE = 2147483648; // max size of encrypted blob- currently 2GB.
internal const byte CustomCipherAlgorithmId = 0; // Id used for custom encryption algorithm.

internal const int AES_256_CBC = 1;
internal const int AEAD_AES_256_CBC_HMAC_SHA256 = 2;
internal const string ENCLAVE_TYPE_VBS = "VBS";
internal const string ENCLAVE_TYPE_SGX = "SGX";
Expand Down
Expand Up @@ -202,12 +202,6 @@
<Compile Include="..\..\src\Microsoft\Data\SqlClient\SqlAeadAes256CbcHmac256Factory.cs">
<Link>Microsoft\Data\SqlClient\SqlAeadAes256CbcHmac256Factory.cs</Link>
</Compile>
<Compile Include="..\..\src\Microsoft\Data\SqlClient\SqlAes256CbcAlgorithm.cs">
<Link>Microsoft\Data\SqlClient\SqlAes256CbcAlgorithm.cs</Link>
</Compile>
<Compile Include="..\..\src\Microsoft\Data\SqlClient\SqlAes256CbcFactory.cs">
<Link>Microsoft\Data\SqlClient\SqlAes256CbcFactory.cs</Link>
</Compile>
<Compile Include="..\..\src\Microsoft\Data\SqlClient\SqlAuthenticationParameters.cs">
<Link>Microsoft\Data\SqlClient\SqlAuthenticationParameters.cs</Link>
</Compile>
Expand Down
Expand Up @@ -149,10 +149,6 @@ private static string ValidateAndGetEncryptionAlgorithmName(byte cipherAlgorithm
{
return SqlAeadAes256CbcHmac256Algorithm.AlgorithmName;
}
else if (TdsEnums.AES_256_CBC == cipherAlgorithmId)
{
return SqlAes256CbcAlgorithm.AlgorithmName;
}
else
{
throw SQL.UnknownColumnEncryptionAlgorithmId(cipherAlgorithmId, GetRegisteredCipherAlgorithmIds());
Expand Down
Expand Up @@ -148,7 +148,7 @@ internal static class TdsEnums
public const byte SQLDEBUG_CMD = 0x60;
public const byte SQLLOGINACK = 0xad;
public const byte SQLFEATUREEXTACK = 0xae; // TDS 7.4 - feature ack
public const byte SQLSESSIONSTATE = 0xe4; // TDS 7.4 - connection resiliency session state
public const byte SQLSESSIONSTATE = 0xe4; // TDS 7.4 - connection resiliency session state
public const byte SQLENVCHANGE = 0xe3; // Environment change notification
public const byte SQLSECLEVEL = 0xed; // Security level token ???
public const byte SQLROWCRC = 0x39; // ROWCRC datastream???
Expand Down Expand Up @@ -199,11 +199,11 @@ internal static class TdsEnums
public const byte FEATUREEXT_TERMINATOR = 0xFF;
public const byte FEATUREEXT_SRECOVERY = 0x01;
public const byte FEATUREEXT_FEDAUTH = 0x02;
// 0x03 is for x_eFeatureExtensionId_Rcs
// 0x03 is for x_eFeatureExtensionId_Rcs
public const byte FEATUREEXT_TCE = 0x04;
public const byte FEATUREEXT_GLOBALTRANSACTIONS = 0x05;
// 0x06 is for x_eFeatureExtensionId_LoginToken
// 0x07 is for x_eFeatureExtensionId_ClientSideTelemetry
// 0x06 is for x_eFeatureExtensionId_LoginToken
// 0x07 is for x_eFeatureExtensionId_ClientSideTelemetry
public const byte FEATUREEXT_AZURESQLSUPPORT = 0x08;
public const byte FEATUREEXT_DATACLASSIFICATION = 0x09;
public const byte FEATUREEXT_UTF8SUPPORT = 0x0A;
Expand All @@ -219,7 +219,7 @@ public enum FeatureExtension : uint
GlobalTransactions = 1 << (TdsEnums.FEATUREEXT_GLOBALTRANSACTIONS - 1),
AzureSQLSupport = 1 << (TdsEnums.FEATUREEXT_AZURESQLSUPPORT - 1),
DataClassification = 1 << (TdsEnums.FEATUREEXT_DATACLASSIFICATION - 1),
UTF8Support = 1 << (TdsEnums.FEATUREEXT_UTF8SUPPORT - 1),
UTF8Support = 1 << (TdsEnums.FEATUREEXT_UTF8SUPPORT - 1),
SQLDNSCaching = 1 << (TdsEnums.FEATUREEXT_SQLDNSCACHING - 1)
}

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

internal const int AES_256_CBC = 1;
internal const int AEAD_AES_256_CBC_HMAC_SHA256 = 2;
internal const string ENCLAVE_TYPE_VBS = "VBS";
internal const string ENCLAVE_TYPE_SGX = "SGX";
Expand Down Expand Up @@ -1100,7 +1099,7 @@ public enum SqlAuthenticationMethod
ActiveDirectoryDeviceCodeFlow,
#if ADONET_CERT_AUTH
SqlCertificate
#endif
#endif
}
// This enum indicates the state of TransparentNetworkIPResolution
// The first attempt when TNIR is on should be sequential. If the first attempt failes next attempts should be parallel.
Expand Down
Expand Up @@ -7,7 +7,7 @@
namespace Microsoft.Data.SqlClient
{
/// <summary>
/// Encryption key class containing 4 keys. This class is used by SqlAeadAes256CbcHmac256Algorithm and SqlAes256CbcAlgorithm
/// Encryption key class containing 4 keys. This class is used by SqlAeadAes256CbcHmac256Algorithm
/// 1) root key - Main key that is used to derive the keys used in the encryption algorithm
/// 2) encryption key - A derived key that is used to encrypt the plain text and generate cipher text
/// 3) mac_key - A derived key that is used to compute HMAC of the cipher text
Expand Down

This file was deleted.

This file was deleted.

Expand Up @@ -21,9 +21,8 @@ private SqlClientEncryptionAlgorithmFactoryList()
{
_encryptionAlgoFactoryList = new ConcurrentDictionary<string, SqlClientEncryptionAlgorithmFactory>(concurrencyLevel: 4 * Environment.ProcessorCount /* default value in ConcurrentDictionary*/, capacity: 2);

// Add wellknown algorithms
// Add wellknown algorithm
_encryptionAlgoFactoryList.TryAdd(SqlAeadAes256CbcHmac256Algorithm.AlgorithmName, new SqlAeadAes256CbcHmac256Factory());
_encryptionAlgoFactoryList.TryAdd(SqlAes256CbcAlgorithm.AlgorithmName, new SqlAes256CbcFactory());
}

internal static SqlClientEncryptionAlgorithmFactoryList GetInstance()
Expand Down
Expand Up @@ -30,13 +30,6 @@ internal SqlClientSymmetricKey(byte[] rootKey)
_rootKey = rootKey;
}

/// <summary>
/// Empty destructor for binary back compat.
/// </summary>
~SqlClientSymmetricKey()
{
}

/// <summary>
/// Returns a copy of the plain text key
/// This is needed for actual encryption/decryption.
Expand Down

0 comments on commit 3f71017

Please sign in to comment.