def _multiply(a: int, b: int) -> int:
    """Implements multiplication of `a` times `b` in GF256, i.e.,
    multiplication modulo the AES irreducible polynomial `x**8 + x**4 + x**3 + x + 1`.
    """
    IRREDUCIBLE_POLYNOMIAL = 0b100011011

    product = 0
    while b > 0:
        # add (xor operation) `a` to the product if the last bit of `b` == 1
        product ^= a * (b & 1)

        # shift `a` one bit to the left
        # and perform a modulo reduction if there is an overflow after shifting (a >> 8 == 1)
        a <<= 1
        a ^= (a >> 8) * IRREDUCIBLE_POLYNOMIAL

        # move the next highest bit of `b` bit shifting it down
        b >>= 1

    return product