简体   繁体   中英

Generating P in DSA algorithm java

Could you tell me if I am right? I want to generate p in DSA algorithm. I don't understaand that: || pTemp.bitLength() != l || pTemp.bitLength() != l in the do while statement, because it means I am looking only for 1 digit prime which is 2,5,7? It is nonsense.

private BigInteger generateP(BigInteger q, int l) { 
    if (l % 64 != 0) { 
        throw new IllegalArgumentException("L value is wrong");
    } 
    BigInteger pTemp;
    BigInteger pTemp2;
    int i = 0;
    do {
        //pTemp = new BigInteger(l, primeCenterie, rand);  <--- this is useless also?
        pTemp = new BigInteger(l,  rand);
        pTemp2 = pTemp.subtract(BigInteger.ONE);
        pTemp = pTemp.subtract(pTemp2.remainder(q));
        System.out.println("1 " + i++); 
    } while (!pTemp.isProbablePrime(primeCenterie) || pTemp.bitLength() != l);

    return pTemp;
}

IT is not 1(one) but l(L) everything was okay. I was doing it 2 months ago and didn't understand it now.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM