private void process(ByteBuffer inBuffer, ByteBuffer outBuffer) throws IOException { try { int inputSize = inBuffer.remaining(); // OpensslCipher#update will maintain crypto context. int n = cipher.update(inBuffer, outBuffer); if (n < inputSize) { /** * Typically code will not get here. OpensslCipher#update will * consume all input data and put result in outBuffer. * OpensslCipher#doFinal will reset the crypto context. */ contextReset = true; cipher.doFinal(outBuffer); } } catch (Exception e) { throw new IOException(e); } }
checkState(); Preconditions.checkArgument(output.isDirect(), "Direct buffer is required."); int len = doFinal(context, output, output.position(), output.remaining()); output.position(output.position() + len); return len;
private void process(ByteBuffer inBuffer, ByteBuffer outBuffer) throws IOException { try { int inputSize = inBuffer.remaining(); // OpensslCipher#update will maintain crypto context. int n = cipher.update(inBuffer, outBuffer); if (n < inputSize) { /** * Typically code will not get here. OpensslCipher#update will * consume all input data and put result in outBuffer. * OpensslCipher#doFinal will reset the crypto context. */ contextReset = true; cipher.doFinal(outBuffer); } } catch (Exception e) { throw new IOException(e); } }
private void process(ByteBuffer inBuffer, ByteBuffer outBuffer) throws IOException { try { int inputSize = inBuffer.remaining(); // OpensslCipher#update will maintain crypto context. int n = cipher.update(inBuffer, outBuffer); if (n < inputSize) { /** * Typically code will not get here. OpensslCipher#update will * consume all input data and put result in outBuffer. * OpensslCipher#doFinal will reset the crypto context. */ contextReset = true; cipher.doFinal(outBuffer); } } catch (Exception e) { throw new IOException(e); } }
private void process(ByteBuffer inBuffer, ByteBuffer outBuffer) throws IOException { try { int inputSize = inBuffer.remaining(); // OpensslCipher#update will maintain crypto context. int n = cipher.update(inBuffer, outBuffer); if (n < inputSize) { /** * Typically code will not get here. OpensslCipher#update will * consume all input data and put result in outBuffer. * OpensslCipher#doFinal will reset the crypto context. */ contextReset = true; cipher.doFinal(outBuffer); } } catch (Exception e) { throw new IOException(e); } }
private void process(ByteBuffer inBuffer, ByteBuffer outBuffer) throws IOException { try { int inputSize = inBuffer.remaining(); // OpensslCipher#update will maintain crypto context. int n = cipher.update(inBuffer, outBuffer); if (n < inputSize) { /** * Typically code will not get here. OpensslCipher#update will * consume all input data and put result in outBuffer. * OpensslCipher#doFinal will reset the crypto context. */ contextReset = true; cipher.doFinal(outBuffer); } } catch (Exception e) { throw new IOException(e); } }
checkState(); Preconditions.checkArgument(output.isDirect(), "Direct buffer is required."); int len = doFinal(context, output, output.position(), output.remaining()); output.position(output.position() + len); return len;
checkState(); Preconditions.checkArgument(output.isDirect(), "Direct buffer is required."); int len = doFinal(context, output, output.position(), output.remaining()); output.position(output.position() + len); return len;
checkState(); Preconditions.checkArgument(output.isDirect(), "Direct buffer is required."); int len = doFinal(context, output, output.position(), output.remaining()); output.position(output.position() + len); return len;
checkState(); Preconditions.checkArgument(output.isDirect(), "Direct buffer is required."); int len = doFinal(context, output, output.position(), output.remaining()); output.position(output.position() + len); return len;
@Test(timeout=120000) public void testDoFinalArguments() throws Exception { Assume.assumeTrue(OpensslCipher.getLoadingFailureReason() == null); OpensslCipher cipher = OpensslCipher.getInstance("AES/CTR/NoPadding"); Assert.assertTrue(cipher != null); cipher.init(OpensslCipher.ENCRYPT_MODE, key, iv); // Require direct buffer ByteBuffer output = ByteBuffer.allocate(1024); try { cipher.doFinal(output); Assert.fail("Output buffer should be direct buffer."); } catch (IllegalArgumentException e) { GenericTestUtils.assertExceptionContains( "Direct buffer is required", e); } } }
@Test(timeout=120000) public void testDoFinalArguments() throws Exception { Assume.assumeTrue(OpensslCipher.getLoadingFailureReason() == null); OpensslCipher cipher = OpensslCipher.getInstance("AES/CTR/NoPadding"); Assert.assertTrue(cipher != null); cipher.init(OpensslCipher.ENCRYPT_MODE, key, iv); // Require direct buffer ByteBuffer output = ByteBuffer.allocate(1024); try { cipher.doFinal(output); Assert.fail("Output buffer should be direct buffer."); } catch (IllegalArgumentException e) { GenericTestUtils.assertExceptionContains( "Direct buffer is required", e); } } }