I am trying to show that if $f(x) \in \mathbb{F}_p[x]$ ($p$ prime) is a polynomial of degree $5$, then $f(x)$ is irreducible if and only if $gcd(f(x), x^{p^2}-x)=1$.
Suppose $f(x)$ is irreducible. Now $f(x) \neq c(x^{p^2}-x)$ where $c \in \mathbb{F}_p$ because $p^2 \neq 5$. If $x^{p^2}-x$ divides $f(x)$, then because $f(x)$ is irreducible, we must have $x^{p^2}-x = 1$ which is a contradiction. If $f(x)$ divides $x^{p^2}-x$, then I have read from Product of all monic irreducibles with degree dividing $n$ in $\mathbb{F}_{q}$? that $x^{p^2}-x$ is the product of all monic irreducible polynomials with degree dividing $2$. This means $f(x)$ must equal (up to multiplication by a unit) some monic irreducible polynomial with degree dividing $2$ which is a contradiction as $f(x)$ has degree $5$. Is this logic correct?
For the other direction where we suppose that $gcd(f(x), x^{p^2}-x)=1$, I would appreciate any guidance on how to proceed.