@@ -679,8 +679,7 @@ private async Task<PayloadData> SwitchAuthenticationAsync(ConnectionSettings cs,
679
679
}
680
680
681
681
// send the password as a NULL-terminated UTF-8 string
682
- var passwordBytes = Encoding . UTF8 . GetBytes ( password ) ;
683
- Array . Resize ( ref passwordBytes , passwordBytes . Length + 1 ) ;
682
+ var passwordBytes = AuthenticationUtility . GetNullTerminatedPasswordBytes ( password ) ;
684
683
payload = new ( passwordBytes ) ;
685
684
await SendReplyAsync ( payload , ioBehavior , cancellationToken ) . ConfigureAwait ( false ) ;
686
685
return await ReceiveReplyAsync ( ioBehavior , cancellationToken ) . ConfigureAwait ( false ) ;
@@ -736,8 +735,7 @@ private async Task<PayloadData> SwitchAuthenticationAsync(ConnectionSettings cs,
736
735
private async Task < PayloadData > SendClearPasswordAsync ( string password , IOBehavior ioBehavior , CancellationToken cancellationToken )
737
736
{
738
737
// add NUL terminator to password
739
- var passwordBytes = Encoding . UTF8 . GetBytes ( password ) ;
740
- Array . Resize ( ref passwordBytes , passwordBytes . Length + 1 ) ;
738
+ var passwordBytes = AuthenticationUtility . GetNullTerminatedPasswordBytes ( password ) ;
741
739
742
740
// send plaintext password
743
741
var payload = new PayloadData ( passwordBytes ) ;
@@ -780,8 +778,7 @@ private async Task<PayloadData> SendEncryptedPasswordAsync(
780
778
#endif
781
779
782
780
// add NUL terminator to password
783
- var passwordBytes = Encoding . UTF8 . GetBytes ( password ) ;
784
- Array . Resize ( ref passwordBytes , passwordBytes . Length + 1 ) ;
781
+ var passwordBytes = AuthenticationUtility . GetNullTerminatedPasswordBytes ( password ) ;
785
782
786
783
// XOR the password bytes with the challenge
787
784
AuthPluginData = Utility . TrimZeroByte ( switchRequestData ) ;
0 commit comments