int encryptFinal(byte[] in,int inOfs,int len,byte[] out,int outOfs) throws IllegalBlockSizeException, ShortBufferException {
  if (out.length - outOfs < (len + tagLenBytes)) {
    throw new ShortBufferException("Output buffer too small");
  }
  processAAD();
  if (len > 0) {
    doLastBlock(in,inOfs,len,out,outOfs,true);
  }
  byte[] lengthBlock=getLengthBlock(sizeOfAAD * 8,processed * 8);
  ghashAllToS.update(lengthBlock);
  byte[] s=ghashAllToS.digest();
  byte[] sOut=new byte[s.length];
  GCTR gctrForSToTag=new GCTR(embeddedCipher,this.preCounterBlock);
  gctrForSToTag.doFinal(s,0,s.length,sOut,0);
  System.arraycopy(sOut,0,out,(outOfs + len),tagLenBytes);
  return (len + tagLenBytes);
}

int encryptFinal ( byte [ ] in , int inOfs , int len , byte [ ] out , int outOfs ) throws IllegalBlockSizeException , ShortBufferException { if ( out . length - outOfs < ( len + tagLenBytes ) ) { throw new ShortBufferException ( "Output buffer too small" ) ; } processAAD ( ) ; if ( len > 0 ) { doLastBlock ( in , inOfs , len , out , outOfs , true ) ; } byte [ ] lengthBlock = getLengthBlock ( sizeOfAAD * 8 , processed * 8 ) ; ghashAllToS . update ( lengthBlock ) ; byte [ ] s = ghashAllToS . digest ( ) ; byte [ ] sOut = new byte [ s . length ] ; GCTR gctrForSToTag = new GCTR ( embeddedCipher , this . preCounterBlock ) ; gctrForSToTag . doFinal ( s , 0 , s . length , sOut , 0 ) ; System . arraycopy ( sOut , 0 , out , ( outOfs + len ) , tagLenBytes ) ; return ( len + tagLenBytes ) ; }
performs encryption operation for the last time .
