From 061832558e5e17b20a1f635809eab7fb8cf09934 Mon Sep 17 00:00:00 2001 From: LossyDragon Date: Sat, 4 May 2024 01:39:03 -0500 Subject: [PATCH] Remove spongycastle --- README.md | 8 +++----- build.gradle.kts | 2 +- .../steam/authentication/SteamAuthentication.kt | 3 ++- .../javasteam/util/crypto/CryptoHelper.java | 15 ++++----------- 4 files changed, 10 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 9d1b572b..4ac271cb 100644 --- a/README.md +++ b/README.md @@ -44,16 +44,14 @@ Maven ``` -**3. Add the appropriate cryptography dependency to your project. JavaSteam depends on this.** +**3. Add the cryptography dependency to your project. JavaSteam depends on this.** -[Android | Spongy Castle](https://mvnrepository.com/artifact/com.madgag.spongycastle/prov) - -[Non-Android | Bouncy Castle](https://mvnrepository.com/artifact/org.bouncycastle/bcprov-jdk18on) +[Bouncy Castle](https://mvnrepository.com/artifact/org.bouncycastle/bcprov-jdk18on) ## Getting Started -You can head to the very short [Getting Started](https://github.com/Longi94/JavaSteam/wiki/Getting-started) page or take a look at the [samples](https://github.com/Longi94/JavaSteam/tree/master/javasteam-samples/src/main/java/in/dragonbra/javasteamsamples) to get you started with using this library. +You can head to the very short [Getting Started](https://github.com/Longi94/JavaSteam/wiki/Getting-started) page or take a look at the [samples](https://github.com/Longi94/JavaSteam/tree/master/javasteam-samples/src/main/java/in/dragonbra/javasteamsamples) to get you started with using this library. There some [open-source projects](https://github.com/Longi94/JavaSteam/wiki/Samples) too you can check out. diff --git a/build.gradle.kts b/build.gradle.kts index 31caedb5..1c8dc4eb 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -16,7 +16,7 @@ plugins { allprojects { group = "in.dragonbra" - version = "1.4.0" + version = "1.4.1-SNAPSHOT" } repositories { diff --git a/src/main/java/in/dragonbra/javasteam/steam/authentication/SteamAuthentication.kt b/src/main/java/in/dragonbra/javasteam/steam/authentication/SteamAuthentication.kt index 36a820e9..3d9b4c5a 100644 --- a/src/main/java/in/dragonbra/javasteam/steam/authentication/SteamAuthentication.kt +++ b/src/main/java/in/dragonbra/javasteam/steam/authentication/SteamAuthentication.kt @@ -16,6 +16,7 @@ import `in`.dragonbra.javasteam.rpc.service.Authentication import `in`.dragonbra.javasteam.steam.handlers.steamunifiedmessages.SteamUnifiedMessages import `in`.dragonbra.javasteam.steam.steamclient.SteamClient import `in`.dragonbra.javasteam.types.SteamID +import `in`.dragonbra.javasteam.util.crypto.CryptoHelper import java.math.BigInteger import java.nio.charset.StandardCharsets import java.security.KeyFactory @@ -159,7 +160,7 @@ class SteamAuthentication(private val steamClient: SteamClient, unifiedMessages: val rsaPublicKeySpec = RSAPublicKeySpec(publicModulus, publicExponent) val publicKey = KeyFactory.getInstance("RSA").generatePublic(rsaPublicKeySpec) - val cipher = Cipher.getInstance("RSA/None/PKCS1Padding").apply { + val cipher = Cipher.getInstance("RSA/None/PKCS1Padding", CryptoHelper.SEC_PROV).apply { init(Cipher.ENCRYPT_MODE, publicKey) } diff --git a/src/main/java/in/dragonbra/javasteam/util/crypto/CryptoHelper.java b/src/main/java/in/dragonbra/javasteam/util/crypto/CryptoHelper.java index 3dfcbfc8..c25a4d97 100644 --- a/src/main/java/in/dragonbra/javasteam/util/crypto/CryptoHelper.java +++ b/src/main/java/in/dragonbra/javasteam/util/crypto/CryptoHelper.java @@ -31,17 +31,10 @@ public class CryptoHelper { static { try { - if (Utils.getOSType() == EOSType.AndroidUnknown) { - Class provider = - (Class) Class.forName("org.spongycastle.jce.provider.BouncyCastleProvider"); - Security.insertProviderAt(provider.getDeclaredConstructor().newInstance(), 1); - SEC_PROV = "SC"; - } else { - Class provider = - (Class) Class.forName("org.bouncycastle.jce.provider.BouncyCastleProvider"); - Security.addProvider(provider.getDeclaredConstructor().newInstance()); - SEC_PROV = "BC"; - } + Class provider = + (Class) Class.forName("org.bouncycastle.jce.provider.BouncyCastleProvider"); + Security.addProvider(provider.getDeclaredConstructor().newInstance()); + SEC_PROV = "BC"; } catch (Exception e) { throw new SecurityException("Couldn't create security provider", e); }