Acceleration of particles by shocks in a cosmic plasma