Context. The acceleration of electrons to nonthermal energies in solar flares is one of the main unsolved questions in solar physics. One possibility for producing these energetic electrons is acceleration at the reconnection outflow termination shock (TS). Aims. By comparing theoretical results with observations of nonthermal electrons, we determine whether shock drift acceleration (SDA) at the TS is a viable electron acceleration mechanism. Methods. We used radio observations to constrain the characteristics of the TS, and hard X-ray observations provided by RHESSI, INTEGRAL, and HXRS to obtain the characteristics of the injected electrons. Invoking relativistic shock-drift acceleration at the TS, we calculated electron flux spectra, which are then compared with the corresponding observational results from RHESSI. A parametric study of the model allows us to answer the question under which conditions the TS is a viable electron accelerator. Results. SDA at the TS is able to reproduce the required fluxes and kinetic power of nonthermal electrons in solar flares as long as there is significant heating of the outflow jet and a sufficiently large shock area. A prediction of the model is that the flux and power of injected electrons is higher than the values that are usually given by fitting observed spectra, since the low-energy cutoff is generally below 10 keV. The synthetic spectra are consistent with the observed spectral indices up to approximate to 100 keV. Beyond that, they soften too quickly. Possibly this is because we have not yet considered various additional effects, such as multiple reflections at the shock or some form of preacceleration. The observed relation between electron flux and spectral index is reproduced by the model, as well as the temporal evolution of the energetic electrons. We conclude that SDA at the TS is a viable electron acceleration mechanism that deserves further study.