Skip to content

Commit ad6d316

Browse files
author
David Engel
authored
Make enclave provider interfaces internal (#602)
1 parent 5f36b1d commit ad6d316

19 files changed

+65
-137
lines changed

src/Microsoft.Data.SqlClient/netcore/ref/Microsoft.Data.SqlClient.NetCoreApp.cs

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -191,42 +191,6 @@ protected SqlColumnEncryptionKeyStoreProvider() { }
191191
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient/SqlColumnEncryptionKeyStoreProvider.xml' path='docs/members[@name="SqlColumnEncryptionKeyStoreProvider"]/VerifyColumnMasterKeyMetadata/*'/>
192192
public virtual bool VerifyColumnMasterKeyMetadata(string masterKeyPath, bool allowEnclaveComputations, byte[] signature) { throw null; }
193193
}
194-
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient/SqlColumnEncryptionEnclaveProvider.xml' path='docs/members[@name="SqlColumnEncryptionEnclaveProvider"]/SqlColumnEncryptionEnclaveProvider/*'/>
195-
public abstract partial class SqlColumnEncryptionEnclaveProvider
196-
{
197-
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient/SqlColumnEncryptionEnclaveProvider.xml' path='docs/members[@name="SqlColumnEncryptionEnclaveProvider"]/ctor/*'/>
198-
protected SqlColumnEncryptionEnclaveProvider() { }
199-
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient/SqlColumnEncryptionEnclaveProvider.xml' path='docs/members[@name="SqlColumnEncryptionEnclaveProvider"]/CreateEnclaveSession/*'/>
200-
public abstract void CreateEnclaveSession(byte[] enclaveAttestationInfo, System.Security.Cryptography.ECDiffieHellmanCng clientDiffieHellmanKey, string attestationUrl, string servername, byte[] customData, int customDataLength, out Microsoft.Data.SqlClient.SqlEnclaveSession sqlEnclaveSession, out long counter);
201-
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient/SqlColumnEncryptionEnclaveProvider.xml' path='docs/members[@name="SqlColumnEncryptionEnclaveProvider"]/GetAttestationParameters/*'/>
202-
public abstract Microsoft.Data.SqlClient.SqlEnclaveAttestationParameters GetAttestationParameters(string attestationUrl, byte[] customData, int customDataLength);
203-
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient/SqlColumnEncryptionEnclaveProvider.xml' path='docs/members[@name="SqlColumnEncryptionEnclaveProvider"]/GetEnclaveSession/*'/>
204-
public abstract void GetEnclaveSession(string serverName, string attestationUrl, bool generateCustomData, out Microsoft.Data.SqlClient.SqlEnclaveSession sqlEnclaveSession, out long counter, out byte[] customData, out int customDataLength);
205-
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient/SqlColumnEncryptionEnclaveProvider.xml' path='docs/members[@name="SqlColumnEncryptionEnclaveProvider"]/InvalidateEnclaveSession/*'/>
206-
public abstract void InvalidateEnclaveSession(string serverName, string enclaveAttestationUrl, Microsoft.Data.SqlClient.SqlEnclaveSession enclaveSession);
207-
}
208-
/// <include file='./../../../../doc/snippets/Microsoft.Data.SqlClient/SqlEnclaveAttestationParameters.xml' path='docs/members[@name="SqlEnclaveAttestationParameters"]/SqlEnclaveAttestationParameters/*' />
209-
public partial class SqlEnclaveAttestationParameters
210-
{
211-
/// <include file='./../../../../doc/snippets/Microsoft.Data.SqlClient/SqlEnclaveAttestationParameters.xml' path='docs/members[@name="SqlEnclaveAttestationParameters"]/ctor/*' />
212-
public SqlEnclaveAttestationParameters(int protocol, byte[] input, System.Security.Cryptography.ECDiffieHellmanCng clientDiffieHellmanKey) { }
213-
/// <include file='./../../../../doc/snippets/Microsoft.Data.SqlClient/SqlEnclaveAttestationParameters.xml' path='docs/members[@name="SqlEnclaveAttestationParameters"]/ClientDiffieHellmanKey/*' />
214-
public System.Security.Cryptography.ECDiffieHellmanCng ClientDiffieHellmanKey { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
215-
/// <include file='./../../../../doc/snippets/Microsoft.Data.SqlClient/SqlEnclaveAttestationParameters.xml' path='docs/members[@name="SqlEnclaveAttestationParameters"]/Protocol/*' />
216-
public int Protocol { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
217-
/// <include file='./../../../../doc/snippets/Microsoft.Data.SqlClient/SqlEnclaveAttestationParameters.xml' path='docs/members[@name="SqlEnclaveAttestationParameters"]/GetInput/*' />
218-
public byte[] GetInput() { throw null; }
219-
}
220-
/// <include file='./../../../../doc/snippets/Microsoft.Data.SqlClient/SqlEnclaveSession.xml' path='docs/members[@name="SqlEnclaveSession"]/SqlEnclaveSession/*' />
221-
public partial class SqlEnclaveSession
222-
{
223-
/// <include file='./../../../../doc/snippets/Microsoft.Data.SqlClient/SqlEnclaveSession.xml' path='docs/members[@name="SqlEnclaveSession"]/ctor/*' />
224-
public SqlEnclaveSession(byte[] sessionKey, long sessionId) { }
225-
/// <include file='./../../../../doc/snippets/Microsoft.Data.SqlClient/SqlEnclaveSession.xml' path='docs/members[@name="SqlEnclaveSession"]/SessionId/*' />
226-
public long SessionId { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
227-
/// <include file='./../../../../doc/snippets/Microsoft.Data.SqlClient/SqlEnclaveSession.xml' path='docs/members[@name="SqlEnclaveSession"]/GetSessionKey/*' />
228-
public byte[] GetSessionKey() { throw null; }
229-
}
230194
}
231195

232196
namespace Microsoft.Data.SqlTypes

src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/AzureAttestationBasedEnclaveProvider.NetCoreApp.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,16 @@ internal class AzureAttestationEnclaveProvider : EnclaveProviderBase
6262
private static readonly MemoryCache OpenIdConnectConfigurationCache = new MemoryCache("OpenIdConnectConfigurationCache");
6363
#endregion
6464

65-
#region Public methods
65+
#region Internal methods
6666
// When overridden in a derived class, looks up an existing enclave session information in the enclave session cache.
6767
// If the enclave provider doesn't implement enclave session caching, this method is expected to return null in the sqlEnclaveSession parameter.
68-
public override void GetEnclaveSession(string servername, string attestationUrl, bool generateCustomData, out SqlEnclaveSession sqlEnclaveSession, out long counter, out byte[] customData, out int customDataLength)
68+
internal override void GetEnclaveSession(string servername, string attestationUrl, bool generateCustomData, out SqlEnclaveSession sqlEnclaveSession, out long counter, out byte[] customData, out int customDataLength)
6969
{
7070
GetEnclaveSessionHelper(servername, attestationUrl, generateCustomData, out sqlEnclaveSession, out counter, out customData, out customDataLength);
7171
}
7272

7373
// Gets the information that SqlClient subsequently uses to initiate the process of attesting the enclave and to establish a secure session with the enclave.
74-
public override SqlEnclaveAttestationParameters GetAttestationParameters(string attestationUrl, byte[] customData, int customDataLength)
74+
internal override SqlEnclaveAttestationParameters GetAttestationParameters(string attestationUrl, byte[] customData, int customDataLength)
7575
{
7676
ECDiffieHellmanCng clientDHKey = new ECDiffieHellmanCng(DiffieHellmanKeySize);
7777
clientDHKey.KeyDerivationFunction = ECDiffieHellmanKeyDerivationFunction.Hash;
@@ -81,7 +81,7 @@ public override SqlEnclaveAttestationParameters GetAttestationParameters(string
8181
}
8282

8383
// When overridden in a derived class, performs enclave attestation, generates a symmetric key for the session, creates a an enclave session and stores the session information in the cache.
84-
public override void CreateEnclaveSession(byte[] attestationInfo, ECDiffieHellmanCng clientDHKey, string attestationUrl, string servername, byte[] customData, int customDataLength, out SqlEnclaveSession sqlEnclaveSession, out long counter)
84+
internal override void CreateEnclaveSession(byte[] attestationInfo, ECDiffieHellmanCng clientDHKey, string attestationUrl, string servername, byte[] customData, int customDataLength, out SqlEnclaveSession sqlEnclaveSession, out long counter)
8585
{
8686
sqlEnclaveSession = null;
8787
counter = 0;
@@ -126,7 +126,7 @@ public override void CreateEnclaveSession(byte[] attestationInfo, ECDiffieHellma
126126
}
127127

128128
// When overridden in a derived class, looks up and evicts an enclave session from the enclave session cache, if the provider implements session caching.
129-
public override void InvalidateEnclaveSession(string serverName, string enclaveAttestationUrl, SqlEnclaveSession enclaveSessionToInvalidate)
129+
internal override void InvalidateEnclaveSession(string serverName, string enclaveAttestationUrl, SqlEnclaveSession enclaveSessionToInvalidate)
130130
{
131131
InvalidateEnclaveSessionHelper(serverName, enclaveAttestationUrl, enclaveSessionToInvalidate);
132132
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ namespace Microsoft.Data.SqlClient
1010
internal class EnclavePackage
1111
{
1212

13-
public SqlEnclaveSession EnclaveSession { get; }
14-
public byte[] EnclavePackageBytes { get; }
13+
internal SqlEnclaveSession EnclaveSession { get; }
14+
internal byte[] EnclavePackageBytes { get; }
1515

1616
/// <summary>
1717
/// Constructor

src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/EnclaveSessionCache.NetCoreApp.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ internal class EnclaveSessionCache
2222
private static int enclaveCacheTimeOutInHours = 8;
2323

2424
// Retrieves a SqlEnclaveSession from the cache
25-
public SqlEnclaveSession GetEnclaveSession(string servername, string attestationUrl, out long counter)
25+
internal SqlEnclaveSession GetEnclaveSession(string servername, string attestationUrl, out long counter)
2626
{
2727
string cacheKey = GenerateCacheKey(servername, attestationUrl);
2828
SqlEnclaveSession enclaveSession = enclaveMemoryCache[cacheKey] as SqlEnclaveSession;
@@ -31,7 +31,7 @@ public SqlEnclaveSession GetEnclaveSession(string servername, string attestation
3131
}
3232

3333
// Invalidates a SqlEnclaveSession entry in the cache
34-
public void InvalidateSession(string serverName, string enclaveAttestationUrl, SqlEnclaveSession enclaveSessionToInvalidate)
34+
internal void InvalidateSession(string serverName, string enclaveAttestationUrl, SqlEnclaveSession enclaveSessionToInvalidate)
3535
{
3636
string cacheKey = GenerateCacheKey(serverName, enclaveAttestationUrl);
3737

@@ -52,7 +52,7 @@ public void InvalidateSession(string serverName, string enclaveAttestationUrl, S
5252
}
5353

5454
// Creates a new SqlEnclaveSession and adds it to the cache
55-
public SqlEnclaveSession CreateSession(string attestationUrl, string serverName, byte[] sharedSecret, long sessionId, out long counter)
55+
internal SqlEnclaveSession CreateSession(string attestationUrl, string serverName, byte[] sharedSecret, long sessionId, out long counter)
5656
{
5757
string cacheKey = GenerateCacheKey(serverName, attestationUrl);
5858
SqlEnclaveSession enclaveSession = null;

src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlColumnEncryptionEnclaveProvider.NetCoreApp.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace Microsoft.Data.SqlClient
99
/// <summary>
1010
/// The base class that defines the interface for enclave providers for Always Encrypted. An enclave is a protected region of memory inside SQL Server, used for computations on encrypted columns. An enclave provider encapsulates the client-side implementation details of the enclave attestation protocol as well as the logic for creating and caching enclave sessions.
1111
/// </summary>
12-
public abstract partial class SqlColumnEncryptionEnclaveProvider
12+
internal abstract partial class SqlColumnEncryptionEnclaveProvider
1313
{
1414
/// Performs enclave attestation, generates a symmetric key for the session, creates a an enclave session and stores the session information in the cache.
1515
/// <param name="enclaveAttestationInfo">The information the provider uses to attest the enclave and generate a symmetric key for the session. The format of this information is specific to the enclave attestation protocol.</param>
@@ -20,7 +20,7 @@ public abstract partial class SqlColumnEncryptionEnclaveProvider
2020
/// <param name="customDataLength">The length of the extra data needed for attestating the enclave.</param>
2121
/// <param name="sqlEnclaveSession">The requested enclave session or null if the provider does not implement session caching.</param>
2222
/// <param name="counter">A counter that the enclave provider is expected to increment each time SqlClient retrieves the session from the cache. The purpose of this field is to prevent replay attacks.</param>
23-
public abstract void CreateEnclaveSession(byte[] enclaveAttestationInfo, ECDiffieHellmanCng clientDiffieHellmanKey, string attestationUrl, string servername, byte[] customData, int customDataLength,
23+
internal abstract void CreateEnclaveSession(byte[] enclaveAttestationInfo, ECDiffieHellmanCng clientDiffieHellmanKey, string attestationUrl, string servername, byte[] customData, int customDataLength,
2424
out SqlEnclaveSession sqlEnclaveSession, out long counter);
2525
}
26-
}
26+
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
namespace Microsoft.Data.SqlClient
66
{
77
/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlColumnEncryptionEnclaveProvider.xml' path='docs/members[@name="SqlColumnEncryptionEnclaveProvider"]/SqlColumnEncryptionEnclaveProvider/*'/>
8-
public abstract partial class SqlColumnEncryptionEnclaveProvider
8+
internal abstract partial class SqlColumnEncryptionEnclaveProvider
99
{
1010
/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlColumnEncryptionEnclaveProvider.xml' path='docs/members[@name="SqlColumnEncryptionEnclaveProvider"]/GetEnclaveSession/*'/>
11-
public abstract void GetEnclaveSession(string serverName, string attestationUrl, bool generateCustomData, out SqlEnclaveSession sqlEnclaveSession, out long counter, out byte[] customData, out int customDataLength);
11+
internal abstract void GetEnclaveSession(string serverName, string attestationUrl, bool generateCustomData, out SqlEnclaveSession sqlEnclaveSession, out long counter, out byte[] customData, out int customDataLength);
1212

1313
/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlColumnEncryptionEnclaveProvider.xml' path='docs/members[@name="SqlColumnEncryptionEnclaveProvider"]/GetAttestationParameters/*'/>
14-
public abstract SqlEnclaveAttestationParameters GetAttestationParameters(string attestationUrl, byte[] customData, int customDataLength);
14+
internal abstract SqlEnclaveAttestationParameters GetAttestationParameters(string attestationUrl, byte[] customData, int customDataLength);
1515

1616
/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlColumnEncryptionEnclaveProvider.xml' path='docs/members[@name="SqlColumnEncryptionEnclaveProvider"]/InvalidateEnclaveSession/*'/>
17-
public abstract void InvalidateEnclaveSession(string serverName, string enclaveAttestationUrl, SqlEnclaveSession enclaveSession);
17+
internal abstract void InvalidateEnclaveSession(string serverName, string enclaveAttestationUrl, SqlEnclaveSession enclaveSession);
1818
}
1919
}

src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlEnclaveAttestationParameters.NetCoreApp.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@
77
namespace Microsoft.Data.SqlClient
88
{
99
/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlEnclaveAttestationParameters.xml' path='docs/members[@name="SqlEnclaveAttestationParameters"]/SqlEnclaveAttestationParameters/*' />
10-
public partial class SqlEnclaveAttestationParameters
10+
internal partial class SqlEnclaveAttestationParameters
1111
{
1212
private static readonly string _clientDiffieHellmanKeyName = "ClientDiffieHellmanKey";
1313
private static readonly string _inputName = "input";
1414
private static readonly string _className = "EnclaveAttestationParameters";
1515

1616
/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlEnclaveAttestationParameters.xml' path='docs/members[@name="SqlEnclaveAttestationParameters"]/ClientDiffieHellmanKey/*' />
17-
public ECDiffieHellmanCng ClientDiffieHellmanKey { get; }
17+
internal ECDiffieHellmanCng ClientDiffieHellmanKey { get; }
1818

1919
/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlEnclaveAttestationParameters.xml' path='docs/members[@name="SqlEnclaveAttestationParameters"]/ctor/*' />
20-
public SqlEnclaveAttestationParameters(int protocol, byte[] input, ECDiffieHellmanCng clientDiffieHellmanKey)
20+
internal SqlEnclaveAttestationParameters(int protocol, byte[] input, ECDiffieHellmanCng clientDiffieHellmanKey)
2121
{
2222
_input = input ?? throw SQL.NullArgumentInConstructorInternal(_inputName, _className);
2323
Protocol = protocol;

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
namespace Microsoft.Data.SqlClient
66
{
77
/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlEnclaveAttestationParameters.xml' path='docs/members[@name="SqlEnclaveAttestationParameters"]/SqlEnclaveAttestationParameters/*' />
8-
public partial class SqlEnclaveAttestationParameters
8+
internal partial class SqlEnclaveAttestationParameters
99
{
1010
private readonly byte[] _input = null;
1111

1212
/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlEnclaveAttestationParameters.xml' path='docs/members[@name="SqlEnclaveAttestationParameters"]/Protocol/*' />
13-
public int Protocol { get; }
13+
internal int Protocol { get; }
1414

1515
/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlEnclaveAttestationParameters.xml' path='docs/members[@name="SqlEnclaveAttestationParameters"]/GetInput/*' />
16-
public byte[] GetInput()
16+
internal byte[] GetInput()
1717
{
1818
return Clone(_input);
1919
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
namespace Microsoft.Data.SqlClient
66
{
77
/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlEnclaveSession.xml' path='docs/members[@name="SqlEnclaveSession"]/SqlEnclaveSession/*' />
8-
public class SqlEnclaveSession
8+
internal class SqlEnclaveSession
99
{
1010

1111
private static readonly string _sessionKeyName = "SessionKey";
@@ -14,10 +14,10 @@ public class SqlEnclaveSession
1414
private readonly byte[] _sessionKey;
1515

1616
/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlEnclaveSession.xml' path='docs/members[@name="SqlEnclaveSession"]/SessionId/*' />
17-
public long SessionId { get; }
17+
internal long SessionId { get; }
1818

1919
/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlEnclaveSession.xml' path='docs/members[@name="SqlEnclaveSession"]/GetSessionKey/*' />
20-
public byte[] GetSessionKey()
20+
internal byte[] GetSessionKey()
2121
{
2222
return Clone(_sessionKey);
2323
}
@@ -41,7 +41,7 @@ private byte[] Clone(byte[] arrayToClone)
4141
}
4242

4343
/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlEnclaveSession.xml' path='docs/members[@name="SqlEnclaveSession"]/ctor/*' />
44-
public SqlEnclaveSession(byte[] sessionKey, long sessionId/*, long counter*/)
44+
internal SqlEnclaveSession(byte[] sessionKey, long sessionId/*, long counter*/)
4545
{
4646
if (null == sessionKey)
4747
{

0 commit comments

Comments
 (0)