Merge branch 'master' of github.com:openpgp-keychain/openpgp-keychain

This commit is contained in:
Dominik Schürmann 2014-03-19 16:22:26 +01:00
commit 52838a50c1
4 changed files with 32 additions and 17 deletions

View File

@ -26,7 +26,7 @@ import android.content.Intent;
import android.content.IntentFilter;
import android.os.*;
import android.util.Log;
import android.util.LongSparseArray;
import android.support.v4.util.LongSparseArray;
import org.spongycastle.openpgp.PGPException;
import org.spongycastle.openpgp.PGPPrivateKey;
import org.spongycastle.openpgp.PGPSecretKey;

View File

@ -25,6 +25,7 @@ import android.support.v4.app.DialogFragment;
import android.support.v4.app.FragmentActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
import org.sufficientlysecure.keychain.Id;
@ -113,21 +114,8 @@ public class CreateKeyDialogFragment extends DialogFragment {
public void onClick(DialogInterface di, int id) {
di.dismiss();
try {
int nKeyIndex = keySize.getSelectedItemPosition();
switch (nKeyIndex) {
case 0:
mNewKeySize = 512;
break;
case 1:
mNewKeySize = 1024;
break;
case 2:
mNewKeySize = 2048;
break;
case 3:
mNewKeySize = 4096;
break;
}
final String selectedItem = (String) keySize.getSelectedItem();
mNewKeySize = Integer.parseInt(selectedItem);
} catch (NumberFormatException e) {
mNewKeySize = 0;
}
@ -145,7 +133,26 @@ public class CreateKeyDialogFragment extends DialogFragment {
}
});
return dialog.create();
final AlertDialog alertDialog = dialog.create();
final AdapterView.OnItemSelectedListener weakRsaListener = new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
final Choice selectedAlgorithm = (Choice)algorithm.getSelectedItem();
final int selectedKeySize = Integer.parseInt((String)keySize.getSelectedItem());
final boolean isWeakRsa = (selectedAlgorithm.getId() == Id.choice.algorithm.rsa && selectedKeySize <= 1024);
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(!isWeakRsa);
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
};
keySize.setOnItemSelectedListener(weakRsaListener);
algorithm.setOnItemSelectedListener(weakRsaListener);
return alertDialog;
}
}

View File

@ -17,6 +17,13 @@
android:padding="4dp"
android:text="@string/key_creation_el_gamal_info" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:padding="4dp"
android:text="@string/key_creation_weak_rsa_info" />
<TableRow>
<TextView

View File

@ -244,6 +244,7 @@
<string name="keys_exported">Successfully exported %d keys.</string>
<string name="no_keys_exported">No keys exported.</string>
<string name="key_creation_el_gamal_info">Note: only subkeys support ElGamal, and for ElGamal the nearest keysize of 1536, 2048, 3072, 4096, or 8192 will be used.</string>
<string name="key_creation_weak_rsa_info">Note: generating RSA key with length 1024-bit and less is considered unsafe and it\'s disabled for generating new keys.</string>
<string name="key_not_found">Couldn\'t find key %08X.</string>
<plurals name="keys_found">