-
Notifications
You must be signed in to change notification settings - Fork 9
Add GUI #256
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
feat: gui project
| // Send password | ||
| using var rsa = new RSACryptoServiceProvider(); | ||
| rsa.FromXmlString(rsaPublicKey.Key); | ||
| await _sender!.SendPacketAsync(ConnectionVerifyPackets.Password, new PasswordPacket { PasswordData = rsa.Encrypt(_hashedPassword, false) }, false, token); |
Check failure
Code scanning / CodeQL
Weak encryption: inadequate RSA padding High
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 9 months ago
To fix the problem, we need to replace the insecure PKCS#1 v1.5 padding with the more secure PKCS#1 v2 (OAEP) padding. This involves changing the rsa.Encrypt method call to use OAEP padding.
- Update the
rsa.Encryptmethod call to use OAEP padding by passingtrueinstead offalse. - Ensure that the decryption process also uses OAEP padding by updating the
rsa.Decryptmethod call accordingly.
-
Copy modified line R196 -
Copy modified line R213
| @@ -195,3 +195,3 @@ | ||
| rsa.FromXmlString(rsaPublicKey.Key); | ||
| await _sender!.SendPacketAsync(ConnectionVerifyPackets.Password, new PasswordPacket { PasswordData = rsa.Encrypt(_hashedPassword, false) }, false, token); | ||
| await _sender!.SendPacketAsync(ConnectionVerifyPackets.Password, new PasswordPacket { PasswordData = rsa.Encrypt(_hashedPassword, RSAEncryptionPadding.OaepSHA1) }, false, token); | ||
|
|
||
| @@ -212,3 +212,3 @@ | ||
| //if (type is not ConnectionVerifyPackets.AesKey) throw new InvalidOperationException("Failed to recive aes key."); | ||
| byte[] key = _cryptoServiceProvider.Decrypt(aesKeyPacket.Key, false); | ||
| byte[] key = _cryptoServiceProvider.Decrypt(aesKeyPacket.Key, RSAEncryptionPadding.OaepSHA1); | ||
|
|
| using var rsa = new RSACryptoServiceProvider(); | ||
| rsa.FromXmlString(rsaPublicKey.Key); | ||
| byte[] key = Guid.NewGuid().ToByteArray(); | ||
| await _sender.SendPacketAsync(ConnectionVerifyPackets.AesKey, new AESKeyPacket { Key = rsa.Encrypt(key, false) }, false, token); |
Check failure
Code scanning / CodeQL
Weak encryption: inadequate RSA padding High
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 9 months ago
To fix the problem, we need to change the padding scheme used in the RSA encryption from PKCS#1 v1.5 to PKCS#1 v2 (OAEP). This involves modifying the rsa.Encrypt method call to use OAEP padding.
- Update the
rsa.Encryptmethod call to use OAEP padding by passingtrueinstead offalse. - Ensure that the rest of the code remains unchanged to maintain existing functionality.
-
Copy modified line R253
| @@ -252,3 +252,3 @@ | ||
| byte[] key = Guid.NewGuid().ToByteArray(); | ||
| await _sender.SendPacketAsync(ConnectionVerifyPackets.AesKey, new AESKeyPacket { Key = rsa.Encrypt(key, false) }, false, token); | ||
| await _sender.SendPacketAsync(ConnectionVerifyPackets.AesKey, new AESKeyPacket { Key = rsa.Encrypt(key, RSAEncryptionPadding.OaepSHA1) }, false, token); | ||
|
|
What does this PR do?
Which issues does this PR resolve?
Checklist before merging
Thank you for your contribution to the repository.
Before submitting this PR, please make sure: