public RdpPacket_Localised receive(Rdp rdpLayer) throws RdesktopException,
			IOException, CryptoException, OrderException {
		int sec_flags = 0;
		RdpPacket_Localised buffer = null;
		while (true) {
			int[] channel = new int[1];
			GWT.log("new receive at MCS");
			buffer = McsLayer.receive(channel, rdpLayer);
			GWT.log("after receive at mcs");
			if (buffer == null)
				return null;
			buffer.setHeader(RdpPacket_Localised.SECURE_HEADER);
			if (Constants.encryption || (!this.licenceIssued)) {

				sec_flags = buffer.getLittleEndian32();

				if ((sec_flags & SEC_LICENCE_NEG) != 0) {
					licence.process(buffer, option);
					continue;
				}
				if ((sec_flags & SEC_ENCRYPT) != 0) {
					buffer.incrementPosition(8); // signature
					byte[] data = new byte[buffer.size() - buffer.getPosition()];
					buffer.copyToByteArray(data, 0, buffer.getPosition(),
							data.length);
					byte[] packet = this.decrypt(data);

					buffer.copyFromByteArray(packet, 0, buffer.getPosition(),
							packet.length);

					// buffer.setStart(buffer.getPosition());
					// return buffer;
				}
			}

			if (channel[0] != MCS.MCS_GLOBAL_CHANNEL) {
				channels.channel_process(buffer, channel[0]);
				continue;
			}

			buffer.setStart(buffer.getPosition());
			return buffer;
		}
	}