fix cv25519 encryption key generation
This commit is contained in:
committed by
Vincent Breitmoser
parent
3288adf5b2
commit
5f0646b7e9
@@ -269,9 +269,14 @@ public class PgpKeyOperation {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
progress(R.string.progress_generating_ecdh, 30);
|
progress(R.string.progress_generating_ecdh, 30);
|
||||||
ECGenParameterSpec ecParamSpec = getEccParameterSpec(add.getCurve());
|
if (add.getCurve() == Curve.CV25519) {
|
||||||
keyGen = KeyPairGenerator.getInstance("ECDH", Constants.BOUNCY_CASTLE_PROVIDER_NAME);
|
keyGen = KeyPairGenerator.getInstance("X25519");
|
||||||
keyGen.initialize(ecParamSpec, new SecureRandom());
|
keyGen.initialize(255);
|
||||||
|
} else {
|
||||||
|
ECGenParameterSpec ecParamSpec = getEccParameterSpec(add.getCurve());
|
||||||
|
keyGen = KeyPairGenerator.getInstance("ECDH", Constants.BOUNCY_CASTLE_PROVIDER_NAME);
|
||||||
|
keyGen.initialize(ecParamSpec, new SecureRandom());
|
||||||
|
}
|
||||||
|
|
||||||
algorithm = PGPPublicKey.ECDH;
|
algorithm = PGPPublicKey.ECDH;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -324,7 +324,7 @@ public abstract class SaveKeyringParcel implements Parcelable {
|
|||||||
// All curves defined in the standard
|
// All curves defined in the standard
|
||||||
// http://www.bouncycastle.org/wiki/pages/viewpage.action?pageId=362269
|
// http://www.bouncycastle.org/wiki/pages/viewpage.action?pageId=362269
|
||||||
public enum Curve {
|
public enum Curve {
|
||||||
NIST_P256, NIST_P384, NIST_P521,
|
NIST_P256, NIST_P384, NIST_P521, CV25519
|
||||||
|
|
||||||
// these are supported by gpg, but they are not in rfc6637 and not supported by BouncyCastle yet
|
// these are supported by gpg, but they are not in rfc6637 and not supported by BouncyCastle yet
|
||||||
// (adding support would be trivial though -> JcaPGPKeyConverter.java:190)
|
// (adding support would be trivial though -> JcaPGPKeyConverter.java:190)
|
||||||
|
|||||||
@@ -262,6 +262,10 @@ public class AddSubkeyDialogFragment extends DialogFragment {
|
|||||||
curve = Curve.NIST_P521;
|
curve = Curve.NIST_P521;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case EDDSA: {
|
||||||
|
curve = Curve.CV25519;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// set algorithm
|
// set algorithm
|
||||||
@@ -283,7 +287,11 @@ public class AddSubkeyDialogFragment extends DialogFragment {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case EDDSA: {
|
case EDDSA: {
|
||||||
algorithm = Algorithm.EDDSA;
|
if(mUsageEncrypt.isChecked()) {
|
||||||
|
algorithm = Algorithm.ECDH;
|
||||||
|
} else {
|
||||||
|
algorithm = Algorithm.EDDSA;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -188,6 +188,8 @@ public class KeyFormattingUtils {
|
|||||||
return "NIST P-384";
|
return "NIST P-384";
|
||||||
case NIST_P521:
|
case NIST_P521:
|
||||||
return "NIST P-521";
|
return "NIST P-521";
|
||||||
|
case CV25519:
|
||||||
|
return "Curve25519";
|
||||||
|
|
||||||
/* see SaveKeyringParcel
|
/* see SaveKeyringParcel
|
||||||
case BRAINPOOL_P256:
|
case BRAINPOOL_P256:
|
||||||
|
|||||||
Reference in New Issue
Block a user