Skip to content

Commit b09cfea

Browse files
committed
Reorder static methods before instance methods
1 parent 3152361 commit b09cfea

File tree

2 files changed

+128
-128
lines changed

2 files changed

+128
-128
lines changed

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlColumnEncryptionCngProvider.Windows.cs

Lines changed: 64 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -33,70 +33,6 @@ public class SqlColumnEncryptionCngProvider : SqlColumnEncryptionKeyStoreProvide
3333
/// </summary>
3434
private const string RSAEncryptionAlgorithmWithOAEP = @"RSA_OAEP";
3535

36-
/// <include file='../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlColumnEncryptionCngProvider.xml' path='docs/members[@name="SqlColumnEncryptionCngProvider"]/DecryptColumnEncryptionKey/*' />
37-
public override byte[] DecryptColumnEncryptionKey(string? masterKeyPath, string? encryptionAlgorithm, byte[]? encryptedColumnEncryptionKey)
38-
{
39-
// Validate the input parameters
40-
ValidateNonEmptyKeyPath(masterKeyPath, isSystemOp: true);
41-
42-
if (encryptedColumnEncryptionKey is null)
43-
{
44-
throw SQL.NullEncryptedColumnEncryptionKey();
45-
}
46-
47-
if (encryptedColumnEncryptionKey.Length == 0)
48-
{
49-
throw SQL.EmptyEncryptedColumnEncryptionKey();
50-
}
51-
52-
// Validate encryptionAlgorithm
53-
ValidateEncryptionAlgorithm(encryptionAlgorithm, isSystemOp: true);
54-
55-
// Create RSA Provider with the given CNG provider name and key name
56-
RSA rsaProvider = CreateRSACngProvider(masterKeyPath, isSystemOp: true);
57-
using EncryptedColumnEncryptionKeyParameters cekDecryptionParameters = new(rsaProvider, masterKeyPath, MasterKeyType, KeyPathReference);
58-
59-
return cekDecryptionParameters.Decrypt(encryptedColumnEncryptionKey);
60-
}
61-
62-
/// <include file='../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlColumnEncryptionCngProvider.xml' path='docs/members[@name="SqlColumnEncryptionCngProvider"]/EncryptColumnEncryptionKey/*' />
63-
public override byte[] EncryptColumnEncryptionKey(string? masterKeyPath, string? encryptionAlgorithm, byte[]? columnEncryptionKey)
64-
{
65-
// Validate the input parameters
66-
ValidateNonEmptyKeyPath(masterKeyPath, isSystemOp: false);
67-
68-
if (columnEncryptionKey is null)
69-
{
70-
throw SQL.NullColumnEncryptionKey();
71-
}
72-
73-
if (columnEncryptionKey.Length == 0)
74-
{
75-
throw SQL.EmptyColumnEncryptionKey();
76-
}
77-
78-
// Validate encryptionAlgorithm
79-
ValidateEncryptionAlgorithm(encryptionAlgorithm, isSystemOp: false);
80-
81-
// Create RSA Provider with the given CNG provider name and key name
82-
RSA rsaProvider = CreateRSACngProvider(masterKeyPath, isSystemOp: false);
83-
using EncryptedColumnEncryptionKeyParameters cekEncryptionParameters = new(rsaProvider, masterKeyPath, MasterKeyType, KeyPathReference);
84-
85-
return cekEncryptionParameters.Encrypt(columnEncryptionKey);
86-
}
87-
88-
/// <include file='../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlColumnEncryptionCngProvider.xml' path='docs/members[@name="SqlColumnEncryptionCngProvider"]/SignColumnMasterKeyMetadata/*' />
89-
public override byte[] SignColumnMasterKeyMetadata(string? masterKeyPath, bool allowEnclaveComputations)
90-
{
91-
throw new NotSupportedException();
92-
}
93-
94-
/// <include file='../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlColumnEncryptionCngProvider.xml' path='docs/members[@name="SqlColumnEncryptionCngProvider"]/VerifyColumnMasterKeyMetadata/*' />
95-
public override bool VerifyColumnMasterKeyMetadata(string? masterKeyPath, bool allowEnclaveComputations, byte[]? signature)
96-
{
97-
throw new NotSupportedException();
98-
}
99-
10036
/// <summary>
10137
/// This function validates that the encryption algorithm is RSA_OAEP and if it is not,
10238
/// then throws an exception.
@@ -208,5 +144,69 @@ private static void GetCngProviderAndKeyId(string keyPath, bool isSystemOp, out
208144

209145
keyIdentifier = keyPath.Substring(indexOfSlash + 1);
210146
}
147+
148+
/// <include file='../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlColumnEncryptionCngProvider.xml' path='docs/members[@name="SqlColumnEncryptionCngProvider"]/DecryptColumnEncryptionKey/*' />
149+
public override byte[] DecryptColumnEncryptionKey(string? masterKeyPath, string? encryptionAlgorithm, byte[]? encryptedColumnEncryptionKey)
150+
{
151+
// Validate the input parameters
152+
ValidateNonEmptyKeyPath(masterKeyPath, isSystemOp: true);
153+
154+
if (encryptedColumnEncryptionKey is null)
155+
{
156+
throw SQL.NullEncryptedColumnEncryptionKey();
157+
}
158+
159+
if (encryptedColumnEncryptionKey.Length == 0)
160+
{
161+
throw SQL.EmptyEncryptedColumnEncryptionKey();
162+
}
163+
164+
// Validate encryptionAlgorithm
165+
ValidateEncryptionAlgorithm(encryptionAlgorithm, isSystemOp: true);
166+
167+
// Create RSA Provider with the given CNG provider name and key name
168+
RSA rsaProvider = CreateRSACngProvider(masterKeyPath, isSystemOp: true);
169+
using EncryptedColumnEncryptionKeyParameters cekDecryptionParameters = new(rsaProvider, masterKeyPath, MasterKeyType, KeyPathReference);
170+
171+
return cekDecryptionParameters.Decrypt(encryptedColumnEncryptionKey);
172+
}
173+
174+
/// <include file='../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlColumnEncryptionCngProvider.xml' path='docs/members[@name="SqlColumnEncryptionCngProvider"]/EncryptColumnEncryptionKey/*' />
175+
public override byte[] EncryptColumnEncryptionKey(string? masterKeyPath, string? encryptionAlgorithm, byte[]? columnEncryptionKey)
176+
{
177+
// Validate the input parameters
178+
ValidateNonEmptyKeyPath(masterKeyPath, isSystemOp: false);
179+
180+
if (columnEncryptionKey is null)
181+
{
182+
throw SQL.NullColumnEncryptionKey();
183+
}
184+
185+
if (columnEncryptionKey.Length == 0)
186+
{
187+
throw SQL.EmptyColumnEncryptionKey();
188+
}
189+
190+
// Validate encryptionAlgorithm
191+
ValidateEncryptionAlgorithm(encryptionAlgorithm, isSystemOp: false);
192+
193+
// Create RSA Provider with the given CNG provider name and key name
194+
RSA rsaProvider = CreateRSACngProvider(masterKeyPath, isSystemOp: false);
195+
using EncryptedColumnEncryptionKeyParameters cekEncryptionParameters = new(rsaProvider, masterKeyPath, MasterKeyType, KeyPathReference);
196+
197+
return cekEncryptionParameters.Encrypt(columnEncryptionKey);
198+
}
199+
200+
/// <include file='../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlColumnEncryptionCngProvider.xml' path='docs/members[@name="SqlColumnEncryptionCngProvider"]/SignColumnMasterKeyMetadata/*' />
201+
public override byte[] SignColumnMasterKeyMetadata(string? masterKeyPath, bool allowEnclaveComputations)
202+
{
203+
throw new NotSupportedException();
204+
}
205+
206+
/// <include file='../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlColumnEncryptionCngProvider.xml' path='docs/members[@name="SqlColumnEncryptionCngProvider"]/VerifyColumnMasterKeyMetadata/*' />
207+
public override bool VerifyColumnMasterKeyMetadata(string? masterKeyPath, bool allowEnclaveComputations, byte[]? signature)
208+
{
209+
throw new NotSupportedException();
210+
}
211211
}
212212
}

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlColumnEncryptionCspProvider.Windows.cs

Lines changed: 64 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -36,70 +36,6 @@ public class SqlColumnEncryptionCspProvider : SqlColumnEncryptionKeyStoreProvide
3636
/// </summary>
3737
private const string RSAEncryptionAlgorithmWithOAEP = @"RSA_OAEP";
3838

39-
/// <include file='../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlColumnEncryptionCspProvider.xml' path='docs/members[@name="SqlColumnEncryptionCspProvider"]/DecryptColumnEncryptionKey/*' />
40-
public override byte[] DecryptColumnEncryptionKey(string? masterKeyPath, string? encryptionAlgorithm, byte[]? encryptedColumnEncryptionKey)
41-
{
42-
// Validate the input parameters
43-
ValidateNonEmptyCSPKeyPath(masterKeyPath, isSystemOp: true);
44-
45-
if (encryptedColumnEncryptionKey is null)
46-
{
47-
throw SQL.NullEncryptedColumnEncryptionKey();
48-
}
49-
50-
if (encryptedColumnEncryptionKey.Length == 0)
51-
{
52-
throw SQL.EmptyEncryptedColumnEncryptionKey();
53-
}
54-
55-
// Validate encryptionAlgorithm
56-
ValidateEncryptionAlgorithm(encryptionAlgorithm, isSystemOp: true);
57-
58-
// Create RSA Provider with the given CSP name and key name
59-
RSA rsaProvider = CreateRSACryptoProvider(masterKeyPath, isSystemOp: true);
60-
using EncryptedColumnEncryptionKeyParameters cekDecryptionParameters = new(rsaProvider, masterKeyPath, MasterKeyType, KeyPathReference);
61-
62-
return cekDecryptionParameters.Decrypt(encryptedColumnEncryptionKey);
63-
}
64-
65-
/// <include file='../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlColumnEncryptionCspProvider.xml' path='docs/members[@name="SqlColumnEncryptionCspProvider"]/EncryptColumnEncryptionKey/*' />
66-
public override byte[] EncryptColumnEncryptionKey(string? masterKeyPath, string? encryptionAlgorithm, byte[]? columnEncryptionKey)
67-
{
68-
// Validate the input parameters
69-
ValidateNonEmptyCSPKeyPath(masterKeyPath, isSystemOp: false);
70-
71-
if (columnEncryptionKey is null)
72-
{
73-
throw SQL.NullColumnEncryptionKey();
74-
}
75-
76-
if (columnEncryptionKey.Length == 0)
77-
{
78-
throw SQL.EmptyColumnEncryptionKey();
79-
}
80-
81-
// Validate encryptionAlgorithm
82-
ValidateEncryptionAlgorithm(encryptionAlgorithm, isSystemOp: false);
83-
84-
// Create RSA Provider with the given CSP name and key name
85-
RSA rsaProvider = CreateRSACryptoProvider(masterKeyPath, isSystemOp: false);
86-
using EncryptedColumnEncryptionKeyParameters cekEncryptionParameters = new(rsaProvider, masterKeyPath, MasterKeyType, KeyPathReference);
87-
88-
return cekEncryptionParameters.Encrypt(columnEncryptionKey);
89-
}
90-
91-
/// <include file='../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlColumnEncryptionCspProvider.xml' path='docs/members[@name="SqlColumnEncryptionCspProvider"]/SignColumnMasterKeyMetadata/*' />
92-
public override byte[] SignColumnMasterKeyMetadata(string? masterKeyPath, bool allowEnclaveComputations)
93-
{
94-
throw new NotSupportedException();
95-
}
96-
97-
/// <include file='../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlColumnEncryptionCspProvider.xml' path='docs/members[@name="SqlColumnEncryptionCspProvider"]/VerifyColumnMasterKeyMetadata/*' />
98-
public override bool VerifyColumnMasterKeyMetadata(string? masterKeyPath, bool allowEnclaveComputations, byte[]? signature)
99-
{
100-
throw new NotSupportedException();
101-
}
102-
10339
/// <summary>
10440
/// This function validates that the encryption algorithm is RSA_OAEP and if it is not,
10541
/// then throws an exception.
@@ -211,5 +147,69 @@ private static int GetProviderType(string providerName, string keyPath, bool isS
211147
return (int)(key.GetValue(@"Type")
212148
?? throw SQL.InvalidCspName(providerName, keyPath, isSystemOp));
213149
}
150+
151+
/// <include file='../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlColumnEncryptionCspProvider.xml' path='docs/members[@name="SqlColumnEncryptionCspProvider"]/DecryptColumnEncryptionKey/*' />
152+
public override byte[] DecryptColumnEncryptionKey(string? masterKeyPath, string? encryptionAlgorithm, byte[]? encryptedColumnEncryptionKey)
153+
{
154+
// Validate the input parameters
155+
ValidateNonEmptyCSPKeyPath(masterKeyPath, isSystemOp: true);
156+
157+
if (encryptedColumnEncryptionKey is null)
158+
{
159+
throw SQL.NullEncryptedColumnEncryptionKey();
160+
}
161+
162+
if (encryptedColumnEncryptionKey.Length == 0)
163+
{
164+
throw SQL.EmptyEncryptedColumnEncryptionKey();
165+
}
166+
167+
// Validate encryptionAlgorithm
168+
ValidateEncryptionAlgorithm(encryptionAlgorithm, isSystemOp: true);
169+
170+
// Create RSA Provider with the given CSP name and key name
171+
RSA rsaProvider = CreateRSACryptoProvider(masterKeyPath, isSystemOp: true);
172+
using EncryptedColumnEncryptionKeyParameters cekDecryptionParameters = new(rsaProvider, masterKeyPath, MasterKeyType, KeyPathReference);
173+
174+
return cekDecryptionParameters.Decrypt(encryptedColumnEncryptionKey);
175+
}
176+
177+
/// <include file='../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlColumnEncryptionCspProvider.xml' path='docs/members[@name="SqlColumnEncryptionCspProvider"]/EncryptColumnEncryptionKey/*' />
178+
public override byte[] EncryptColumnEncryptionKey(string? masterKeyPath, string? encryptionAlgorithm, byte[]? columnEncryptionKey)
179+
{
180+
// Validate the input parameters
181+
ValidateNonEmptyCSPKeyPath(masterKeyPath, isSystemOp: false);
182+
183+
if (columnEncryptionKey is null)
184+
{
185+
throw SQL.NullColumnEncryptionKey();
186+
}
187+
188+
if (columnEncryptionKey.Length == 0)
189+
{
190+
throw SQL.EmptyColumnEncryptionKey();
191+
}
192+
193+
// Validate encryptionAlgorithm
194+
ValidateEncryptionAlgorithm(encryptionAlgorithm, isSystemOp: false);
195+
196+
// Create RSA Provider with the given CSP name and key name
197+
RSA rsaProvider = CreateRSACryptoProvider(masterKeyPath, isSystemOp: false);
198+
using EncryptedColumnEncryptionKeyParameters cekEncryptionParameters = new(rsaProvider, masterKeyPath, MasterKeyType, KeyPathReference);
199+
200+
return cekEncryptionParameters.Encrypt(columnEncryptionKey);
201+
}
202+
203+
/// <include file='../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlColumnEncryptionCspProvider.xml' path='docs/members[@name="SqlColumnEncryptionCspProvider"]/SignColumnMasterKeyMetadata/*' />
204+
public override byte[] SignColumnMasterKeyMetadata(string? masterKeyPath, bool allowEnclaveComputations)
205+
{
206+
throw new NotSupportedException();
207+
}
208+
209+
/// <include file='../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlColumnEncryptionCspProvider.xml' path='docs/members[@name="SqlColumnEncryptionCspProvider"]/VerifyColumnMasterKeyMetadata/*' />
210+
public override bool VerifyColumnMasterKeyMetadata(string? masterKeyPath, bool allowEnclaveComputations, byte[]? signature)
211+
{
212+
throw new NotSupportedException();
213+
}
214214
}
215215
}

0 commit comments

Comments
 (0)