@@ -42,12 +42,12 @@ public static SafeFreeCredentials AcquireCredentialsHandle(SslStreamCertificateC
4242return new SafeFreeSslCredentials ( certificateContext ? . Certificate , protocols , policy ) ;
4343}
4444
45- public static SecurityStatusPal EncryptMessage ( SafeDeleteContext securityContext , ReadOnlyMemory < byte > input , int headerSize , int trailerSize , ref byte [ ] output , out int resultSize )
45+ public static SecurityStatusPal EncryptMessage ( SafeDeleteSslContext securityContext , ReadOnlyMemory < byte > input , int headerSize , int trailerSize , ref byte [ ] output , out int resultSize )
4646{
4747return EncryptDecryptHelper ( securityContext , input , offset : 0 , size : 0 , encrypt : true , output : ref output , resultSize : out resultSize ) ;
4848}
4949
50- public static SecurityStatusPal DecryptMessage ( SafeDeleteContext securityContext , byte [ ] buffer , ref int offset , ref int count )
50+ public static SecurityStatusPal DecryptMessage ( SafeDeleteSslContext securityContext , byte [ ] buffer , ref int offset , ref int count )
5151{
5252SecurityStatusPal retVal = EncryptDecryptHelper ( securityContext , buffer , offset , count , false , ref buffer , out int resultSize ) ;
5353if ( retVal . ErrorCode == SecurityStatusPalErrorCode . OK ||
@@ -58,7 +58,7 @@ public static SecurityStatusPal DecryptMessage(SafeDeleteContext securityContext
5858return retVal ;
5959}
6060
61- public static ChannelBinding ? QueryContextChannelBinding ( SafeDeleteContext securityContext , ChannelBindingKind attribute )
61+ public static ChannelBinding ? QueryContextChannelBinding ( SafeDeleteSslContext securityContext , ChannelBindingKind attribute )
6262{
6363ChannelBinding ? bindingHandle ;
6464
@@ -74,7 +74,7 @@ public static SecurityStatusPal DecryptMessage(SafeDeleteContext securityContext
7474else
7575{
7676bindingHandle = Interop . OpenSsl . QueryChannelBinding (
77- ( ( SafeDeleteSslContext ) securityContext ) . SslContext ,
77+ securityContext . SslContext ,
7878attribute ) ;
7979}
8080
@@ -86,9 +86,9 @@ public static void QueryContextStreamSizes(SafeDeleteContext? securityContext, o
8686streamSizes = StreamSizes . Default ;
8787}
8888
89- public static void QueryContextConnectionInfo ( SafeDeleteContext securityContext , out SslConnectionInfo connectionInfo )
89+ public static void QueryContextConnectionInfo ( SafeDeleteSslContext securityContext , out SslConnectionInfo connectionInfo )
9090{
91- connectionInfo = new SslConnectionInfo ( ( ( SafeDeleteSslContext ) securityContext ) . SslContext ) ;
91+ connectionInfo = new SslConnectionInfo ( securityContext . SslContext ) ;
9292}
9393
9494public static byte [ ] ConvertAlpnProtocolListToByteArray ( List < SslApplicationProtocol > applicationProtocols )
@@ -111,13 +111,13 @@ private static SecurityStatusPal HandshakeInternal(SafeFreeCredentials credentia
111111context = new SafeDeleteSslContext ( ( credential as SafeFreeSslCredentials ) ! , sslAuthenticationOptions ) ;
112112}
113113
114- bool done = Interop . OpenSsl . DoSslHandshake ( ( ( SafeDeleteSslContext ) context ) . SslContext , inputBuffer , out output , out outputSize ) ;
114+ bool done = Interop . OpenSsl . DoSslHandshake ( context . SslContext , inputBuffer , out output , out outputSize ) ;
115115
116116// When the handshake is done, and the context is server, check if the alpnHandle target was set to null during ALPN.
117117// If it was, then that indicates ALPN failed, send failure.
118118// We have this workaround, as openssl supports terminating handshake only from version 1.1.0,
119119// whereas ALPN is supported from version 1.0.2.
120- SafeSslHandle sslContext = ( ( SafeDeleteSslContext ) context ) . SslContext ;
120+ SafeSslHandle sslContext = context . SslContext ;
121121if ( done && sslAuthenticationOptions . IsServer && sslAuthenticationOptions . ApplicationProtocols != null && sslContext . AlpnHandle . IsAllocated && sslContext . AlpnHandle . Target == null )
122122{
123123return new SecurityStatusPal ( SecurityStatusPalErrorCode . InternalError , Interop . OpenSsl . CreateSslException ( SR . net_alpn_failed ) ) ;
@@ -142,21 +142,21 @@ private static SecurityStatusPal HandshakeInternal(SafeFreeCredentials credentia
142142}
143143}
144144
145- internal static byte [ ] ? GetNegotiatedApplicationProtocol ( SafeDeleteContext ? context )
145+ internal static byte [ ] ? GetNegotiatedApplicationProtocol ( SafeDeleteSslContext ? context )
146146{
147147if ( context == null )
148148return null ;
149149
150- return Interop . Ssl . SslGetAlpnSelected ( ( ( SafeDeleteSslContext ) context ) . SslContext ) ;
150+ return Interop . Ssl . SslGetAlpnSelected ( context . SslContext ) ;
151151}
152152
153- private static SecurityStatusPal EncryptDecryptHelper ( SafeDeleteContext securityContext , ReadOnlyMemory < byte > input , int offset , int size , bool encrypt , ref byte [ ] output , out int resultSize )
153+ private static SecurityStatusPal EncryptDecryptHelper ( SafeDeleteSslContext securityContext , ReadOnlyMemory < byte > input , int offset , int size , bool encrypt , ref byte [ ] output , out int resultSize )
154154{
155155resultSize = 0 ;
156156try
157157{
158158Interop . Ssl . SslErrorCode errorCode = Interop . Ssl . SslErrorCode . SSL_ERROR_NONE ;
159- SafeSslHandle scHandle = ( ( SafeDeleteSslContext ) securityContext ) . SslContext ;
159+ SafeSslHandle scHandle = securityContext . SslContext ;
160160
161161if ( encrypt )
162162{
@@ -194,10 +194,8 @@ public static SecurityStatusPal ApplyAlertToken(ref SafeFreeCredentials? credent
194194return new SecurityStatusPal ( SecurityStatusPalErrorCode . OK ) ;
195195}
196196
197- public static SecurityStatusPal ApplyShutdownToken ( ref SafeFreeCredentials ? credentialsHandle , SafeDeleteContext securityContext )
197+ public static SecurityStatusPal ApplyShutdownToken ( ref SafeFreeCredentials ? credentialsHandle , SafeDeleteSslContext sslContext )
198198{
199- SafeDeleteSslContext sslContext = ( ( SafeDeleteSslContext ) securityContext ) ;
200-
201199// Unset the quiet shutdown option initially configured.
202200Interop . Ssl . SslSetQuietShutdown ( sslContext . SslContext , 0 ) ;
203201