What is the easiest arithmetic to get the 168px distance marked in red in the rectangle based on a square which is 340px width x 577px height and rotated 45 deg ?
I came to the solution: 168px doing the following calculation:
(577px / square root of 2) - (340px / square root of 2) = 168px
Is there a simpler way to get this value?

I don't know how you reached the values of 648px and 240px, but your left corner, top corner, and middle point from the two lines leaving these form a 45-45-90 triangle.
The two legs of a 45-45-90 triangle must have equal lengths.
Therefore, if your math is correct, 648 must equal 240 + 168. It does not, therefore your solution is incorrect.
If you know for sure the one side is 648, then simply, 648 - 240 for 408.