public byte[] update(byte[] b, int off, int len) { if (aes) { if (initiated) return cipher.update(b, off, len); else { int left = Math.min(iv.length - ivptr, len); System.arraycopy(b, off, iv, ivptr, left); off += left; len -= left; ivptr += left; if (ivptr == iv.length) { cipher = new AESCipher(false, key, iv); initiated = true; if (len > 0) return cipher.update(b, off, len); } return null; } } else { byte[] b2 = new byte[len]; arcfour.encryptARCFOUR(b, off, len, b2, 0); return b2; } }
public byte[] finish() { if (aes) { return cipher.doFinal(); } else return null; } }
/** Creates a new instance of OutputStreamCounter */ public OutputStreamEncryption(OutputStream out, byte key[], int off, int len, int revision) { try { this.out = out; aes = revision == AES_128; if (aes) { byte[] iv = IVGenerator.getIV(); byte[] nkey = new byte[len]; System.arraycopy(key, off, nkey, 0, len); cipher = new AESCipher(true, nkey, iv); write(iv); } else { arcfour = new ARCFOUREncryption(); arcfour.prepareARCFOURKey(key, off, len); } } catch (Exception ex) { throw new ExceptionConverter(ex); } }
byte[] b2 = cipher.update(b, off, len); if (b2 == null || b2.length == 0) return;
/** Creates a new instance of OutputStreamCounter */ public OutputStreamEncryption(OutputStream out, byte[] key, int off, int len, int revision) { try { this.out = out; aes = revision == AES_128; if (aes) { byte[] iv = IVGenerator.getIV(); byte[] nkey = new byte[len]; System.arraycopy(key, off, nkey, 0, len); cipher = new AESCipher(true, nkey, iv); write(iv); } else { arcfour = new ARCFOUREncryption(); arcfour.prepareARCFOURKey(key, off, len); } } catch (Exception ex) { throw new ExceptionConverter(ex); } }
byte[] b2 = cipher.update(b, off, len); if (b2 == null || b2.length == 0) return;
public byte[] update(byte[] b, int off, int len) { if (aes) { if (initiated) return cipher.update(b, off, len); else { int left = Math.min(iv.length - ivptr, len); System.arraycopy(b, off, iv, ivptr, left); off += left; len -= left; ivptr += left; if (ivptr == iv.length) { cipher = new AESCipher(false, key, iv); initiated = true; if (len > 0) return cipher.update(b, off, len); } return null; } } else { byte[] b2 = new byte[len]; arcfour.encryptARCFOUR(b, off, len, b2, 0); return b2; } }
public byte[] finish() { if (aes) { return cipher.doFinal(); } else return null; } }
/** Creates a new instance of OutputStreamCounter */ public OutputStreamEncryption(OutputStream out, byte key[], int off, int len, int revision) { try { this.out = out; aes = revision == AES_128; if (aes) { byte[] iv = IVGenerator.getIV(); byte[] nkey = new byte[len]; System.arraycopy(key, off, nkey, 0, len); cipher = new AESCipher(true, nkey, iv); write(iv); } else { arcfour = new ARCFOUREncryption(); arcfour.prepareARCFOURKey(key, off, len); } } catch (Exception ex) { throw new ExceptionConverter(ex); } }
byte[] b2 = cipher.update(b, off, len); if (b2 == null || b2.length == 0) return;
public byte[] update(byte[] b, int off, int len) { if (aes) { if (initiated) return cipher.update(b, off, len); else { int left = Math.min(iv.length - ivptr, len); System.arraycopy(b, off, iv, ivptr, left); off += left; len -= left; ivptr += left; if (ivptr == iv.length) { cipher = new AESCipher(false, key, iv); initiated = true; if (len > 0) return cipher.update(b, off, len); } return null; } } else { byte[] b2 = new byte[len]; arcfour.encryptARCFOUR(b, off, len, b2, 0); return b2; } }
public byte[] finish() { if (aes) { return cipher.doFinal(); } else return null; } }
public void finish() throws IOException { if (!finished) { finished = true; if (aes) { byte[] b; try { b = cipher.doFinal(); } catch (Exception ex) { throw new ExceptionConverter(ex); } out.write(b, 0, b.length); } } } }
public void finish() throws IOException { if (!finished) { finished = true; if (aes) { byte[] b; try { b = cipher.doFinal(); } catch (Exception ex) { throw new ExceptionConverter(ex); } out.write(b, 0, b.length); } } } }
public void finish() throws IOException { if (!finished) { finished = true; if (aes) { byte[] b; try { b = cipher.doFinal(); } catch (Exception ex) { throw new ExceptionConverter(ex); } out.write(b, 0, b.length); } } } }