- 
                Notifications
    
You must be signed in to change notification settings  - Fork 317
 
Rename SimulatorEnclaveProvider - "None" attestation protocol, phase 1 #1419
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| 
          
            
          
           | 
    @@ -3,21 +3,17 @@ | |
| // See the LICENSE file in the project root for more information. | ||
| 
     | 
||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Diagnostics; | ||
| using System.Linq; | ||
| using System.Runtime.Caching; | ||
| using System.Security.Cryptography; | ||
| using System.Text; | ||
| using System.Threading; | ||
| using System.Threading.Tasks; | ||
| using System.Collections.Concurrent; | ||
| 
     | 
||
| namespace Microsoft.Data.SqlClient | ||
| { | ||
| internal class SimulatorEnclaveProvider : EnclaveProviderBase | ||
| internal class NoneAttestationEnclaveProvider : EnclaveProviderBase | ||
| { | ||
| private static readonly int EnclaveSessionHandleSize = 8; | ||
| private const int DiffieHellmanKeySize = 384; | ||
| private const int NoneAttestationProtocolId = 2; | ||
                
      
                  DavoudEshtehari marked this conversation as resolved.
               
          
            Show resolved
            Hide resolved
         | 
||
| 
     | 
||
| // When overridden in a derived class, looks up an existing enclave session information in the enclave session cache. | ||
| // If the enclave provider doesn't implement enclave session caching, this method is expected to return null in the sqlEnclaveSession parameter. | ||
| 
        
          
        
         | 
    @@ -29,18 +25,15 @@ internal override void GetEnclaveSession(EnclaveSessionParameters enclaveSession | |
| // Gets the information that SqlClient subsequently uses to initiate the process of attesting the enclave and to establish a secure session with the enclave. | ||
| internal override SqlEnclaveAttestationParameters GetAttestationParameters(string attestationUrl, byte[] customData, int customDataLength) | ||
| { | ||
| // The key derivation function and hash algorithm name are specified when key derivation is performed | ||
| ECDiffieHellman clientDHKey = ECDiffieHellman.Create(); | ||
| clientDHKey.KeySize = 384; | ||
| 
     | 
||
| return new SqlEnclaveAttestationParameters(2, new byte[] { }, clientDHKey); | ||
| ECDiffieHellman clientDHKey = KeyConverter.CreateECDiffieHellman(DiffieHellmanKeySize); | ||
| 
         There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change is required to share the file. See #1022 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could  There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it'll work, I'll let the CI determine that 😄  | 
||
| return new SqlEnclaveAttestationParameters(NoneAttestationProtocolId, Array.Empty<byte>(), clientDHKey); | ||
| } | ||
| 
     | 
||
| // 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. | ||
| // When overridden in a derived class, performs enclave attestation, generates a symmetric key for the session, creates an enclave session and stores the session information in the cache. | ||
| internal override void CreateEnclaveSession(byte[] attestationInfo, ECDiffieHellman clientDHKey, EnclaveSessionParameters enclaveSessionParameters, byte[] customData, int customDataLength, out SqlEnclaveSession sqlEnclaveSession, out long counter) | ||
| { | ||
| ////for simulator: enclave does not send public key, and sends an empty attestation info | ||
| //// The only non-trivial content it sends is the session setup info (DH pubkey of enclave) | ||
| // for None attestation: enclave does not send public key, and sends an empty attestation info | ||
| // The only non-trivial content it sends is the session setup info (DH pubkey of enclave) | ||
| 
     | 
||
| sqlEnclaveSession = null; | ||
| counter = 0; | ||
| 
        
          
        
         | 
    @@ -53,14 +46,14 @@ internal override void CreateEnclaveSession(byte[] attestationInfo, ECDiffieHell | |
| { | ||
| if (!string.IsNullOrEmpty(enclaveSessionParameters.AttestationUrl)) | ||
| { | ||
| ////Read AttestationInfo | ||
| // Read AttestationInfo | ||
| int attestationInfoOffset = 0; | ||
| uint sizeOfTrustedModuleAttestationInfoBuffer = BitConverter.ToUInt32(attestationInfo, attestationInfoOffset); | ||
| attestationInfoOffset += sizeof(UInt32); | ||
| int sizeOfTrustedModuleAttestationInfoBufferInt = checked((int)sizeOfTrustedModuleAttestationInfoBuffer); | ||
| Debug.Assert(sizeOfTrustedModuleAttestationInfoBuffer == 0); | ||
| 
     | 
||
| ////read secure session info | ||
| // read secure session info | ||
| uint sizeOfSecureSessionInfoResponse = BitConverter.ToUInt32(attestationInfo, attestationInfoOffset); | ||
| attestationInfoOffset += sizeof(UInt32); | ||
| 
     | 
||
| 
          
            
          
           | 
    ||
Uh oh!
There was an error while loading. Please reload this page.