/**
  * Resets the cipher object to its original state. This is used when doFinal is called in the
  * Cipher class, so that the cipher can be reused (with its original key and iv).
  */
 void reset() {
   if (aadBuffer == null) {
     aadBuffer = new ByteArrayOutputStream();
   } else {
     aadBuffer.reset();
   }
   if (gctrPAndC != null) gctrPAndC.reset();
   if (ghashAllToS != null) ghashAllToS.reset();
   processed = 0;
   sizeOfAAD = 0;
   if (ibuffer != null) {
     ibuffer.reset();
   }
 }