Let $n\in\mathbb{Z}_{>0}$. Prove that there exist $x,y,z\in\mathbb{Z}_2$ (2-adic integers) such that $x^2+y^2+z^2=n$ if and only if $n$ is not of the form $4^m(8k+1)$ with $k,m\in\mathbb{Z}_{>0}$.
I suppose this problem has to do with the Hasse principle. However, in class we only saw results for quadratic equations in two variables. Does there exist an efficient way to solve this type of problem?