Sperm are propelled by an actively beating tail, and display a wide variety of swimming patterns. When confined between two parallel walls, sperm swim either in circles or on curvilinear trajectories close to the walls. We employ mesoscale hydrodynamics simulations in combination with a mechanical sperm model to study the swimming behavior near walls. The simulations show that sperm become captured at the wall due to the hydrodynamic flow fields which are generated by the flagellar beat. The circular trajectories are determined by the chiral asymmetry of the sperm shape. For strong (weak) chirality, sperm swim in tight (wide) circles, with the beating plane of the flagellum oriented perpendicular (parallel) to the wall. For comparison, we also perform simulations based on a local anisotropic friction of the flagellum. In this resistive force approximation, surface adhesion and circular swimming patterns are obtained as well. However, the adhesion mechanism is now due to steric repulsion, and the orientation of the beating plane is different. Our model provides a theoretical framework that explains several distinct swimming behaviors of sperm near and far from a wall. Moreover, the model suggests a mechanism by which sperm navigate in a chemical gradient via a change of their shape.