Show max AES key size

This commit is contained in:
M66B 2019-12-02 11:00:00 +01:00
parent cb0db5de3e
commit ab0ad41d89
3 changed files with 22 additions and 0 deletions

View File

@ -55,6 +55,7 @@ import androidx.preference.PreferenceManager;
import org.openintents.openpgp.util.OpenPgpApi;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.List;
@ -70,6 +71,7 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
private Button btnPin;
private Spinner spBiometricsTimeout;
private Button btnImportKey;
private TextView tvKeySize;
private List<String> openPgpProvider = new ArrayList<>();
@ -101,6 +103,7 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
btnPin = view.findViewById(R.id.btnPin);
spBiometricsTimeout = view.findViewById(R.id.spBiometricsTimeout);
btnImportKey = view.findViewById(R.id.btnImportKey);
tvKeySize = view.findViewById(R.id.tvKeySize);
Intent intent = new Intent(OpenPgpApi.SERVICE_INTENT_2);
List<ResolveInfo> ris = getContext().getPackageManager().queryIntentServices(intent, 0);
@ -232,6 +235,14 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
}
});
try {
int maxKeySize = javax.crypto.Cipher.getMaxAllowedKeyLength("AES");
tvKeySize.setText(getString(R.string.title_aes_key_size, maxKeySize));
} catch (NoSuchAlgorithmException ex) {
tvKeySize.setText(Helper.formatThrowable(ex));
}
tvKeySize.setVisibility(BuildConfig.DEBUG ? View.VISIBLE : View.GONE);
PreferenceManager.getDefaultSharedPreferences(getContext()).registerOnSharedPreferenceChangeListener(this);
return view;

View File

@ -218,5 +218,15 @@
android:text="@string/title_import_encrypt_key"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/spBiometricsTimeout" />
<TextView
android:id="@+id/tvKeySize"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@string/title_aes_key_size"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/btnImportKey" />
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>

View File

@ -699,6 +699,7 @@
<string name="title_not_encrypted">Message is not signed or encrypted</string>
<string name="title_reset_sign_key">Reset sign key</string>
<string name="title_import_encrypt_key">Import encryption key</string>
<string name="title_aes_key_size" translatable="false">Max AES key size: %1$d</string>
<string name="title_signature_none">Message not signed</string>
<string name="title_signature_valid">Message signature valid</string>