@Override public int doFinal(final byte[] out,final int outOff) throws BadCiphertextException {
  complete_=true;
  int written=contentCryptoHandler_.doFinal(out,outOff);
  updateTrailingSignature(out,outOff,written);
  if (cryptoAlgo_.getTrailingSignatureLength() > 0) {
    try {
      CiphertextFooters footer=new CiphertextFooters(trailingSig_.sign());
      byte[] fBytes=footer.toByteArray();
      System.arraycopy(fBytes,0,out,outOff + written,fBytes.length);
      return written + fBytes.length;
    }
 catch (    final SignatureException ex) {
      throw new AwsCryptoException(ex);
    }
  }
 else {
    return written;
  }
}

@ Override public int doFinal ( final byte [ ] out , final int outOff ) throws BadCiphertextException { complete_ = true ; int written = contentCryptoHandler_ . doFinal ( out , outOff ) ; updateTrailingSignature ( out , outOff , written ) ; if ( cryptoAlgo_ . getTrailingSignatureLength ( ) > 0 ) { try { CiphertextFooters footer = new CiphertextFooters ( trailingSig_ . sign ( ) ) ; byte [ ] fBytes = footer . toByteArray ( ) ; System . arraycopy ( fBytes , 0 , out , outOff + written , fBytes . length ) ; return written + fBytes . length ; } catch ( final SignatureException ex ) { throw new AwsCryptoException ( ex ) ; } } else { return written ; } }
finish encryption of the plaintext bytes .
