mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-21 22:02:06 +01:00
Merge remote-tracking branch 'vanitas/oxSecretKeyBackupRestore' into mercuryPatches
This commit is contained in:
commit
fb352d64c2
2 changed files with 3 additions and 13 deletions
|
@ -20,7 +20,6 @@ import static org.jivesoftware.smackx.ox.util.OpenPgpPubSubUtil.PEP_NODE_PUBLIC_
|
|||
import static org.jivesoftware.smackx.ox.util.OpenPgpPubSubUtil.PEP_NODE_PUBLIC_KEYS_NOTIFY;
|
||||
import static org.jivesoftware.smackx.ox.util.OpenPgpPubSubUtil.publishPublicKey;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.security.InvalidAlgorithmParameterException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
@ -43,7 +42,6 @@ import org.jivesoftware.smack.packet.Message;
|
|||
import org.jivesoftware.smack.util.Async;
|
||||
import org.jivesoftware.smack.util.stringencoder.Base64;
|
||||
import org.jivesoftware.smack.xml.XmlPullParserException;
|
||||
|
||||
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
|
||||
import org.jivesoftware.smackx.ox.callback.backup.AskForBackupCodeCallback;
|
||||
import org.jivesoftware.smackx.ox.callback.backup.DisplayBackupCodeCallback;
|
||||
|
@ -76,12 +74,9 @@ import org.jivesoftware.smackx.pubsub.PubSubException;
|
|||
import org.jivesoftware.smackx.pubsub.PubSubFeature;
|
||||
|
||||
import org.bouncycastle.openpgp.PGPException;
|
||||
import org.bouncycastle.openpgp.PGPPublicKey;
|
||||
import org.bouncycastle.openpgp.PGPPublicKeyRing;
|
||||
import org.bouncycastle.openpgp.PGPSecretKey;
|
||||
import org.bouncycastle.openpgp.PGPSecretKeyRing;
|
||||
import org.bouncycastle.openpgp.PGPSecretKeyRingCollection;
|
||||
import org.bouncycastle.openpgp.operator.bc.BcKeyFingerprintCalculator;
|
||||
import org.jxmpp.jid.BareJid;
|
||||
import org.jxmpp.jid.EntityBareJid;
|
||||
import org.pgpainless.key.OpenPgpV4Fingerprint;
|
||||
|
@ -479,16 +474,11 @@ public final class OpenPgpManager extends Manager {
|
|||
String backupCode = codeCallback.askForBackupCode();
|
||||
|
||||
PGPSecretKeyRing secretKeys = SecretKeyBackupHelper.restoreSecretKeyBackup(backup, backupCode);
|
||||
OpenPgpV4Fingerprint fingerprint = new OpenPgpV4Fingerprint(secretKeys);
|
||||
provider.getStore().importSecretKey(getJidOrThrow(), secretKeys);
|
||||
provider.getStore().importPublicKey(getJidOrThrow(), BCUtil.publicKeyRingFromSecretKeyRing(secretKeys));
|
||||
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream(2048);
|
||||
for (PGPSecretKey sk : secretKeys) {
|
||||
PGPPublicKey pk = sk.getPublicKey();
|
||||
if (pk != null) pk.encode(buffer);
|
||||
}
|
||||
PGPPublicKeyRing publicKeys = new PGPPublicKeyRing(buffer.toByteArray(), new BcKeyFingerprintCalculator());
|
||||
provider.getStore().importPublicKey(getJidOrThrow(), publicKeys);
|
||||
getOpenPgpSelf().trust(fingerprint);
|
||||
|
||||
return new OpenPgpV4Fingerprint(secretKeys);
|
||||
}
|
||||
|
|
|
@ -111,7 +111,7 @@ public class OpenPgpPubSubUtil {
|
|||
* Publish the users OpenPGP public key to the public key node if necessary.
|
||||
* Also announce the key to other users by updating the metadata node.
|
||||
*
|
||||
* @see <a href="https://xmpp.org/extensions/xep-0373.html#annoucning-pubkey">XEP-0373 §4.1</a>
|
||||
* @see <a href="https://xmpp.org/extensions/xep-0373.html#announcing-pubkey">XEP-0373 §4.1</a>
|
||||
*
|
||||
* @param pepManager The PEP manager.
|
||||
* @param pubkeyElement {@link PubkeyElement} containing the public key
|
||||
|
|
Loading…
Reference in a new issue