What are necessary and sufficient conditions on a binary quadratic form $ax^2+bxy+cy^2$, with integer coefficients and solution set in integers, to be equivalent to $x^2-y^2$, and separately to $x^2+y^2$?

The conditions would be in terms of $a,b,c$ but can we say anything about the transformation matrix? Since we are dealing with integers, the determinant is $\pm 1$, but can it be made $1$?

I'm new to binary quadratic forms, so if these questions are trivial, an accessible reference (which answers the questions) would be great. I think the answers are known from bits and pieces that I've read online.