Example usage for org.bouncycastle.crypto.engines RC4Engine RC4Engine

List of usage examples for org.bouncycastle.crypto.engines RC4Engine RC4Engine

Introduction

In this page you can find the example usage for org.bouncycastle.crypto.engines RC4Engine RC4Engine.

Prototype

RC4Engine

Source Link

Usage

From source file:net.propero.rdp.Licence.java

License:Open Source License

/**
 * Handle a licence issued by the server, save to disk if
 * options.save_licence//from   w  ww .ja v a 2s .c o  m
 *
 * @param data
 *            Packet containing issued licence
 */
public void process_issue(RdpPacket data) {
    int length = 0;
    int check = 0;
    RC4Engine rc4_licence = new RC4Engine();
    byte[] key = new byte[this.licence_key.length];
    System.arraycopy(this.licence_key, 0, key, 0, this.licence_key.length);

    data.incrementPosition(2); // unknown
    length = data.getLittleEndian16();

    if (data.getPosition() + length > data.getEnd()) {
        return;
    }

    rc4_licence.init(false, new KeyParameter(key));
    byte[] buffer = new byte[length];
    data.copyToByteArray(buffer, 0, data.getPosition(), length);
    rc4_licence.processBytes(buffer, 0, length, buffer, 0);
    data.copyFromByteArray(buffer, 0, data.getPosition(), length);

    check = data.getLittleEndian16();
    if (check != 0) {
        // return;
    }
    secure.licenceIssued = true;

    /*
     * data.incrementPosition(2); // in_uint8s(s, 2); // pad
     *  // advance to fourth string length = 0; for (int i = 0; i < 4; i++) {
     * data.incrementPosition(length); // in_uint8s(s, length); length =
     * data.getLittleEndian32(length); // in_uint32_le(s, length); if
     * (!(data.getPosition() + length <= data.getEnd())) return; }
     */

    secure.licenceIssued = true;
    LOGGER.debug("Server issued Licence");
    if (options.save_licence) {
        save_licence(data, length - 2);
    }
}

From source file:net.propero.rdp.Secure.java

License:Open Source License

/**
 * Initialise Secure layer of communications
 *
 * @param channels//w w w.j  a va 2s  . c  om
 *            Virtual channels for this connection
 * @param options
 *            The options instance
 */
public Secure(VChannels channels, Options options, Rdp rdp) {
    this.channels = channels;
    this.options = options;
    this.licence = new Licence(options, this);
    McsLayer = new MCS(options, channels, this, rdp);
    rc4_dec = new RC4Engine();
    rc4_enc = new RC4Engine();
    rc4_update = new RC4Engine();
    sha1 = new SHA1Digest();
    md5 = new MD5Digest();
    sec_sign_key = new byte[16]; // changed from 8 - rdesktop 1.2.0
    sec_decrypt_key = new byte[16];
    sec_encrypt_key = new byte[16];
    sec_decrypt_update_key = new byte[16]; // changed from 8 - rdesktop
    // 1.2.0
    sec_encrypt_update_key = new byte[16]; // changed from 8 - rdesktop
    // 1.2.0
    sec_crypted_random = new byte[64];

}

From source file:org.cryptacular.spec.StreamCipherSpec.java

License:Open Source License

@Override
public StreamCipher newInstance() {
    StreamCipher cipher;/* w  w  w. j  a  v  a2 s .com*/
    if ("Grainv1".equalsIgnoreCase(algorithm) || "Grain-v1".equalsIgnoreCase(algorithm)) {
        cipher = new ISAACEngine();
    } else if ("Grain128".equalsIgnoreCase(algorithm) || "Grain-128".equalsIgnoreCase(algorithm)) {
        cipher = new Grain128Engine();
    } else if ("ISAAC".equalsIgnoreCase(algorithm)) {
        cipher = new ISAACEngine();
    } else if ("HC128".equalsIgnoreCase(algorithm)) {
        cipher = new HC128Engine();
    } else if ("HC256".equalsIgnoreCase(algorithm)) {
        cipher = new HC256Engine();
    } else if ("RC4".equalsIgnoreCase(algorithm)) {
        cipher = new RC4Engine();
    } else if ("Salsa20".equalsIgnoreCase(algorithm)) {
        cipher = new Salsa20Engine();
    } else if ("VMPC".equalsIgnoreCase(algorithm)) {
        cipher = new VMPCEngine();
    } else {
        throw new IllegalStateException("Unsupported cipher algorithm " + algorithm);
    }
    return cipher;
}

From source file:org.sejda.sambox.encryption.ARC4Engine.java

License:Apache License

public ARC4Engine() {
    cipher = new RC4Engine();
}

From source file:rpc.security.ntlm.NTLMKeyFactory.java

License:Open Source License

StreamCipher getARCFOUR(byte[] key) {
    HashMap attrib = new HashMap();
    //      IRandom keystream = new ARCFour();
    //      attrib.put(ARCFour.ARCFOUR_KEY_MATERIAL, key);
    //      keystream.init(attrib);
    StreamCipher keystream = new RC4Engine();
    CipherParameters params = new KeyParameter(key);
    keystream.init(true, params);//from  w ww  . j  a  v  a 2  s .co m
    return keystream;
}