Skip to content

Commit 451f79a

Browse files
authored
Use SCH_CREDENTIALS instead of SCHANNEL_CREDS (#111)
This change updates the Schannel platform code to use the newer SCH_CREDENTIALS struct instead of the legacy SCHANNEL_CREDS struct. Also added an -InitialBreak flag to test.ps1 which helps debugging.
1 parent 154ee7e commit 451f79a

File tree

3 files changed

+58
-19
lines changed

3 files changed

+58
-19
lines changed

build.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,10 @@ function Install-Azure-Dependencies {
134134
if ($IsWindows) {
135135
# Enable SChannel TLS 1.3 (client and server).
136136
$TlsServerKeyPath = "HKLM\System\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.3\Server"
137-
reg.exe add $TlsServerKeyPath /v DisabledByDefault /t REG_DWORD /d 1 /f | Out-Null
137+
# reg.exe add $TlsServerKeyPath /v DisabledByDefault /t REG_DWORD /d 1 /f | Out-Null
138138
reg.exe add $TlsServerKeyPath /v Enabled /t REG_DWORD /d 1 /f | Out-Null
139139
$TlsClientKeyPath = "HKLM\System\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.3\Client"
140-
reg.exe add $TlsClientKeyPath /v DisabledByDefault /t REG_DWORD /d 1 /f | Out-Null
140+
# reg.exe add $TlsClientKeyPath /v DisabledByDefault /t REG_DWORD /d 1 /f | Out-Null
141141
reg.exe add $TlsClientKeyPath /v Enabled /t REG_DWORD /d 1 /f | Out-Null
142142
# Make sure procdump is installed
143143
Install-ProcDump

src/platform/tls_schannel.c

Lines changed: 40 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
#include <winerror.h>
5050
#endif
5151

52+
#define SCHANNEL_USE_BLACKLISTS
5253
#include <schannel.h>
5354

5455
uint16_t QuicTlsTPHeaderSize = FIELD_OFFSET(SEND_GENERIC_TLS_EXTENSION, Buffer);
@@ -125,7 +126,12 @@ typedef struct QUIC_ACHA_CONTEXT {
125126
//
126127
// Holds the credentials configuration for the lifetime of the async call.
127128
//
128-
SCHANNEL_CRED Credentials;
129+
SCH_CREDENTIALS Credentials;
130+
131+
//
132+
// Holds TLS configuration for the lifetime of the async call.
133+
//
134+
TLS_PARAMETERS TlsParameter;
129135

130136
} QUIC_ACHA_CONTEXT;
131137
#endif
@@ -670,25 +676,35 @@ QuicTlsServerSecConfigCreate(
670676
goto Error;
671677
}
672678

673-
PSCHANNEL_CRED Credentials = &AchaContext->Credentials;
679+
PSCH_CREDENTIALS Credentials = &AchaContext->Credentials;
680+
Credentials->pTlsParameters = &AchaContext->TlsParameters;
681+
Credentials->cTlsParameters = 1;
674682
#else
675-
SCHANNEL_CRED LocalCredentials = { 0 };
676-
PSCHANNEL_CRED Credentials = &LocalCredentials;
683+
SCH_CREDENTIALS LocalCredentials = { 0 };
684+
TLS_PARAMETERS LocalTlsParameters = { 0 };
685+
PSCH_CREDENTIALS Credentials = &LocalCredentials;
686+
Credentials->pTlsParameters = &LocalTlsParameters;
687+
Credentials->cTlsParameters = 1;
677688
#endif
678689

679690
//
680691
// Initialize user/kernel-common configuration.
681692
//
682-
Credentials->dwVersion = SCHANNEL_CRED_VERSION;
683-
Credentials->grbitEnabledProtocols = SP_PROT_TLS1_3_SERVER;
684-
Credentials->cSupportedAlgs = 0;
685-
Credentials->palgSupportedAlgs = NULL;
693+
Credentials->dwVersion = SCH_CREDENTIALS_VERSION;
694+
Credentials->pTlsParameters->grbitDisabledProtocols = (DWORD) ~SP_PROT_TLS1_3_SERVER;
695+
Credentials->pTlsParameters->cAlpnIds = 0;
696+
Credentials->pTlsParameters->rgstrAlpnIds = NULL; // QUIC manages all the ALPN matching.
697+
Credentials->pTlsParameters->cDisabledCrypto = 0;
698+
//
699+
// TODO: Disallow AES_CCM_8 algorithm, which are undefined in the QUIC-TLS spec.
700+
//
701+
Credentials->pTlsParameters->pDisabledCrypto = NULL;
686702
Credentials->dwFlags |= SCH_CRED_NO_SYSTEM_MAPPER;
687703

688704
//
689-
// This flag is required to prevent the SSL BEAST attack.
705+
// This flag disables known-weak crypto algorithms.
690706
//
691-
Credentials->dwFlags |= SCH_SEND_AUX_RECORD;
707+
Credentials->dwFlags |= SCH_USE_STRONG_CRYPTO;
692708

693709
if (Flags & QUIC_SEC_CONFIG_FLAG_ENABLE_OCSP) {
694710
Credentials->dwFlags |= SCH_CRED_SNI_ENABLE_OCSP;
@@ -917,7 +933,8 @@ QuicTlsClientSecConfigCreate(
917933
)
918934
{
919935
TimeStamp CredExpiration;
920-
SCHANNEL_CRED SchannelCred = { 0 };
936+
TLS_PARAMETERS TlsParameters = { 0 };
937+
SCH_CREDENTIALS SchannelCred = { 0 };
921938
SECURITY_STATUS SecStatus;
922939
QUIC_STATUS Status = QUIC_STATUS_SUCCESS;
923940

@@ -936,6 +953,7 @@ QuicTlsClientSecConfigCreate(
936953
Config->RefCount = 1;
937954

938955
SchannelCred.dwFlags = SCH_CRED_NO_DEFAULT_CREDS;
956+
SchannelCred.dwFlags |= SCH_USE_STRONG_CRYPTO;
939957
if (Flags & QUIC_CERTIFICATE_FLAG_DISABLE_CERT_VALIDATION) {
940958
SchannelCred.dwFlags |= SCH_CRED_MANUAL_CRED_VALIDATION;
941959
} else if (Flags != 0) {
@@ -946,10 +964,17 @@ QuicTlsClientSecConfigCreate(
946964
SchannelCred.dwFlags |= SCH_CRED_MANUAL_CRED_VALIDATION;
947965
}
948966

949-
SchannelCred.grbitEnabledProtocols = SP_PROT_TLS1_3_CLIENT;
950-
SchannelCred.dwVersion = SCHANNEL_CRED_VERSION;
951-
SchannelCred.cSupportedAlgs = 0;
952-
SchannelCred.palgSupportedAlgs = NULL;
967+
TlsParameters.grbitDisabledProtocols = (DWORD) ~SP_PROT_TLS1_3_CLIENT;
968+
TlsParameters.cAlpnIds = 0;
969+
TlsParameters.rgstrAlpnIds = NULL; // Only used on server.
970+
TlsParameters.cDisabledCrypto = 0;
971+
//
972+
// TODO: Disallow AES_CCM_8 algorithm, which are undefined in the QUIC-TLS spec.
973+
//
974+
TlsParameters.pDisabledCrypto = NULL;
975+
SchannelCred.cTlsParameters = 1;
976+
SchannelCred.pTlsParameters = &TlsParameters;
977+
SchannelCred.dwVersion = SCH_CREDENTIALS_VERSION;
953978
#ifdef _KERNEL_MODE
954979
PSECURITY_STRING PackageName = (PSECURITY_STRING) &QuicTlsPackageName;
955980
#else

test.ps1

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ This script provides helpers for running executing the MsQuic tests.
3030
.PARAMETER Debugger
3131
Attaches the debugger to each test case run.
3232
33+
.PARAMETER InitialBreak
34+
Debugger starts broken into the process to allow setting breakpoints, etc.
35+
3336
.PARAMETER BreakOnFailure
3437
Triggers a break point on a test failure.
3538
@@ -92,6 +95,9 @@ param (
9295
[Parameter(Mandatory = $false)]
9396
[switch]$Debugger = $false,
9497

98+
[Parameter(Mandatory = $false)]
99+
[switch]$InitialBreak = $false,
100+
95101
[Parameter(Mandatory = $false)]
96102
[switch]$BreakOnFailure = $false,
97103

@@ -222,15 +228,23 @@ function Start-MsQuicTest([String]$Arguments, [String]$OutputDir) {
222228
if ($IsWindows) {
223229
if ($Debugger) {
224230
$pinfo.FileName = "windbg"
225-
$pinfo.Arguments = "-g -G $($MsQuicTest) $($Arguments)"
231+
if ($InitialBreak) {
232+
$pinfo.Arguments = "-G $($MsQuicTest) $($Arguments)"
233+
} else {
234+
$pinfo.Arguments = "-g -G $($MsQuicTest) $($Arguments)"
235+
}
226236
} else {
227237
$pinfo.FileName = $ProcDumpExe
228238
$pinfo.Arguments = "-ma -e -b -l -accepteula -x $($OutputDir) $($MsQuicTest) $($Arguments)"
229239
}
230240
} else {
231241
if ($Debugger) {
232242
$pinfo.FileName = "gdb"
233-
$pinfo.Arguments = "--args $MsQuicTest $Arguments"
243+
if ($InitialBreak) {
244+
$pinfo.Arguments = "--args $($MsQuicTest) $($Arguments)"
245+
} else {
246+
$pinfo.Arguments = "-ex=r --args $($MsQuicTest) $($Arguments)"
247+
}
234248
} else {
235249
$pinfo.FileName = $MsQuicTest
236250
$pinfo.Arguments = $Arguments

0 commit comments

Comments
 (0)