Commit e700ecb 1 parent 8e13286 commit e700ecb Copy full SHA for e700ecb
File tree 2 files changed +36
-6
lines changed
SteamKit2/SteamKit2/Steam
2 files changed +36
-6
lines changed Original file line number Diff line number Diff line change @@ -137,16 +137,27 @@ public async Task<CredentialsAuthSession> BeginAuthSessionViaCredentialsAsync( A
137
137
throw new InvalidOperationException ( "The SteamClient instance must be connected." ) ;
138
138
}
139
139
140
- // Encrypt the password
141
- var publicKey = await GetPasswordRSAPublicKeyAsync ( details . Username ! ) . ConfigureAwait ( false ) ;
140
+ // Password limit.
141
+ const int MAX_PASSWORD_SIZE = 64 ;
142
+ if ( ! string . IsNullOrEmpty ( details . Password ) && details . Password . Length >= MAX_PASSWORD_SIZE )
143
+ {
144
+ DebugLog . WriteLine ( nameof ( SteamUser ) , $ "Notice: password is longer than { MAX_PASSWORD_SIZE } characters.") ;
145
+ }
142
146
143
- // Password limit is 64. If it's longer, trim it .
144
- if ( ! string . IsNullOrEmpty ( details . Password ) && details . Password . Length > 64 )
147
+ // Password Unicode check .
148
+ if ( details . Password != null )
145
149
{
146
- DebugLog . WriteLine ( nameof ( SteamAuthentication ) , "Notice: password is longer than 64 characters and will be trimmed." ) ;
147
- details . Password = details . Password . Substring ( 0 , 64 ) ;
150
+ for ( var i = 0 ; i < details . Password . Length ; i ++ )
151
+ {
152
+ if ( details . Password [ i ] > 127 )
153
+ {
154
+ throw new ArgumentException ( "Password contains non standard ASCII characters." ) ;
155
+ }
156
+ }
148
157
}
149
158
159
+ // Encrypt the password
160
+ var publicKey = await GetPasswordRSAPublicKeyAsync ( details . Username ! ) . ConfigureAwait ( false ) ;
150
161
var rsaParameters = new RSAParameters
151
162
{
152
163
Modulus = Utils . DecodeHexString ( publicKey . publickey_mod ) ,
Original file line number Diff line number Diff line change @@ -231,6 +231,25 @@ public void LogOn( LogOnDetails details )
231
231
throw new ArgumentException ( "LogOn requires a username and password or access token to be set in 'details'." ) ;
232
232
}
233
233
234
+ // Password limit.
235
+ const int MAX_PASSWORD_SIZE = 64 ;
236
+ if ( ! string . IsNullOrEmpty ( details . Password ) && details . Password . Length >= MAX_PASSWORD_SIZE )
237
+ {
238
+ DebugLog . WriteLine ( nameof ( SteamUser ) , $ "Notice: password is longer than { MAX_PASSWORD_SIZE } characters.") ;
239
+ }
240
+
241
+ // Password Unicode check.
242
+ if ( details . Password != null )
243
+ {
244
+ for ( var i = 0 ; i < details . Password . Length ; i ++ )
245
+ {
246
+ if ( details . Password [ i ] > 127 )
247
+ {
248
+ throw new ArgumentException ( "Password contains non standard ASCII characters." ) ;
249
+ }
250
+ }
251
+ }
252
+
234
253
if ( ! this . Client . IsConnected )
235
254
{
236
255
this . Client . PostCallback ( new LoggedOnCallback ( EResult . NoConnection ) ) ;
You can’t perform that action at this time.
0 commit comments