@SideOnly(Side.CLIENT) public Packet252SharedKey( SecretKey par1SecretKey, PublicKey par2PublicKey, byte[] par3ArrayOfByte) { this.sharedKey = par1SecretKey; this.sharedSecret = CryptManager.encryptData(par2PublicKey, par1SecretKey.getEncoded()); this.verifyToken = CryptManager.encryptData(par2PublicKey, par3ArrayOfByte); }
/** * Adds an encoder+decoder to the channel pipeline. The parameter is the secret key used for * encrypted communication */ public void enableEncryption(SecretKey key) { this.isEncrypted = true; this.channel .pipeline() .addBefore( "splitter", "decrypt", new NettyEncryptingDecoder(CryptManager.func_151229_a(2, key))); this.channel .pipeline() .addBefore( "prepender", "encrypt", new NettyEncryptingEncoder(CryptManager.func_151229_a(1, key))); }
/** Initialises the server and starts it. */ protected boolean startServer() throws IOException { logger.info("Starting integrated minecraft server version 1.7.2"); this.setOnlineMode(false); this.setCanSpawnAnimals(true); this.setCanSpawnNPCs(true); this.setAllowPvp(true); this.setAllowFlight(true); logger.info("Generating keypair"); this.setKeyPair(CryptManager.createNewKeyPair()); Object inst; if (Reflector.FMLCommonHandler_handleServerAboutToStart.exists()) { inst = Reflector.call(Reflector.FMLCommonHandler_instance, new Object[0]); if (!Reflector.callBoolean( inst, Reflector.FMLCommonHandler_handleServerAboutToStart, new Object[] {this})) { return false; } } this.loadAllWorlds( this.getFolderName(), this.getWorldName(), this.theWorldSettings.getSeed(), this.theWorldSettings.getTerrainType(), this.theWorldSettings.func_82749_j()); this.setMOTD( this.getServerOwner() + " - " + this.worldServers[0].getWorldInfo().getWorldName()); if (Reflector.FMLCommonHandler_handleServerStarting.exists()) { inst = Reflector.call(Reflector.FMLCommonHandler_instance, new Object[0]); if (Reflector.FMLCommonHandler_handleServerStarting.getReturnType() == Boolean.TYPE) { return Reflector.callBoolean( inst, Reflector.FMLCommonHandler_handleServerStarting, new Object[] {this}); } Reflector.callVoid( inst, Reflector.FMLCommonHandler_handleServerStarting, new Object[] {this}); } return true; }
/** Return verifyToken */ public byte[] getVerifyToken(PrivateKey par1PrivateKey) { return par1PrivateKey == null ? this.verifyToken : CryptManager.decryptData(par1PrivateKey, this.verifyToken); }
/** Return secretKey, decrypting it from the sharedSecret byte array if needed */ public SecretKey getSharedKey(PrivateKey par1PrivateKey) { return par1PrivateKey == null ? this.sharedKey : (this.sharedKey = CryptManager.decryptSharedKey(par1PrivateKey, this.sharedSecret)); }