mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-01-07 00:23:20 +08:00
security: add secure mode and padding scheme
This commit is contained in:
parent
c313939ec0
commit
63fbe66158
@ -103,7 +103,7 @@ public final class DefaultAuthenticators {
|
|||||||
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
|
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
|
||||||
RSAPrivateKey private_key = (RSAPrivateKey) keyFactory.generatePrivate(keySpec);
|
RSAPrivateKey private_key = (RSAPrivateKey) keyFactory.generatePrivate(keySpec);
|
||||||
|
|
||||||
Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");
|
Cipher cipher = Cipher.getInstance("RSA/ECB/OAEPWithSHA-256AndMGF1Padding");
|
||||||
|
|
||||||
cipher.init(Cipher.DECRYPT_MODE, private_key);
|
cipher.init(Cipher.DECRYPT_MODE, private_key);
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ public class HandlerGetPlayerTokenReq extends PacketHandler {
|
|||||||
if (req.getKeyId() > 0) {
|
if (req.getKeyId() > 0) {
|
||||||
var encryptSeed = session.getEncryptSeed();
|
var encryptSeed = session.getEncryptSeed();
|
||||||
try {
|
try {
|
||||||
var cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");
|
var cipher = Cipher.getInstance("RSA/ECB/OAEPWithSHA-256AndMGF1Padding");
|
||||||
cipher.init(Cipher.DECRYPT_MODE, Crypto.CUR_SIGNING_KEY);
|
cipher.init(Cipher.DECRYPT_MODE, Crypto.CUR_SIGNING_KEY);
|
||||||
|
|
||||||
var clientSeedEncrypted = Utils.base64Decode(req.getClientRandKey());
|
var clientSeedEncrypted = Utils.base64Decode(req.getClientRandKey());
|
||||||
|
@ -10,6 +10,7 @@ import java.security.spec.*;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import javax.crypto.Cipher;
|
import javax.crypto.Cipher;
|
||||||
|
import javax.crypto.NoSuchPaddingException;
|
||||||
|
|
||||||
public final class Crypto {
|
public final class Crypto {
|
||||||
|
|
||||||
@ -100,8 +101,8 @@ public final class Crypto {
|
|||||||
if (key_id == null) {
|
if (key_id == null) {
|
||||||
throw new Exception("Key ID was not set");
|
throw new Exception("Key ID was not set");
|
||||||
}
|
}
|
||||||
|
Cipher cipher = Cipher.getInstance("RSA/ECB/OAEPWithSHA-256AndMGF1Padding");
|
||||||
|
|
||||||
Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");
|
|
||||||
cipher.init(Cipher.ENCRYPT_MODE, EncryptionKeys.get(Integer.valueOf(key_id)));
|
cipher.init(Cipher.ENCRYPT_MODE, EncryptionKeys.get(Integer.valueOf(key_id)));
|
||||||
|
|
||||||
// Encrypt regionInfo in chunks
|
// Encrypt regionInfo in chunks
|
||||||
|
Loading…
Reference in New Issue
Block a user