In order to castle, neither the King nor the Rook involved may have moved yet. Also, the King may not castle out of check, ...

In order to castle, neither the King nor the Rook involved may have moved yet. Also, the King may not castle out of check, into check, or through check. Further, there may not be pieces of either color between the King and the Rook involved in castling.