public DecryptingStream(BlockCipher cipher, InputStream inputStream) throws EncryptionError, IOException { this.inputStream = inputStream; byte[] iv = new byte[cipher.getBlockSize()]; inputStream.read(iv); transformer = new CTRTransformer(cipher, iv); }
public EncryptingStream(BlockCipher cipher, OutputStream outputStream) throws EncryptionError, IOException { transformer = new CTRTransformer(cipher, null); this.outputStream = outputStream; outputStream.write(transformer.getIV()); }
EtaEncryptingStream(OutputStream outputStream, boolean encrypt) throws IOException, EncryptionError { int blockSize = 64; // for SHA256 at least this.outputStream = outputStream; hmac = new HMAC(key); if (encrypt) { transformer = new CTRTransformer(getCipher(), null); outputStream.write(transformer.getIV()); } }
EtaDecryptingStream(InputStream inputStream) throws IOException, EncryptionError { this.inputStream = inputStream; byte[] IV = new byte[getCipher().getBlockSize()]; inputStream.read(IV); transformer = new CTRTransformer(getCipher(), IV); hmac = new HMAC(key); // We should have always block bytes in the buffer to finish: ring = new ByteRingBuffer(hmac.getLength() + 8); for (int i = 0; i < hmac.getLength(); i++) ring.put(inputStream.read()); }