public void send_request(byte[] client_random, byte[] rsa_data,
			byte[] username, byte[] hostname) throws RdesktopException,
			IOException, CryptoException {
		int sec_flags = Secure.SEC_LICENCE_NEG;
		int userlen = (username.length == 0 ? 0 : username.length + 1);
		int hostlen = (hostname.length == 0 ? 0 : hostname.length + 1);
		int length = 128 + userlen + hostlen;

		RdpPacket_Localised buffer = secure.init(sec_flags, length);

		buffer.set8(LICENCE_TAG_REQUEST);
		buffer.set8(2); // version
		buffer.setLittleEndian16(length);

		buffer.setLittleEndian32(1);

		if (Options.built_in_licence && (!Options.load_licence)
				&& (!Options.save_licence)) {
			logger.debug("Using built-in Windows Licence");
			buffer.setLittleEndian32(0x03010000);
		} else {
			logger.debug("Requesting licence");
			buffer.setLittleEndian32(0xff010000);
		}
		buffer.copyFromByteArray(client_random, 0, buffer.getPosition(),
				Secure.SEC_RANDOM_SIZE);
		buffer.incrementPosition(Secure.SEC_RANDOM_SIZE);
		buffer.setLittleEndian16(0);

		buffer.setLittleEndian16(Secure.SEC_MODULUS_SIZE
				+ Secure.SEC_PADDING_SIZE);
		buffer.copyFromByteArray(rsa_data, 0, buffer.getPosition(),
				Secure.SEC_MODULUS_SIZE);
		buffer.incrementPosition(Secure.SEC_MODULUS_SIZE);

		buffer.incrementPosition(Secure.SEC_PADDING_SIZE);

		buffer.setLittleEndian16(LICENCE_TAG_USER);
		buffer.setLittleEndian16(userlen);

		if (username.length != 0) {
			buffer.copyFromByteArray(username, 0, buffer.getPosition(),
					userlen - 1);
		} else {
			buffer
					.copyFromByteArray(username, 0, buffer.getPosition(),
							userlen);
		}

		buffer.incrementPosition(userlen);

		buffer.setLittleEndian16(LICENCE_TAG_HOST);
		buffer.setLittleEndian16(hostlen);

		if (hostname.length != 0) {
			buffer.copyFromByteArray(hostname, 0, buffer.getPosition(),
					hostlen - 1);
		} else {
			buffer
					.copyFromByteArray(hostname, 0, buffer.getPosition(),
							hostlen);
		}
		buffer.incrementPosition(hostlen);
		buffer.markEnd();
		secure.send(buffer, sec_flags);
	}