From d8e89c88224d3e32e853fbb9c59a6fadb8d0f832 Mon Sep 17 00:00:00 2001 From: Thialfihar Date: Sat, 24 Apr 2010 17:52:13 +0000 Subject: [PATCH] choose the NEAREST prime for ElGamal, rather than the next lowest --- src/org/thialfihar/android/apg/Primes.java | 10 +++++----- .../thialfihar/android/apg/ui/widget/SectionView.java | 5 +++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/org/thialfihar/android/apg/Primes.java b/src/org/thialfihar/android/apg/Primes.java index 28ff732a2..e97a6c6c5 100644 --- a/src/org/thialfihar/android/apg/Primes.java +++ b/src/org/thialfihar/android/apg/Primes.java @@ -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; diff --git a/src/org/thialfihar/android/apg/ui/widget/SectionView.java b/src/org/thialfihar/android/apg/ui/widget/SectionView.java index 2cac2375b..865267660 100644 --- a/src/org/thialfihar/android/apg/ui/widget/SectionView.java +++ b/src/org/thialfihar/android/apg/ui/widget/SectionView.java @@ -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);