Skip to content

Commit 209a189

Browse files
committed
Remove trim. Add Unicode check.
Notify password length is greater 64. Throw an error since Steam does reject non standard ASCII characters. Move to SteamUser.cs.
1 parent 8e13286 commit 209a189

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

SteamKit2/SteamKit2/Steam/Authentication/SteamAuthentication.cs

-8
Original file line numberDiff line numberDiff line change
@@ -139,14 +139,6 @@ public async Task<CredentialsAuthSession> BeginAuthSessionViaCredentialsAsync( A
139139

140140
// Encrypt the password
141141
var publicKey = await GetPasswordRSAPublicKeyAsync( details.Username! ).ConfigureAwait( false );
142-
143-
// Password limit is 64. If it's longer, trim it.
144-
if (!string.IsNullOrEmpty(details.Password) && details.Password.Length > 64)
145-
{
146-
DebugLog.WriteLine(nameof(SteamAuthentication), "Notice: password is longer than 64 characters and will be trimmed.");
147-
details.Password = details.Password.Substring(0, 64);
148-
}
149-
150142
var rsaParameters = new RSAParameters
151143
{
152144
Modulus = Utils.DecodeHexString( publicKey.publickey_mod ),

SteamKit2/SteamKit2/Steam/Handlers/SteamUser/SteamUser.cs

+18
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,24 @@ public void LogOn( LogOnDetails details )
231231
throw new ArgumentException( "LogOn requires a username and password or access token to be set in 'details'." );
232232
}
233233

234+
// Password limit is 64.
235+
if (!string.IsNullOrEmpty(details.Password) && details.Password.Length > 64)
236+
{
237+
DebugLog.WriteLine(nameof(SteamUser), "Notice: password is longer than 64 characters and will be trimmed.");
238+
}
239+
240+
// Password Unicode check.
241+
if (details.Password != null)
242+
{
243+
for (var i = 0; i < details.Password.Length; i++)
244+
{
245+
if (details.Password[i] > 127)
246+
{
247+
throw new ArgumentException( "Password contains non standard ASCII characters." );
248+
}
249+
}
250+
}
251+
234252
if ( !this.Client.IsConnected )
235253
{
236254
this.Client.PostCallback( new LoggedOnCallback( EResult.NoConnection ) );

0 commit comments

Comments
 (0)