Activate ssh encoding of public keys for ed25519

This commit is contained in:
David Hedberg 2021-02-20 14:26:18 +01:00
parent 38f50c2af6
commit 3fb4771602
2 changed files with 10 additions and 11 deletions

View file

@ -19,11 +19,13 @@ package org.sufficientlysecure.keychain.pgp;
import org.bouncycastle.bcpg.DSAPublicBCPGKey;
import org.bouncycastle.bcpg.ECPublicBCPGKey;
import org.bouncycastle.bcpg.EdDSAPublicBCPGKey;
import org.bouncycastle.bcpg.RSAPublicBCPGKey;
import org.bouncycastle.openpgp.PGPPublicKey;
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
import org.sufficientlysecure.keychain.ssh.key.SshDSAPublicKey;
import org.sufficientlysecure.keychain.ssh.key.SshECDSAPublicKey;
import org.sufficientlysecure.keychain.ssh.key.SshEd25519PublicKey;
import org.sufficientlysecure.keychain.ssh.key.SshRSAPublicKey;
import org.sufficientlysecure.keychain.ssh.utils.SshUtils;
@ -46,9 +48,8 @@ public class SshPublicKey {
return encodeRSAKey(key);
case PGPPublicKey.ECDSA:
return encodeECKey(key);
// TODO
// case PGPPublicKey.EDDSA:
// return encodeEdDSAKey(key);
case PGPPublicKey.EDDSA:
return encodeEdDSAKey(key);
case PGPPublicKey.DSA:
return encodeDSAKey(key);
default:
@ -73,15 +74,13 @@ public class SshPublicKey {
return sshECDSAPublicKey.getPublicKeyBlob();
}
private String encodeEdDSAKey(PGPPublicKey publicKey) {
EdDSAPublicBCPGKey publicBCPGKey = (EdDSAPublicBCPGKey) publicKey.getPublicKeyPacket().getKey();
SshEd25519PublicKey pubkey = new SshEd25519PublicKey(publicBCPGKey.getEdDSAEncodedPoint());
// private String encodeEdDSAKey(PGPPublicKey publicKey) {
// EdDSAPublicBCPGKey publicBCPGKey = (EdDSAPublicBCPGKey) publicKey.getPublicKeyPacket().getKey();
//
// SshEd25519PublicKey pubkey = new SshEd25519PublicKey(publicBCPGKey.getEdDSAEncodedPoint());
//
// return pubkey.getPublicKeyBlob();
// }
return pubkey.getPublicKeyBlob();
}
private String encodeDSAKey(PGPPublicKey publicKey) {
DSAPublicBCPGKey publicBCPGKey = (DSAPublicBCPGKey) publicKey.getPublicKeyPacket().getKey();

2
extern/bouncycastle vendored

@ -1 +1 @@
Subproject commit 40bdff6428fbe09f20f727abcb06ce5c62efb436
Subproject commit be424633c3bfb942dd07f290dc4b7299034ac021