Example usage for org.bouncycastle.crypto.modes CBCBlockCipher processBlock

List of usage examples for org.bouncycastle.crypto.modes CBCBlockCipher processBlock

Introduction

In this page you can find the example usage for org.bouncycastle.crypto.modes CBCBlockCipher processBlock.

Prototype

public int processBlock(byte[] in, int inOff, byte[] out, int outOff)
        throws DataLengthException, IllegalStateException 

Source Link

Document

Process one block of input from the array in and write it to the out array.

Usage

From source file:org.tramaci.onionmail.Stdio.java

License:Open Source License

public static byte[] AESEnc2m(byte[][] key, byte[][] iv, byte[] data) throws Exception {

    byte[][] blo = Stdio.DivBlock(data, 16, false);
    int cx = blo.length;
    int kc = key.length;
    for (int kx = 0; kx < kc; kx++) {
        CBCBlockCipher aes = new CBCBlockCipher(new AESEngine());
        CipherParameters ivAndKey = new ParametersWithIV(new KeyParameter(key[kx]), iv[kx]);
        aes.init(true, ivAndKey);/*w  w  w  .  j  a v a 2s  .c o  m*/
        for (int ax = 0; ax < cx; ax++)
            aes.processBlock(blo[ax], 0, blo[ax], 0);
    }

    data = Stdio.MulBlock(blo, 16);
    blo = null;
    return data;
}

From source file:org.tramaci.onionmail.Stdio.java

License:Open Source License

public static byte[] AESDec2m(byte[][] key, byte[][] iv, byte[] data) throws Exception {

    byte[][] blo = Stdio.DivBlock(data, 16, false);
    int cx = blo.length;
    int kc = key.length - 1;
    for (int kx = kc; kx > -1; kx--) {
        CBCBlockCipher aes = new CBCBlockCipher(new AESEngine());
        CipherParameters ivAndKey = new ParametersWithIV(new KeyParameter(key[kx]), iv[kx]);
        aes.init(false, ivAndKey);/* ww w . j a  v a2s .  c o  m*/
        for (int ax = 0; ax < cx; ax++)
            aes.processBlock(blo[ax], 0, blo[ax], 0);
    }

    data = Stdio.MulBlock(blo, 16);
    blo = null;
    return data;
}

From source file:org.tramaci.onionmail.Stdio.java

License:Open Source License

public static byte[] AESEnc2(byte[] key, byte[] iv, byte[] data) throws Exception {
    byte[][] blo = Stdio.DivBlock(data, 16, false);

    CBCBlockCipher aes = new CBCBlockCipher(new AESEngine());
    CipherParameters ivAndKey = new ParametersWithIV(new KeyParameter(key), iv);
    aes.init(true, ivAndKey);/*w  w  w .  j  av  a  2s.c o m*/

    int cx = blo.length;
    for (int ax = 0; ax < cx; ax++)
        aes.processBlock(blo[ax], 0, blo[ax], 0);
    data = Stdio.MulBlock(blo, 16);
    blo = null;
    return data;
}

From source file:org.tramaci.onionmail.Stdio.java

License:Open Source License

public static byte[] AESDec2(byte[] key, byte[] iv, byte[] data) throws Exception {
    byte[][] blo = Stdio.DivBlock(data, 16, false);

    CBCBlockCipher aes = new CBCBlockCipher(new AESEngine());
    CipherParameters ivAndKey = new ParametersWithIV(new KeyParameter(key), iv);
    aes.init(false, ivAndKey);/*from w ww . j  a v  a2s  . c  om*/

    int cx = blo.length;
    for (int ax = 0; ax < cx; ax++)
        aes.processBlock(blo[ax], 0, blo[ax], 0);
    data = Stdio.MulBlock(blo, 16);
    blo = null;
    return data;
}