System.arraycopy(headerData, 0, headBuffer, 3, headerData.length); enc.processBytes(headBuffer, 0, 16, headBuffer, 0); enc.processBytes(ptype, 0, ptype.length, buff, 0); out.write(buff, 0, ptype.length); egressMac.update(buff, 0, ptype.length); int n = frame.payload.read(buff); if (n <= 0) break; enc.processBytes(buff, 0, n, buff, 0); egressMac.update(buff, 0, n); out.write(buff, 0, n); byte[] pad = new byte[16]; if (padding < 16) { enc.processBytes(pad, 0, padding, buff, 0); egressMac.update(buff, 0, padding); out.write(buff, 0, padding);
dec.processBytes(headBuffer, 0, 16, headBuffer, 0); totalBodySize = headBuffer[0] & 0xFF; totalBodySize = (totalBodySize << 8) + (headBuffer[1] & 0xFF); dec.processBytes(buffer, 0, frameSize, buffer, 0); int pos = 0; long type = RLP.decodeLong(buffer, pos);
protected int engineDoFinal( byte[] input, int inputOffset, int inputLen, byte[] output, int outputOffset) { if (inputLen != 0) { cipher.processBytes(input, inputOffset, inputLen, output, outputOffset); } cipher.reset(); return inputLen; }
protected int engineDoFinal( byte[] input, int inputOffset, int inputLen, byte[] output, int outputOffset) { if (inputLen != 0) { cipher.processBytes(input, inputOffset, inputLen, output, outputOffset); } cipher.reset(); return inputLen; } }
protected int engineUpdate( byte[] input, int inputOffset, int inputLen, byte[] output, int outputOffset) throws ShortBufferException { try { cipher.processBytes(input, inputOffset, inputLen, output, outputOffset); return inputLen; } catch (DataLengthException e) { throw new ShortBufferException(e.getMessage()); } }
public byte[] encodePlaintext(long seqNo, short type, byte[] plaintext, int offset, int len) { if (usesNonce) { updateIV(encryptCipher, true, seqNo); } byte[] outBuf = new byte[len + writeMac.getSize()]; encryptCipher.processBytes(plaintext, offset, len, outBuf, 0); byte[] mac = writeMac.calculateMac(seqNo, type, plaintext, offset, len); encryptCipher.processBytes(mac, 0, mac.length, outBuf, len); return outBuf; }
protected int engineUpdate( byte[] input, int inputOffset, int inputLen, byte[] output, int outputOffset) throws ShortBufferException { try { cipher.processBytes(input, inputOffset, inputLen, output, outputOffset); return inputLen; } catch (DataLengthException e) { throw new ShortBufferException(e.getMessage()); } }
protected int engineUpdate( byte[] input, int inputOffset, int inputLen, byte[] output, int outputOffset) throws ShortBufferException { if (outputOffset + inputLen > output.length) { throw new ShortBufferException("output buffer too short for input."); } try { cipher.processBytes(input, inputOffset, inputLen, output, outputOffset); return inputLen; } catch (DataLengthException e) { // should never happen throw new IllegalStateException(e.getMessage()); } }
protected KeyParameter generateRecordMACKey(StreamCipher cipher) { byte[] firstBlock = new byte[64]; cipher.processBytes(firstBlock, 0, firstBlock.length, firstBlock, 0); KeyParameter macKey = new KeyParameter(firstBlock, 0, 32); Arrays.fill(firstBlock, (byte)0); return macKey; }
protected int engineDoFinal( byte[] input, int inputOffset, int inputLen, byte[] output, int outputOffset) throws ShortBufferException { if (outputOffset + inputLen > output.length) { throw new ShortBufferException("output buffer too short for input."); } if (inputLen != 0) { cipher.processBytes(input, inputOffset, inputLen, output, outputOffset); } cipher.reset(); return inputLen; } }
streamCipher.processBytes(b, off, len, buf, 0);
streamCipher.processBytes(b, off, len, buf, 0);
public void doChaCha(boolean encrypt, InputStream is, OutputStream os, byte[] key, byte[] iv) throws IOException { CipherParameters cp = new KeyParameter(key); ParametersWithIV params = new ParametersWithIV(cp, iv); StreamCipher engine = new ChaChaEngine(); engine.init(encrypt, params); byte in[] = new byte[8192]; byte out[] = new byte[8192]; int len = 0; while(-1 != (len = is.read(in))) { len = engine.processBytes(in, 0 , len, out, 0); os.write(out, 0, len); } } public void encChaCha(InputStream is, OutputStream os, byte[] key, byte[] iv) throws IOException { doChaCha(true, is, os, key, iv); } public void decChaCha(InputStream is, OutputStream os, byte[] key, byte[] iv) throws IOException { doChaCha(false, is, os, key, iv); }
streamCipher.processBytes(inBuf, 0, available, buf, 0); maxBuf = available;
static void prg(byte[] r, int rOff, long rlen, byte[] key, int keyOff) { byte[] nonce = new byte[8]; StreamCipher cipher = new ChaChaEngine(12); cipher.init(true, new ParametersWithIV(new KeyParameter(key, keyOff, 32), nonce)); cipher.processBytes(r, rOff, (int)rlen, r, rOff); //crypto_stream_chacha12(r, rlen, nonce, key); } }
public byte[] decodeCiphertext(long seqNo, short type, byte[] ciphertext, int offset, int len) throws IOException { if (usesNonce) { updateIV(decryptCipher, false, seqNo); } int macSize = readMac.getSize(); if (len < macSize) { throw new TlsFatalAlert(AlertDescription.decode_error); } int plaintextLength = len - macSize; byte[] deciphered = new byte[len]; decryptCipher.processBytes(ciphertext, offset, len, deciphered, 0); checkMAC(seqNo, type, deciphered, plaintextLength, len, deciphered, 0, plaintextLength); return Arrays.copyOfRange(deciphered, 0, plaintextLength); }
streamCipher.processBytes(inBuf, 0, read, buf, 0); maxBuf = read;