private byte[] omac(Cipher ecb, int tag, final byte[] data, int offset, int length)
      throws IllegalBlockSizeException, BadPaddingException {
    assert length >= 0;
    assert 0 <= tag && tag <= 3;
    byte[] block = new byte[BLOCK_SIZE_IN_BYTES];
    block[BLOCK_SIZE_IN_BYTES - 1] = (byte) tag;
    if (length == 0) {
      return ecb.doFinal(xor(block, b));
    }
    block = ecb.doFinal(block);
    int position = 0;
    while (length - position > BLOCK_SIZE_IN_BYTES) {
      for (int i = 0; i < BLOCK_SIZE_IN_BYTES; i++) {
        block[i] ^= data[offset + position + i];
      }
      block = ecb.doFinal(block);
      position += BLOCK_SIZE_IN_BYTES;
    }
    byte[] padded = pad(Arrays.copyOfRange(data, offset + position, offset + length));
    block = xor(block, padded);
    return ecb.doFinal(block);
  }
Computes an OMAC.

@param ecb A cipher initialized with the key of this class using AES/ECB/NOPadding and
    encryption mode.
@param tag The OMAC tag (0 for nonce, 1 for aad, 2 for ciphertext)
@param data The array containing the data to MAC.
@param offset The start of the data to MAC.
@param length The length of the data to MAC.
@return The 16 byte long OMAC
@throws IllegalBlockSizeException, BadPaddingException This should not happen.
java_src/src/main/java/com/google/crypto/tink/subtle/AesEaxJce.java