func Generate(bits int, generator Generator, cb GeneratorCallback) (*DH, error) {
	var (
		err       error
		padd, rem int64
		prime     *big.Int
	)

	if cb == nil {
		cb = nullCallback
	}

	switch generator {
	case 2:
		padd, rem = 24, 11
	case 5:
		padd, rem = 10, 3
	default:
		padd, rem = 2, 1
	}

	for {
		if prime, err = genPrime(bits, big.NewInt(padd), big.NewInt(rem)); err != nil {
			return nil, err
		}

		if prime.BitLen() > bits {
			continue
		}

		t := new(big.Int)
		t.Rsh(prime, 1)

		cb(GeneratorFoundPossiblePrime)

		if prime.ProbablyPrime(0) {
			cb(GeneratorFirstConfirmation)
		} else {
			continue
		}

		if t.ProbablyPrime(0) {
			cb(GeneratorSafePrimeFound)
			break
		}
	}

	return &DH{
		P: prime,
		G: int(generator),
	}, nil
}
// Generate determines a prime number according to the generator having the specified number of bits
//
// In OpenSSL defined generators are 2 and 5. Others are supported but the verification is not supported in an extend as with generators 2 and 5.
// The bit size should be adjusted to be high enough for the current requirements. Also you should keep
// in mind the higher the bitsize, the longer the generation might take.
Generate determines a prime number according to the generator having the specified number of bits

In OpenSSL defined generators are 2 and 5. Others are supported but the verification is not supported in an extend as with generators 2 and 5.
The bit size should be adjusted to be high enough for the current requirements. Also you should keep
in mind the higher the bitsize, the longer the generation might take.
// Generate determines a prime number according to the generator having the specified number of bits // // In OpenSSL defined generators are 2 and 5 . Others are supported but the verification is not supported in an extend as with generators 2 and 5 . // The bit size should be adjusted to be high enough for the current requirements . Also you should keep // in mind the higher the bitsize the longer the generation might take .
func Generate(bits int, generator Generator, cb GeneratorCallback) (*DH, error) {
	var (
		err       error
		padd, rem int64
		prime     *big.Int
	)
	if cb == nil {
		cb = nullCallback
	}
	switch generator {
	case 2:
		padd, rem = 24, 11
	case 5:
		padd, rem = 10, 3
	default:
		padd, rem = 2, 1
	}
	for {
		if prime, err = genPrime(bits, big.NewInt(padd), big.NewInt(rem)); err != nil {
			return nil, err
		}
		if prime.BitLen() > bits {
			continue
		}
		t := new(big.Int)
		t.Rsh(prime, 1)
		cb(GeneratorFoundPossiblePrime)
		if prime.ProbablyPrime(0) {
			cb(GeneratorFirstConfirmation)
		} else {
			continue
		}
		if t.ProbablyPrime(0) {
			cb(GeneratorSafePrimeFound)
			break
		}
	}
	return &DH{
		P: prime,
		G: int(generator),
	}, nil
}
func Generate ( bits int , generator Generator , cb GeneratorCallback ) ( * DH , error ) { var ( err error padd , rem int64 prime * big . Int ) if cb == nil { cb = nullCallback } switch generator { case 2 : padd , rem = 24 , 11 case 5 : padd , rem = 10 , 3 default : padd , rem = 2 , 1 } for { if prime , err = genPrime ( bits , big . NewInt ( padd ) , big . NewInt ( rem ) ) ; err != nil { return nil , err } if prime . BitLen ( ) > bits { continue } t := new ( big . Int ) t . Rsh ( prime , 1 ) cb ( GeneratorFoundPossiblePrime ) if prime . ProbablyPrime ( 0 ) { cb ( GeneratorFirstConfirmation ) } else { continue } if t . ProbablyPrime ( 0 ) { cb ( GeneratorSafePrimeFound ) break } } return & DH { P : prime , G : int ( generator ) , } , nil }
Generate determines a prime number according to the generator having the specified number of bits
Generate determines a prime number according to the generator having the specified number of bits