45
45
#define READ_OUT_SIZE (16 * KB_1)
46
46
#define READ_IN_SIZE READ_OUT_SIZE
47
47
#define EST_HANDSHAKE_SIZE (7 * KB_1)
48
- #define WINDOWS_BUILD_1809 1809
48
+ #define WINDOWS_BUILD_17763 17763
49
49
50
50
#define EST_TLS_RECORD_OVERHEAD 53 /* 5 byte header + 32 + 16 bytes for padding */
51
51
@@ -142,20 +142,24 @@ static size_t s_message_overhead(struct aws_channel_handler *handler) {
142
142
return sc_handler -> stream_sizes .cbTrailer + sc_handler -> stream_sizes .cbHeader ;
143
143
}
144
144
145
- /* Checks whether current system is running Windows 10 version `build_number` or later. This check is used
146
- to determin availability of TLS 1.3. This will continue to be a valid check in Windows 11 and later as the
147
- build number continues to increment upwards. e.g. Windows 11 starts at version 21H2 (build 22_000) */
148
- static bool s_is_windows_equal_or_above_version ( DWORD build_number ) {
149
- ULONGLONG dwlConditionMask = 0 ;
150
- BYTE op = VER_GREATER_EQUAL ;
151
- OSVERSIONINFOEX osvi ;
152
-
145
+ /* Checks whether the current system is running Windows of a specific build number or later.
146
+ *
147
+ * This check is used to determine the availability of TLS 1.3. This will continue to be a valid check in the future
148
+ * versions of Windows as the build number continues to increment upwards. E.g., Windows 11 starts at build 22000.
149
+ *
150
+ * For more information see https://learn.microsoft.com/en-us/windows/release-health/release-information and
151
+ * https://learn.microsoft.com/en-us/windows/release-health/windows11-release-information */
152
+ static bool s_is_windows_equal_or_above_build_number ( DWORD build_number ) {
153
153
NTSTATUS status = STATUS_DLL_NOT_FOUND ;
154
154
155
+ OSVERSIONINFOEX osvi ;
155
156
ZeroMemory (& osvi , sizeof (OSVERSIONINFOEX ));
157
+
156
158
osvi .dwOSVersionInfoSize = sizeof (OSVERSIONINFOEX );
157
159
osvi .dwBuildNumber = build_number ;
158
160
161
+ ULONGLONG dwlConditionMask = 0 ;
162
+ BYTE op = VER_GREATER_EQUAL ;
159
163
dwlConditionMask = VerSetConditionMask (dwlConditionMask , VER_BUILDNUMBER , op );
160
164
typedef NTSTATUS (WINAPI * pRtlGetVersionInfo )(
161
165
OSVERSIONINFOEX * lpVersionInformation , ULONG TypeMask , ULONGLONG ConditionMask );
@@ -2142,8 +2146,10 @@ static DWORD s_get_enabled_protocols(enum aws_tls_versions minimum_tls_version,
2142
2146
return bit_enabled_protocols ;
2143
2147
}
2144
2148
2145
- static struct aws_channel_handler * s_tls_handler_sch_credentials_new (
2149
+ #if NTDDI_VERSION >= 0x0A000006 /* Windows SDK 10.1.17763.0 or later */
2146
2150
2151
+ /* The SCH_CREDENTIALS and few other structures became available starting with Windows SDK 10.1.17763.0. */
2152
+ static struct aws_channel_handler * s_tls_handler_sch_credentials_new (
2147
2153
struct aws_allocator * alloc ,
2148
2154
struct aws_tls_connection_options * options ,
2149
2155
struct aws_channel_slot * slot ,
@@ -2193,7 +2199,7 @@ static struct aws_channel_handler *s_tls_handler_sch_credentials_new(
2193
2199
& sc_handler -> sspi_timestamp );
2194
2200
2195
2201
if (status != SEC_E_OK ) {
2196
- AWS_LOGF_ERROR (AWS_LS_IO_TLS , "Error on AcquireCredentialsHandle. SECURITY_STATUS is %d " , (int )status );
2202
+ AWS_LOGF_ERROR (AWS_LS_IO_TLS , "Error on AcquireCredentialsHandle. SECURITY_STATUS is 0x%X " , (int )status );
2197
2203
int aws_error = s_determine_sspi_error (status );
2198
2204
aws_raise_error (aws_error );
2199
2205
goto on_error ;
@@ -2208,6 +2214,8 @@ static struct aws_channel_handler *s_tls_handler_sch_credentials_new(
2208
2214
return NULL ;
2209
2215
}
2210
2216
2217
+ #endif /* NTDDI_VERSION >= 0x0A000006 */
2218
+
2211
2219
static struct aws_channel_handler * s_tls_handler_schannel_cred_new (
2212
2220
struct aws_allocator * alloc ,
2213
2221
struct aws_tls_connection_options * options ,
@@ -2281,10 +2289,12 @@ static struct aws_channel_handler *s_tls_handler_new(
2281
2289
struct aws_channel_slot * slot ,
2282
2290
bool is_client_mode ) {
2283
2291
2292
+ #if NTDDI_VERSION >= 0x0A000006 /* Windows SDK 10.1.17763.0 or later */
2284
2293
/* check if run on Windows 10 build 1809, (build 17_763) */
2285
- if (s_is_windows_equal_or_above_version ( WINDOWS_BUILD_1809 ) && !s_use_schannel_creds ) {
2294
+ if (s_is_windows_equal_or_above_build_number ( WINDOWS_BUILD_17763 ) && !s_use_schannel_creds ) {
2286
2295
return s_tls_handler_sch_credentials_new (alloc , options , slot , is_client_mode );
2287
2296
}
2297
+ #endif
2288
2298
return s_tls_handler_schannel_cred_new (alloc , options , slot , is_client_mode );
2289
2299
}
2290
2300
0 commit comments