choose the NEAREST prime for ElGamal, rather than the next lowest

This commit is contained in:
Thialfihar 2010-04-24 17:52:13 +00:00
parent 81cdd6b943
commit d8e89c8822
2 changed files with 8 additions and 7 deletions

View File

@ -166,15 +166,15 @@ public final class Primes {
public static BigInteger getBestPrime(int keySize) {
String primeString;
if (keySize >= 8192) {
if (keySize >= (8192 + 6144) / 2) {
primeString = P8192;
} else if (keySize >= 6144) {
} else if (keySize >= (6144 + 4096) / 2) {
primeString = P6144;
} else if (keySize >= 4096) {
} else if (keySize >= (4096 + 3072) / 2) {
primeString = P4096;
} else if (keySize >= 3072) {
} else if (keySize >= (3072 + 2048) / 2) {
primeString = P3072;
} else if (keySize >= 2048) {
} else if (keySize >= (2048 + 1536) / 2) {
primeString = P2048;
} else {
primeString = P1536;

View File

@ -181,8 +181,9 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
View view = mInflater.inflate(R.layout.create_key, null);
dialog.setView(view);
dialog.setTitle("Create Key");
dialog.setMessage("Note: only subkeys support ElGamal, and for ElGamal will use " +
"the next smallest keysize of 1536, 2048, 3072, 4096, or 8192.");
dialog.setMessage("Note: only subkeys support ElGamal, and for ElGamal " +
"the nearest keysize of 1536, 2048, 3072, 4096, or 8192 " +
"will be used");
boolean wouldBeMasterKey = (mEditors.getChildCount() == 0);