Class SecretKeyBackupHelper


  • public class SecretKeyBackupHelper
    extends java.lang.Object
    Helper class which provides some functions needed for backup/restore of the users secret key to/from their private PubSub node.
    • Constructor Detail

      • SecretKeyBackupHelper

        public SecretKeyBackupHelper()
    • Method Detail

      • createSecretkeyElement

        public static SecretkeyElement createSecretkeyElement​(OpenPgpProvider provider,
                                                              org.jxmpp.jid.BareJid owner,
                                                              java.util.Set<org.pgpainless.key.OpenPgpV4Fingerprint> fingerprints,
                                                              OpenPgpSecretKeyBackupPassphrase backupCode)
                                                       throws org.bouncycastle.openpgp.PGPException,
                                                              java.io.IOException,
                                                              MissingOpenPgpKeyException
        Create a SecretkeyElement which contains the secret keys listed in fingerprints and is encrypted symmetrically using the backupCode.
        Parameters:
        provider - OpenPgpProvider for symmetric encryption.
        owner - owner of the secret keys (usually our jid).
        fingerprints - set of OpenPgpV4Fingerprints of the keys which are going to be backed up.
        backupCode - passphrase for symmetric encryption.
        Returns:
        SecretkeyElement
        Throws:
        org.bouncycastle.openpgp.PGPException - PGP is brittle
        java.io.IOException - IO is dangerous
        MissingOpenPgpKeyException - in case one of the keys whose fingerprint is in fingerprints is not accessible.
      • createSecretkeyElement

        public static SecretkeyElement createSecretkeyElement​(byte[] keys,
                                                              OpenPgpSecretKeyBackupPassphrase backupCode)
                                                       throws org.bouncycastle.openpgp.PGPException,
                                                              java.io.IOException
        Create a SecretkeyElement which contains the secret keys which are serialized in keys and is symmetrically encrypted using the backupCode.
        Parameters:
        keys - serialized OpenPGP secret keys in transferable key format
        backupCode - passphrase for symmetric encryption
        Returns:
        SecretkeyElement
        Throws:
        org.bouncycastle.openpgp.PGPException - PGP is brittle
        java.io.IOException - IO is dangerous
        See Also:
        XEP-0373 §5.4 Encrypting the Secret Key Backup
      • restoreSecretKeyBackup

        public static org.bouncycastle.openpgp.PGPSecretKeyRing restoreSecretKeyBackup​(SecretkeyElement backup,
                                                                                       OpenPgpSecretKeyBackupPassphrase backupCode)
                                                                                throws InvalidBackupCodeException,
                                                                                       java.io.IOException,
                                                                                       org.bouncycastle.openpgp.PGPException
        Decrypt a secret key backup and return the PGPSecretKeyRing contained in it. TODO: Return a PGPSecretKeyRingCollection instead?
        Parameters:
        backup - encrypted SecretkeyElement containing the backup
        backupCode - passphrase for decrypting the SecretkeyElement.
        Returns:
        the TODO javadoc me please
        Throws:
        InvalidBackupCodeException - in case the provided backup code is invalid.
        java.io.IOException - IO is dangerous.
        org.bouncycastle.openpgp.PGPException - PGP is brittle.