Generating prime numbers with specified properties

To implement a cryptographic algorithm, it is necessary to generate sufficiently large primes p and q such that each of them is comparable to 3 modulo 4. While studying methods for generating primes, I found a method based on the Miller-Rabin test suitable for me. The general idea is as follows: we take a sufficiently large number, check it with the test, if the test shows "the number is probably prime" - take it, otherwise - add 1 to it and check it again with the test. How modify this algorithm to (with some probability) obtain primes of a given length with the property described above?

Author: DarkGenius, 2014-01-09