function biggestPowerOfTwo(num) { if (num.compareTo(zero) === 0) return zero; const power = bigint(String(num.toString(2).length - 1)); return two.pow(power); }
function generateSecretKey(session, packet) { const cipherPublicKey = packet.readString(); const sharedKey = HabboEncryption.calculateDiffieHellmanSharedKey(cipherPublicKey); if (sharedKey.equals(BigInteger.ZERO)) { return; } session.enableRC4(sharedKey.toByteArray()); session.sendPacket(new CompleteDiffieHandshakeComposer(HabboEncryption.PublicKey.toString())); }
function calculateDiffieHellmanSharedKey(cipherKey) { const publicKey = Rsa.decrypt(cipherKey); const publicClientKey = new BigInteger(publicKey, 10); return publicClientKey.modPow(Rsa.d, prime); }
for (;;) { this.p = new BigInteger(B - qs, 1, rng); if (this.p.subtract(BigInteger.ONE) .gcd(ee) .compareTo(BigInteger.ONE) == 0 && this.p.isProbablePrime(10)) break if (this.q.subtract(BigInteger.ONE) .gcd(ee) .compareTo(BigInteger.ONE) == 0 && this.q.isProbablePrime(10)) break this.q = t var p1 = this.p.subtract(BigInteger.ONE); var q1 = this.q.subtract(BigInteger.ONE); var phi = p1.multiply(q1); if (phi.gcd(ee) .compareTo(BigInteger.ONE) == 0) { this.n = this.p.multiply(this.q); this.d = ee.modInverse(phi); this.dmp1 = this.d.mod(p1); this.dmq1 = this.d.mod(q1);
biggest = biggest.divide(two); start = part.end.divide(biggest).subtract(one).multiply(biggest);