List of usage examples for org.bouncycastle.crypto.modes CBCBlockCipher init
public void init(boolean encrypting, CipherParameters params) throws IllegalArgumentException
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); for (int ax = 0; ax < cx; ax++) aes.processBlock(blo[ax], 0, blo[ax], 0); }/* w w w . j a va 2s .co m*/ 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); for (int ax = 0; ax < cx; ax++) aes.processBlock(blo[ax], 0, blo[ax], 0); }/*from w w w .j a v a2 s. c o m*/ 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); int cx = blo.length; for (int ax = 0; ax < cx; ax++) aes.processBlock(blo[ax], 0, blo[ax], 0); data = Stdio.MulBlock(blo, 16);//from w ww.j ava 2 s .co m 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); int cx = blo.length; for (int ax = 0; ax < cx; ax++) aes.processBlock(blo[ax], 0, blo[ax], 0); data = Stdio.MulBlock(blo, 16);//from w w w . ja v a 2 s . c o m blo = null; return data; }