hope you are already familiar with GF basics..
one primitve poly for GF(2^8) is
α^8 + α^4 + α^3 + α^2 + 1 = 0
any a GF (256) ele can be written as a power of the primitive element α. take element α^i. It can be written as
α^i = a7 * α^7 + a6 * α^6 + a5 * α^5 + a4 * α^4 + a3 * α^3 + a2 * α^2 + a1 * α^1 + a0
lets multiply above element with the primitve element α
α * α^i = a7 * α^8 + a6 * α^7 + a5 * α^6 + a4 * α^5 + a3 * α^4 + a2 * α^3 + a1 * α^2 + a0 * α^1
using the primitive poly, we can replace α^8
α^ (i+1) = a7 * (α^4 + α^3 + α^2 + 1) + a6 * α^7 + a5 * α^6 + a4 * α^5 + a3 * α^4 + a2 * α^3 + a1 * α^2 + a0 * α^1
which can be written as
α^ (i+1) = a6 * α^7 + a5 * α^6 + a4 * α^5 + (a3 xor a7) * α^4 + (a7 xor a2) * α^3 + (a7 xor a1) * α^2 + (a7 xor a0)
(hope I got that right)
now you can see that 'multiply by α' can be achieved by shift and xor operations. We can just repeat this to multiply α^i by α^2, α^3, α^4, α^5, α^6 and α^7.
Now think about multiplying by any other GF ele. Any GF ele can be written as
α^j = b7 * α^7 + b6 * α^6 + b5 * α^5 + b4 * α^4 + b3 * α^3 + b2 * α^2 + b1 * α^1 + b0
you can see that to get product of α^i and α^j, what we need to multiply α^i by α^1, α^2, α^3, α^4, α^5, α^6 and α^7 and add up. However, not all need to be added up, only those products whose b's are not zero need to be. This is exactly what your expresion does.
-b