# Could FIPS 186-5 A.1.6 method generate P and Q with different bit size?

refers to FIPS 186-5 document, I have a question about RSA Key generation A.1.6 method, "Generation of Probable Primes with Conditions Based on Auxiliary", my understanding is that, this method sets restriction on the size of Auxiliary prime only, so it is possible to generate P and Q with different bit size. Compared to A.1.3, it sets restriction on P and Q, force P and Q be same size, and must be half size of n. Do my understanding correct? But I use OpenSSL to run the test with A.1.6 method, P and Q always return with same bit size and are half of n as well.

No; when it generates $$P$$ (in step 5.3) and $$Q$$ (in step 6.3), it passes the intended key length (nlen) to the algorithm in appendix B.9. That algorithm will find a (probable) prime in the range $$(\sqrt{2}(2^{nlen/2 - 1}), 2^{nlen/2}-1)$$
This means that both $$P$$ and $$Q$$ will be $$nlen/2$$ bits in length.
• @gx16: with both $P$ and $Q$ in $\bigl(\sqrt{2}(2^{\mathsf{nlen}/2-1}),2^{\mathsf{nlen}/2}\bigr)$, it holds $P\,Q$ in $\bigl((\sqrt{2}(2^{\mathsf{nlen}/2-1}))^2,(2^{\mathsf{nlen}/2})^2\bigr)$, that is $\bigl(2^{\mathsf{nlen}-1},2^\mathsf{nlen}\bigr)$, thus $N$ is exactly $\mathsf{nlen}$ bit. Also, for even $\mathsf{nlen}$, $P$ and $Q$ both are in $\bigl(2^{\mathsf{nlen}/2-1},2^{\mathsf{nlen}/2}\bigr)$, thus $\mathsf{nlen}/2$ bit.