We consider the Dirac equation in cylindrically symmetric magnetic fields and find its normal modes as eigenfunctions of a complete set of commuting operators. This set consists of the Dirac operator itself, the $z$-components of the linear and the total angular momenta, and of one of the possible spin polarization operators. The spin structure of the solution is completely fixed independently of the radial distribution of the magnetic field which influences only the radial modes. We solve explicitly the radial equations for the uniform magnetic field inside a solenoid of a finite radius and consider in detail the scattering of scalar and Dirac particles in this field. For particles with low energy the scattering cross section coincides with the Aharonov-Bohm scattering cross section. We work out the first order corrections to this result caused by the fact that the solenoid radius is finite. At high energies we obtain the classical result for the scattering cross section.