Does $p = x^2 + 9y^2$ for some $x$, $y \in \mathbb{Z}$ if and only if $p \equiv 1 \text{ mod }12$? For a prime number $p \neq 2$, $3$, does $p = x^2 + 9y^2$ for some $x$, $y \in \mathbb{Z}$ if and only if $p \equiv 1 \text{ mod }12$?
A case where this is true as to suggest plausibility: $13 = 2^2 + 9 \times 1^2$.

A start:
A famous theorem proven by Fermat says $p = x^2 + y^2$ if and only if $p \equiv 1 \bmod 4$. Also, $x^2 \pmod 3$ only takes on the values of $0$ or $1$.
Now we have $p = x^2 + 9y^2 = x^2 + (3y)^2$.
The finish (credit to Mikhail Ivanov):
$\Rightarrow$: Let $p = 12k+1$. We know $p = x^2 + y^2$. If neither $x, y$ are divisible by $3$, then $p \equiv x^2 + y^2 \equiv 2 \mod 3$, contradiction. Hence, one of $x$ or $y$ is divisible by $3$, WLOG let $x = 3z$. Then we have $p = 9z^2 + y^2$, which is what we wanted to prove.
$\Leftarrow$: We have $x^2 + 9y^2 \equiv x^2 \equiv 0$ or $1 \mod 3$ and $x^2 + 9y^2 \equiv 0, 1$ or $2 \mod 4$.
The possibilities $\mod 12$ are then $0, 1, 4, 6, 9, 10$. Only $1$ is possible to be prime, thus $x^2 + 9y^2 \equiv 1 \mod 12$ if it is prime.
