Recreating binary counter for arbitrary length arrays
No check for end of array
incByte() doesn't check if i &gt;= 0.  So if all bytes are 0xff, it will happily start reading/writing to state[-1].
Simplification
Actually, I would remove the recursion.  If byte is of size 1 byte, you could also simplify the check for overflow past 0xff:
void incByte(byte *state, int i)
{
    do {
        if (++state[i] != 0)
            return;
        i--;
    } while (i &gt;= 0);
}