protected void decryptBlock(byte[] in,int pos,int length){
  byte[] decryptedIn=new byte[blockSize];
  byte[] ivBytes=ByteArrayHelper.toByteArray(nonce++,16);
  ParametersWithIV ivParams=new ParametersWithIV(cipherParameters,ivBytes);
  aesCipher.init(false,ivParams);
  int remainingCount=length - pos;
  if (remainingCount >= blockSize) {
    mac.update(in,pos,blockSize);
    aesCipher.processBlock(in,pos,decryptedIn,0);
    System.arraycopy(decryptedIn,0,in,pos,blockSize);
  }
 else {
    mac.update(in,pos,remainingCount);
    byte[] extendedIn=new byte[blockSize];
    System.arraycopy(in,pos,extendedIn,0,remainingCount);
    aesCipher.processBlock(extendedIn,0,decryptedIn,0);
    System.arraycopy(decryptedIn,0,in,pos,remainingCount);
  }
}

protected void decryptBlock ( byte [ ] in , int pos , int length ) { byte [ ] decryptedIn = new byte [ blockSize ] ; byte [ ] ivBytes = ByteArrayHelper . toByteArray ( nonce ++ , 16 ) ; ParametersWithIV ivParams = new ParametersWithIV ( cipherParameters , ivBytes ) ; aesCipher . init ( false , ivParams ) ; int remainingCount = length - pos ; if ( remainingCount >= blockSize ) { mac . update ( in , pos , blockSize ) ; aesCipher . processBlock ( in , pos , decryptedIn , 0 ) ; System . arraycopy ( decryptedIn , 0 , in , pos , blockSize ) ; } else { mac . update ( in , pos , remainingCount ) ; byte [ ] extendedIn = new byte [ blockSize ] ; System . arraycopy ( in , pos , extendedIn , 0 , remainingCount ) ; aesCipher . processBlock ( extendedIn , 0 , decryptedIn , 0 ) ; System . arraycopy ( decryptedIn , 0 , in , pos , remainingCount ) ; } }
encrypt 16 bytes ( aes standard block size ) or less starting at " pos " within " in " byte [ ]
