public void changeCipher(BlockCipher bc) { this.currentCipher = bc; blockSize = bc.getBlockSize(); buffer = new byte[blockSize]; enc = new byte[blockSize]; pos = blockSize; }
public void changeCipher(BlockCipher bc) { this.currentCipher = bc; blockSize = bc.getBlockSize(); buffer = new byte[blockSize]; enc = new byte[blockSize]; pos = 0; }
public void changeCipher(BlockCipher bc) { this.currentCipher = bc; blockSize = bc.getBlockSize(); buffer = new byte[blockSize]; enc = new byte[blockSize]; pos = 0; }
public void changeCipher(BlockCipher bc) { this.currentCipher = bc; blockSize = bc.getBlockSize(); buffer = new byte[blockSize]; enc = new byte[blockSize]; pos = blockSize; }
public void changeCipher(BlockCipher bc) { this.currentCipher = bc; blockSize = bc.getBlockSize(); buffer = new byte[blockSize]; enc = new byte[blockSize]; pos = blockSize; }
public void changeCipher(BlockCipher bc) { this.currentCipher = bc; blockSize = bc.getBlockSize(); buffer = new byte[blockSize]; enc = new byte[blockSize]; pos = 0; }
public CTRMode(BlockCipher tc, byte[] iv, boolean doEnc) throws IllegalArgumentException { bc = tc; blockSize = bc.getBlockSize(); doEncrypt = doEnc; if (blockSize != iv.length) throw new IllegalArgumentException("IV must be " + blockSize + " bytes long! (currently " + iv.length + ")"); X = new byte[blockSize]; Xenc = new byte[blockSize]; System.arraycopy(iv, 0, X, 0, blockSize); }
public CTRMode(BlockCipher tc, byte[] iv, boolean doEnc) throws IllegalArgumentException { bc = tc; blockSize = bc.getBlockSize(); doEncrypt = doEnc; if (blockSize != iv.length) throw new IllegalArgumentException("IV must be " + blockSize + " bytes long! (currently " + iv.length + ")"); X = new byte[blockSize]; Xenc = new byte[blockSize]; System.arraycopy(iv, 0, X, 0, blockSize); }
public CTRMode(BlockCipher tc, byte[] iv, boolean doEnc) throws IllegalArgumentException { bc = tc; blockSize = bc.getBlockSize(); doEncrypt = doEnc; if (blockSize != iv.length) throw new IllegalArgumentException("IV must be " + blockSize + " bytes long! (currently " + iv.length + ")"); X = new byte[blockSize]; Xenc = new byte[blockSize]; System.arraycopy(iv, 0, X, 0, blockSize); }
public CBCMode(BlockCipher tc, byte[] iv, boolean doEncrypt) throws IllegalArgumentException { this.tc = tc; this.blockSize = tc.getBlockSize(); this.doEncrypt = doEncrypt; if (this.blockSize != iv.length) throw new IllegalArgumentException("IV must be " + blockSize + " bytes long! (currently " + iv.length + ")"); this.cbc_vector = new byte[blockSize]; this.tmp_vector = new byte[blockSize]; System.arraycopy(iv, 0, cbc_vector, 0, blockSize); }
public CBCMode(BlockCipher tc, byte[] iv, boolean doEncrypt) throws IllegalArgumentException { this.tc = tc; this.blockSize = tc.getBlockSize(); this.doEncrypt = doEncrypt; if (this.blockSize != iv.length) throw new IllegalArgumentException("IV must be " + blockSize + " bytes long! (currently " + iv.length + ")"); this.cbc_vector = new byte[blockSize]; this.tmp_vector = new byte[blockSize]; System.arraycopy(iv, 0, cbc_vector, 0, blockSize); }
public CBCMode(BlockCipher tc, byte[] iv, boolean doEncrypt) throws IllegalArgumentException { this.tc = tc; this.blockSize = tc.getBlockSize(); this.doEncrypt = doEncrypt; if (this.blockSize != iv.length) throw new IllegalArgumentException("IV must be " + blockSize + " bytes long! (currently " + iv.length + ")"); this.cbc_vector = new byte[blockSize]; this.tmp_vector = new byte[blockSize]; System.arraycopy(iv, 0, cbc_vector, 0, blockSize); }
private static byte[] decryptData(byte[] encryptedData, byte[] keyAndIv, SshCipher sshCipher) { byte[] key = new byte[sshCipher.getKeyLength()]; byte[] iv = new byte[sshCipher.getBlockSize()]; System.arraycopy(keyAndIv, 0, key, 0, key.length); System.arraycopy(keyAndIv, key.length, iv, 0, iv.length); BlockCipher cipher = sshCipher.createBlockCipher(key, iv, false); byte[] decrypted = new byte[encryptedData.length]; for (int i = 0; i < encryptedData.length / cipher.getBlockSize(); i++) { cipher.transformBlock(encryptedData, i * cipher.getBlockSize(), decrypted, i * cipher.getBlockSize()); } return decrypted; }
public void changeSendCipher(BlockCipher bc, MAC mac) { if ((bc instanceof NullCipher) == false) { /* Only use zero byte padding for the first few packets */ useRandomPadding = true; /* Once we start encrypting, there is no way back */ } cos.changeCipher(bc); send_mac = mac; send_mac_buffer = (mac != null) ? new byte[mac.size()] : null; send_padd_blocksize = bc.getBlockSize(); if (send_padd_blocksize < 8) send_padd_blocksize = 8; }
public void changeSendCipher(BlockCipher bc, MAC mac) { if ((bc instanceof NullCipher) == false) { /* Only use zero byte padding for the first few packets */ useRandomPadding = true; /* Once we start encrypting, there is no way back */ } cos.changeCipher(bc); send_mac = mac; send_mac_buffer = (mac != null) ? new byte[mac.size()] : null; send_padd_blocksize = bc.getBlockSize(); if (send_padd_blocksize < 8) send_padd_blocksize = 8; }
public void changeSendCipher(BlockCipher bc, MAC mac) { if ((bc instanceof NullCipher) == false) { /* Only use zero byte padding for the first few packets */ useRandomPadding = true; /* Once we start encrypting, there is no way back */ } cos.changeCipher(bc); send_mac = mac; send_mac_buffer = (mac != null) ? new byte[mac.size()] : null; send_padd_blocksize = bc.getBlockSize(); if (send_padd_blocksize < 8) send_padd_blocksize = 8; }
public void changeRecvCipher(BlockCipher bc, MAC mac) { cis.changeCipher(bc); recv_mac = mac; recv_mac_buffer = (mac != null) ? new byte[mac.size()] : null; recv_mac_buffer_cmp = (mac != null) ? new byte[mac.size()] : null; recv_padd_blocksize = bc.getBlockSize(); if (recv_padd_blocksize < 8) recv_padd_blocksize = 8; }
public void changeRecvCipher(BlockCipher bc, MAC mac) { cis.changeCipher(bc); recv_mac = mac; recv_mac_buffer = (mac != null) ? new byte[mac.size()] : null; recv_mac_buffer_cmp = (mac != null) ? new byte[mac.size()] : null; recv_padd_blocksize = bc.getBlockSize(); if (recv_padd_blocksize < 8) recv_padd_blocksize = 8; }
public void changeRecvCipher(BlockCipher bc, MAC mac) { cis.changeCipher(bc); recv_mac = mac; recv_mac_buffer = (mac != null) ? new byte[mac.size()] : null; recv_mac_buffer_cmp = (mac != null) ? new byte[mac.size()] : null; recv_padd_blocksize = bc.getBlockSize(); if (recv_padd_blocksize < 8) recv_padd_blocksize = 8; }
if ((ps.data.length % bc.getBlockSize()) != 0) throw new IOException("Invalid PEM structure, size of encrypted block is not a multiple of " + bc.getBlockSize()); for (int i = 0; i < ps.data.length / bc.getBlockSize(); i++) bc.transformBlock(ps.data, i * bc.getBlockSize(), dz, i * bc.getBlockSize()); dz = removePadding(dz, bc.getBlockSize());