King-side castling - with King-Rook
Queen-side castling - with Queen-Rook
King --> moves 2 squares
Rook --> moves to the other side of the King
1. The King and castling Rook should not have moved in the game before.
2. There should not be any piece in-between the King and castling Rook.
3. When Check is given, you cannot castle.
4. If the King would come in Check after castling, you cannot castle.
5. If the King would come in Check in-between castling, you cannot castle.
Castling on Wiki