Genetic stability is a key factor in maintaining, survival and reproduction of biological cells. It relies on many processes, but one of the most important is a homologous recombination, in which the repair of breaks in double-stranded DNA molecules is taking place with a help of several specific proteins. In bacteria this task is accomplished by RecA proteins that are active as nucleoprotein filaments formed on single-stranded segments of DNA. A critical step in the homologous recombination is a search for a corresponding homologous region on DNA, which is called a homology search. Recent single-molecule experiments clarified some aspects of this process, but its molecular mechanisms remain not well understood. We developed a quantitative theoretical approach to analyze the homology search. It is based on a discrete-state stochastic model that takes into account the most relevant physical-chemical processes in the system. Using a method of first-passage processes, a full dynamic description of the homology search is presented. It is found that the search dynamics depends on the degree of extension of DNA molecules and on the size of RecA nucleoprotein filaments, in agreement with experimental single-molecule measurements of DNA pairing by RecA proteins. Our theoretical calculations, supported by extensive Monte Carlo computer simulations, provide a molecular description of the mechanisms of the homology search.