docs: static void incrementCounter(byte[] counter, byte[] oldCounter) throws GeneralSecurityException {
      System.arraycopy(counter, 0, oldCounter, 0, counter.length);
      int i = 0;
      for (; i < COUNTER_OVERFLOW_LENGTH; i++) {
        counter[i]++;
        if (counter[i] != (byte) 0x00) {
          break;
        }
      }
  
      if (i == COUNTER_OVERFLOW_LENGTH) {
        // Restore old counter value to ensure that encrypt and decrypt keep failing.
        System.arraycopy(oldCounter, 0, counter, 0, counter.length);
        throw new GeneralSecurityException("Counter has overflowed.");
      }
    }