aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--LICENSE12
-rwxr-xr-xgradlew.bat2
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/Authenticator.java295
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/DGInterface.java (renamed from src/main/java/kr/syeyoung/dungeonsguide/c.java)2
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/DungeonsGuide.java (renamed from src/main/java/kr/syeyoung/dungeonsguide/e.java)28
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/Main.java (renamed from src/main/java/kr/syeyoung/dungeonsguide/a.java)60
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/RichPresenceManager.java8
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/b.java295
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/commands/CommandDungeonsGuide.java24
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/dungeon/DungeonContext.java15
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/dungeon/MapProcessor.java34
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/dungeon/doorfinder/CatacombDataProvider.java4
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/dungeon/doorfinder/CatacombMasterDataProvider.java4
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoomInfoRegistry.java1
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/eventlistener/DungeonListener.java28
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/eventlistener/FeatureListener.java54
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/eventlistener/PacketListener.java7
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/impl/advanced/FeatureDebuggableMap.java10
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/impl/advanced/FeatureRoomCoordDisplay.java7
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/impl/advanced/FeatureRoomDebugInfo.java11
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureAutoReparty.java19
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureBossHealth.java16
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureBoxRealLivid.java12
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureChestPrice.java5
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureCurrentPhase.java6
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureHideAnimals.java11
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureTerracotaTimer.java5
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureThornBearPercentage.java11
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureThornSpiritBowTimer.java4
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/FeatureWarningOnPortal.java4
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/terminal/FeatureSimonSaysSolver.java4
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureBoxBats.java6
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureBoxSkelemaster.java6
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureBoxStarMobs.java5
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonCurrentRoomSecrets.java12
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonDeaths.java17
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonMap.java13
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonMilestone.java13
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonRealTime.java15
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonSBTime.java13
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonScore.java12
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonSecrets.java16
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonTombs.java10
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureHideNameTags.java7
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeaturePlayerESP.java20
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeaturePressAnyKeyToCloseChest.java7
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureWarnLowHealth.java16
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureWatcherWarning.java11
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/FeatureAutoAcceptReparty.java15
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/FeatureCooldownCounter.java6
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/FeatureDecreaseExplosionSound.java4
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/FeatureDisableMessage.java4
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/FeaturePenguins.java8
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/FeatureUpdateAlarm.java4
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/ability/FeatureAbilityCooldown.java4
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureActions.java12
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureFreezePathfind.java20
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureMechanicBrowse.java5
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureSoulRoomWarning.java27
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/party/PartyInviteViewer.java14
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/party/PartyManager.java18
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/resources/DGTexturePack.java11
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/GeneralEditPane.java5
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/roomprocessor/GeneralRoomProcessor.java18
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/RoomProcessorBombDefuseSolver.java6
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bombdefuse/chambers/color/ColorRightProcessor.java6
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bossfight/BossfightProcessorThorn.java8
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/url/DGConnection.java (renamed from src/main/java/kr/syeyoung/dungeonsguide/d/a.java)22
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/url/DGStreamHandler.java (renamed from src/main/java/kr/syeyoung/dungeonsguide/d/b.java)11
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/url/DGStreamHandlerFactory.java (renamed from src/main/java/kr/syeyoung/dungeonsguide/d/c.java)13
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/utils/AhUtils.java5
71 files changed, 553 insertions, 890 deletions
diff --git a/LICENSE b/LICENSE
index 0ad25db4..2aad3fa5 100644
--- a/LICENSE
+++ b/LICENSE
@@ -111,7 +111,7 @@ is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
-Component, and (b) serves only to enable use of the work with that
+Component, and (Authenticator) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
@@ -202,7 +202,7 @@ terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
- b) The work must carry prominent notices stating that it is
+ Authenticator) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
@@ -242,7 +242,7 @@ in one of these ways:
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
- b) Convey the object code in, or embodied in, a physical product
+ Authenticator) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
@@ -353,7 +353,7 @@ that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
- b) Requiring preservation of specified reasonable legal notices or
+ Authenticator) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
@@ -403,7 +403,7 @@ paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
-finally terminates your license, and (b) permanently, if the copyright
+finally terminates your license, and (Authenticator) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
@@ -516,7 +516,7 @@ to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
-conveyed by you (or copies made from those copies), or (b) primarily
+conveyed by you (or copies made from those copies), or (Authenticator) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
diff --git a/gradlew.bat b/gradlew.bat
index f9553162..c1a768de 100755
--- a/gradlew.bat
+++ b/gradlew.bat
@@ -76,7 +76,7 @@ if "%ERRORLEVEL%"=="0" goto mainEnd
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
-exit /b 1
+exit /Authenticator 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/Authenticator.java b/src/main/java/kr/syeyoung/dungeonsguide/Authenticator.java
new file mode 100755
index 00000000..44e0908c
--- /dev/null
+++ b/src/main/java/kr/syeyoung/dungeonsguide/Authenticator.java
@@ -0,0 +1,295 @@
+/*
+ * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod
+ * Copyright (C) 2021 cyoung06
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published
+ * by the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+package kr.syeyoung.dungeonsguide;
+
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParser;
+import com.mojang.authlib.GameProfile;
+import com.mojang.authlib.exceptions.AuthenticationException;
+import com.mojang.authlib.minecraft.MinecraftSessionService;
+import net.minecraft.client.Minecraft;
+import net.minecraft.util.Session;
+import net.minecraftforge.fml.common.ProgressManager;
+import org.apache.commons.codec.binary.Base64;
+
+import javax.crypto.*;
+import javax.crypto.spec.IvParameterSpec;
+import javax.crypto.spec.SecretKeySpec;
+import javax.net.ssl.*;
+import java.io.*;
+import java.math.BigInteger;
+import java.net.*;
+import java.security.*;
+import java.security.cert.CertificateException;
+import java.security.spec.InvalidKeySpecException;
+import java.security.spec.X509EncodedKeySpec;
+import java.util.HashMap;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+
+public class Authenticator {
+ private KeyPair rsaKey;
+ private String token;
+ private final ProgressManager.ProgressBar progressBar;
+
+ public String getToken() {
+ return token;
+ }
+
+ private KeyPair getKeyPair() {
+ KeyPairGenerator a = null;
+ try {
+ a = KeyPairGenerator.getInstance("RSA");
+ } catch (NoSuchAlgorithmException b) { }
+ a.initialize(1024);
+ this.rsaKey = a.generateKeyPair();
+ return this.rsaKey;
+ }
+
+ private PublicKey dgPublicKey;
+ private PublicKey getDGPublicKey() throws NoSuchAlgorithmException, InvalidKeySpecException {
+ if (dgPublicKey != null) return dgPublicKey;
+ X509EncodedKeySpec spec = new X509EncodedKeySpec(Base64.decodeBase64("MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAxO89qtwG67jNucQ9Y44c" +
+ "IUs/B+5BeJPs7G+RG2gfs4/2+tzF/c1FLDc33M7yKw8aKk99vsBUY9Oo8gxxiEPB" +
+ "JitP/qfon2THp94oM77ZTpHlmFoqbZMcKGZVI8yfvEL4laTM8Hw+qh5poQwtpEbK" +
+ "Xo47AkxygxJasUnykER2+aSTZ6kWU2D4xiNtFA6lzqN+/oA+NaYfPS0amAvyVlHR" +
+ "n/8IuGkxb5RrlqVssQstFnxsJuv88qdGSEqlcKq2tLeg9hb8eCnl2OFzvXmgbVER" +
+ "0JaV+4Z02fVG1IlR3Xo1mSit7yIU6++3usRCjx2yfXpnGGJUW5pe6YETjNew3ax+" +
+ "FAZ4GePWCdmS7FvBnbbABKo5pE06ZTfDUTCjQlAJQiUgoF6ntMJvQAXPu48Vr8q/" +
+ "mTcuZWVnI6CDgyE7nNq3WNoq3397sBzxRohMxuqzl3T19zkfPKF05iV2Ju1HQMW5" +
+ "I119bYrmVD240aGESZc20Sx/9g1BFpNzQbM5PGUlWJ0dhLjl2ge4ip2hHciY3OEY" +
+ "p2Qy2k+xEdenpKdL+WMRimCQoO9gWe2Tp4NmP5dppDXZgPjXqjZpnGs0Uxs+fXqW" +
+ "cwlg3MbX3rFl9so/fhVf4p9oXZK3ve7z5D6XSSDRYECvsKIa08WAxJ/U6n204E/4" +
+ "xUF+3ZgFPdzZGn2PU7SsnOsCAwEAAQ=="));
+ return dgPublicKey = KeyFactory.getInstance("RSA").generatePublic(spec);
+ }
+
+ public Authenticator(ProgressManager.ProgressBar progressBar) {
+ this.progressBar = progressBar;
+ progressBar.step("Generating KeyPair");
+ getKeyPair();
+ }
+
+ public String authenticateAndDownload(String version) throws IOException, AuthenticationException, NoSuchAlgorithmException, CertificateException, KeyStoreException, KeyManagementException, InvalidKeySpecException, SignatureException {
+ Session session = Minecraft.getMinecraft().getSession();
+ String sessionToken = session.getToken();
+
+ progressBar.step("Authenticating (1/2)");
+ String tempToken = requestAuth(session.getProfile());
+ MinecraftSessionService yggdrasilMinecraftSessionService = Minecraft.getMinecraft().getSessionService();
+ JsonObject d = getJwtPayload(tempToken);
+ String hash = calculateServerHash(Base64.decodeBase64(d.get("sharedSecret").getAsString()),
+ Base64.decodeBase64(d.get("publicKey").getAsString()));
+ yggdrasilMinecraftSessionService.joinServer(session.getProfile(), sessionToken, hash);
+ progressBar.step("Authenticating (2/2)");
+ this.token = verifyAuth(tempToken, this.rsaKey.getPublic());
+ try {
+ progressBar.step("Downloading Jar");
+ if (version != null)
+ downloadSafe(this.token, "https://dungeons.guide/resource/version?v=" + version, true);
+ progressBar.step("Downloading Rooms");
+ downloadSafe(this.token, "https://dungeons.guide/resource/roomdata", false);
+ } catch (Throwable t) {
+ t.printStackTrace();
+ }
+ return this.token;
+ }
+
+ public JsonObject getJwtPayload(String jwt) {
+ String midPart = jwt.split("\\.")[1].replace("+", "-").replace("/", "_");
+ String base64Decode = new String(Base64.decodeBase64(midPart)); // padding
+ return (JsonObject) new JsonParser().parse(base64Decode);
+ }
+
+
+
+ private String requestAuth(GameProfile profile) throws IOException, NoSuchAlgorithmException, CertificateException, KeyStoreException, KeyManagementException {
+ HttpsURLConnection connection = (HttpsURLConnection) new URL("https://dungeons.guide/auth/requestAuth").openConnection();
+ connection.setRequestProperty("User-Agent", "DungeonsGuide/1.0");
+ connection.setRequestProperty("Content-Type", "application/json");
+ connection.setRequestMethod("POST");
+ connection.setDoInput(true);
+ connection.setDoOutput(true);
+
+ connection.getOutputStream().write(("{\"uuid\":\""+profile.getId().toString()+"\",\"nickname\":\""+profile.getName()+"\"}").getBytes());
+ InputStreamReader inputStreamReader = new InputStreamReader(connection.getInputStream());
+ JsonObject json = (JsonObject) new JsonParser().parse(inputStreamReader);
+ if (!"ok".equals(json.get("status").getAsString())) {
+ return null;
+ }
+ return json.get("data").getAsString();
+ }
+ private String verifyAuth(String tempToken, PublicKey clientKey) throws IOException {
+ HttpsURLConnection urlConnection = (HttpsURLConnection) new URL("https://dungeons.guide/auth/authenticate").openConnection();
+ urlConnection.setRequestMethod("POST");
+ urlConnection.setRequestProperty("User-Agent", "DungeonsGuide/1.0");
+ urlConnection.setRequestProperty("Content-Type", "application/json");
+ urlConnection.setDoInput(true);
+ urlConnection.setDoOutput(true);
+
+ urlConnection.getOutputStream().write(("{\"jwt\":\""+tempToken+"\",\"publicKey\":\""+Base64.encodeBase64URLSafeString(clientKey.getEncoded())+"\"}").getBytes());
+ urlConnection.getResponseCode();
+ InputStreamReader reader = new InputStreamReader(urlConnection.getInputStream());
+ JsonObject jsonObject = (JsonObject) new JsonParser().parse(reader);
+ if (!"ok".equals(jsonObject.get("status").getAsString())) {
+ return null;
+ }
+ return jsonObject.get("data").getAsString();
+ }
+
+ private final HashMap<String, byte[]> loadedResources = new HashMap<String, byte[]>();
+
+ public HashMap<String, byte[]> getResources() {
+ return loadedResources;
+ }
+
+ private void downloadSafe(String dgToken, String url, boolean isValidateSignature) throws IOException, NoSuchPaddingException, NoSuchAlgorithmException, InvalidKeyException, BadPaddingException, IllegalBlockSizeException, InvalidAlgorithmParameterException, CertificateException, KeyStoreException, KeyManagementException, SignatureException, InvalidKeySpecException {
+ HttpsURLConnection dgConnection = (HttpsURLConnection) new URL(url).openConnection();
+ dgConnection.setRequestProperty("User-Agent", "DungeonsGuide/1.0");
+ dgConnection.setRequestProperty("Content-Type", "application/json");
+ dgConnection.setRequestMethod("GET");
+ dgConnection.setRequestProperty("Authorization", dgToken);
+ dgConnection.setDoInput(true);
+ dgConnection.setDoOutput(true);
+
+ InputStream inputStream = dgConnection.getInputStream();
+ byte[] lengthBytes = new byte[4];
+ inputStream.read(lengthBytes);
+ int length = ((lengthBytes[0] & 0xFF) << 24) |
+ ((lengthBytes[1] & 0xFF) << 16) |
+ ((lengthBytes[2] & 0xFF) << 8) |
+ ((lengthBytes[3] & 0xFF));
+ while (inputStream.available() < length) ;
+ byte[] keyPayload = new byte[length];
+ inputStream.read(keyPayload);
+
+ Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");
+ cipher.init(Cipher.DECRYPT_MODE, this.rsaKey.getPrivate());
+ byte[] h = cipher.doFinal(keyPayload);
+
+ cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
+ SecretKeySpec keySpec = new SecretKeySpec(h, "AES");
+ IvParameterSpec ivSpec = new IvParameterSpec(h);
+ cipher.init(Cipher.DECRYPT_MODE, keySpec, ivSpec);
+ CipherInputStream cipherInputStream = new CipherInputStream(inputStream, cipher);
+
+ cipherInputStream.read(lengthBytes);
+ length = ((lengthBytes[0] & 0xFF) << 24) |
+ ((lengthBytes[1] & 0xFF) << 16) |
+ ((lengthBytes[2] & 0xFF) << 8) |
+ ((lengthBytes[3] & 0xFF));
+
+ int totalLen = length;
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ byte[] buff = new byte[256];
+ while (totalLen > 0) {
+ int len = cipherInputStream.read(buff, 0, Math.min(buff.length, totalLen));
+ totalLen -= len;
+ bos.write(buff, 0, len);
+ }
+ byte[] body = bos.toByteArray();
+
+ byte[] signed = null;
+ if (isValidateSignature) {
+ progressBar.step("Validating Signature");
+ cipherInputStream.read(lengthBytes,0 , 4);
+ length = ((lengthBytes[0] & 0xFF) << 24) |
+ ((lengthBytes[1] & 0xFF) << 16) |
+ ((lengthBytes[2] & 0xFF) << 8) |
+ ((lengthBytes[3] & 0xFF));
+
+ totalLen = length;
+