/////////////////////////////////////////// // Create a random example /////////////////////////////////////////// void CRSAFactorHintDlg::OnRandom() { UpdateData(); int m_bitsOfP=GetDlgItemInt(IDC_EDITBITSOFP); if (m_bitsOfN<=10){ CString tmp, myTitle; tmp.LoadString(IDS_RSA_FH_WRONGN); this->GetWindowText(myTitle); MessageBox(tmp,myTitle); } else if(m_bitsOfP<=5 || m_bitsOfP>=m_bitsOfN){ CString tmp, myTitle; tmp.LoadString(IDS_RSA_FH_WRONGP); this->GetWindowText(myTitle); MessageBox(tmp,myTitle); } else{ BeginWaitCursor(); int bitsOfQ=(m_bitsOfN-m_bitsOfP); SetSeed(to_ZZ(GetTime()*10000)); m_p = GenPrime_ZZ(m_bitsOfP); // generate N, p and q ZZ q = GenPrime_ZZ(bitsOfQ); m_N=m_p*q; int newbase=2; // check which representation to use if(m_base==0) newbase=10; if(m_base==1) newbase=16; // m_N=toString(N,newbase,newbase*newbase*2); // m_P=toString(m_p,newbase,newbase*newbase*2); UpdateData(false); updateP(); updateDim(); EndWaitCursor(); } }
void IndexCalc::GeneratePandQ(long bits){ ic_Q = GenGermainPrime_ZZ(bits); ic_P = 2*ic_Q + 1; ic_G = RandomBits_ZZ(bits/6); ic_X = GenPrime_ZZ(bits/8); }