Neukirch mentions in his book on Algebraic Number Theory that the primes $\equiv 1\pmod 4$ are sums of squares, and it is not so obvious (compared to converse). While going for proof of it myself, I came to a problem; there could be similar questions, but I am interested in proceeding one step to complete proof which I was working.
Let $p\equiv 1\pmod 4$, and assume $p$ is odd. Then $4$ divides $(p-1)$, which is order of cyclic group $(\mathbb{Z}/p\mathbb{Z})^{\times}$. This gives that $-1$ is square mod $p$, say $a^2\equiv -1\pmod p$ i.e. $p$ divides $(a^2+1)$ for some integer $a$.
Case 1. $p$ is reducible in $\mathbb{Z}[i]$.
Say $p=(a+bi)(c+di)$ in $\mathbb{Z}[i]$, where factors are non-units.
Then we also have $p=(a-bi)(c-di)$, so $p^2=(a^2+b^2)(c^2+d^2)$.
Thus $a^2+b^2, c^2+d^2\in \{1,p,p^2\}$.
If $a^2+b^2$ is $1$ or $p^2$, then it is easy to see that $a+bi$ or $c+di$ are units (respectively), contradiction.
Thus, $a^2+b^2$ must be $p$, which is what we wanted to prove. But we did it only in one case.
Case 2. $p$ is irreducible in $\mathbb{Z}[i]$.
This case, I was unable to proceed, and I do not know whether we get a contradiction, or not. Any hint for this case?