public static void buildAesCtrIv()

in encryption/src/main/java/org/apache/solr/encryption/crypto/AesCtrUtil.java [77:92]


  public static void buildAesCtrIv(byte[] initialIv, long counter, byte[] iv) {
    assert initialIv.length == IV_LENGTH && iv.length == IV_LENGTH;
    int ivIndex = iv.length;
    int counterIndex = 0;
    int sum = 0;
    while (ivIndex-- > 0) {
      // (sum >>> Byte.SIZE) is the carry for counter addition.
      sum = (initialIv[ivIndex] & 0xff) + (sum >>> Byte.SIZE);
      // Add long counter.
      if (counterIndex++ < 8) {
        sum += (byte) counter & 0xff;
        counter >>>= 8;
      }
      iv[ivIndex] = (byte) sum;
    }
  }