diff --git a/app/src/main/java/eu/faircode/email/FragmentMessages.java b/app/src/main/java/eu/faircode/email/FragmentMessages.java index d773e92c9a..b89afbb7bb 100644 --- a/app/src/main/java/eu/faircode/email/FragmentMessages.java +++ b/app/src/main/java/eu/faircode/email/FragmentMessages.java @@ -198,6 +198,7 @@ import java.io.UnsupportedEncodingException; import java.math.BigInteger; import java.security.KeyStore; import java.security.PrivateKey; +import java.security.PublicKey; import java.security.cert.CertPathBuilder; import java.security.cert.CertPathBuilderResult; import java.security.cert.CertPathValidator; @@ -211,6 +212,7 @@ import java.security.cert.PKIXBuilderParameters; import java.security.cert.PKIXCertPathValidatorResult; import java.security.cert.X509CertSelector; import java.security.cert.X509Certificate; +import java.security.interfaces.RSAPublicKey; import java.text.Collator; import java.text.DateFormat; import java.text.NumberFormat; @@ -10145,18 +10147,6 @@ public class FragmentMessages extends FragmentBase continue; known = true; - - String keyalgo = null; - String keyalgooid = null; - try { - keyalgooid = s.getEncryptionAlgOID(); - DefaultAlgorithmNameFinder af = new DefaultAlgorithmNameFinder(); - keyalgo = af.getAlgorithmName(new ASN1ObjectIdentifier(keyalgooid)); - } catch (Throwable ex) { - Log.e(ex); - } - args.putString("keyalgo", keyalgo); - args.putString("keyalgooid", keyalgooid); break; } @@ -10167,6 +10157,7 @@ public class FragmentMessages extends FragmentBase args.putString("sender", sender); args.putBoolean("known", known); + // Sign algorithm String algo = null; String algooid = null; try { @@ -10179,6 +10170,22 @@ public class FragmentMessages extends FragmentBase args.putString("algo", algo); args.putString("algooid", algooid); + // Encryption algorithm + String keyalgo = null; + String keyalgooid = null; + try { + keyalgooid = s.getEncryptionAlgOID(); + DefaultAlgorithmNameFinder af = new DefaultAlgorithmNameFinder(); + keyalgo = af.getAlgorithmName(new ASN1ObjectIdentifier(keyalgooid)); + PublicKey pubkey = cert.getPublicKey(); + if (pubkey instanceof RSAPublicKey) + keyalgo += ((RSAPublicKey) pubkey).getModulus().bitLength(); + } catch (Throwable ex) { + Log.e(ex); + } + args.putString("keyalgo", keyalgo); + args.putString("keyalgooid", keyalgooid); + List certs = new ArrayList<>(); try { for (Object m : store.getMatches(null)) { @@ -10487,10 +10494,10 @@ public class FragmentMessages extends FragmentBase if (!TextUtils.isEmpty(keyalgo)) keyalgo = keyalgo.replaceAll("(?i)With", "/"); - tvKeyAlgorithmTitle.setVisibility(info && known ? View.VISIBLE : View.GONE); - tvKeyAlgorithm.setVisibility(info && known ? View.VISIBLE : View.GONE); + tvKeyAlgorithmTitle.setVisibility(info ? View.VISIBLE : View.GONE); + tvKeyAlgorithm.setVisibility(info ? View.VISIBLE : View.GONE); tvKeyAlgorithm.setText(keyalgo); - tvKeyAlgorithmOid.setVisibility(info && known ? View.VISIBLE : View.GONE); + tvKeyAlgorithmOid.setVisibility(info ? View.VISIBLE : View.GONE); tvKeyAlgorithmOid.setText(keyalgooid); AlertDialog.Builder builder = new AlertDialog.Builder(getContext()) diff --git a/app/src/main/res/layout/dialog_certificate.xml b/app/src/main/res/layout/dialog_certificate.xml index 66d6841f48..5b310bd93a 100644 --- a/app/src/main/res/layout/dialog_certificate.xml +++ b/app/src/main/res/layout/dialog_certificate.xml @@ -207,7 +207,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="24dp" - android:text="@string/title_signature_public_key" + android:text="@string/title_advanced_section_encryption" android:textAppearance="@style/TextAppearance.AppCompat.Small" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toBottomOf="@id/tvExpired" />