Keystoning occurs when the subject is not parallel with the camera lense. For example, if the camera lense is closer to the bottom of the building, it will appear much larger than the top of the building in the photograph.
1. Double the size of the canvas. Image > Canvas Size
2. Select the entire image area.
3. Edit > Transform > Skew
To rectify right angles and retain proportions do not pull top corner fully out, but only halfway out, and then pull other corner halfway in, creating a fulcrum upon the midpoint of the line.
It may help to view the image with a grid. View > Show > Grid
4. Now crop out the superfluous two corners.