public class SecretKeyBackupHelper extends Object
Constructor and Description |
---|
SecretKeyBackupHelper() |
Modifier and Type | Method and Description |
---|---|
static SecretkeyElement |
createSecretkeyElement(byte[] keys,
String backupCode)
Create a
SecretkeyElement which contains the secret keys which are serialized in keys and is
symmetrically encrypted using the backupCode . |
static SecretkeyElement |
createSecretkeyElement(OpenPgpProvider provider,
org.jxmpp.jid.BareJid owner,
Set<org.pgpainless.key.OpenPgpV4Fingerprint> fingerprints,
String backupCode)
Create a
SecretkeyElement which contains the secret keys listed in fingerprints and is encrypted
symmetrically using the backupCode . |
static String |
generateBackupPassword()
Generate a secure backup code.
|
static org.bouncycastle.openpgp.PGPSecretKeyRing |
restoreSecretKeyBackup(SecretkeyElement backup,
String backupCode)
Decrypt a secret key backup and return the
PGPSecretKeyRing contained in it. |
public SecretKeyBackupHelper()
public static String generateBackupPassword()
public static SecretkeyElement createSecretkeyElement(OpenPgpProvider provider, org.jxmpp.jid.BareJid owner, Set<org.pgpainless.key.OpenPgpV4Fingerprint> fingerprints, String backupCode) throws org.bouncycastle.openpgp.PGPException, IOException, MissingOpenPgpKeyException
SecretkeyElement
which contains the secret keys listed in fingerprints
and is encrypted
symmetrically using the backupCode
.provider
- OpenPgpProvider
for symmetric encryption.owner
- owner of the secret keys (usually our jid).fingerprints
- set of OpenPgpV4Fingerprint
s of the keys which are going to be backed up.backupCode
- passphrase for symmetric encryption.SecretkeyElement
org.bouncycastle.openpgp.PGPException
- PGP is brittleIOException
- IO is dangerousMissingOpenPgpKeyException
- in case one of the keys whose fingerprint is in fingerprints
is
not accessible.public static SecretkeyElement createSecretkeyElement(byte[] keys, String backupCode) throws org.bouncycastle.openpgp.PGPException, IOException
SecretkeyElement
which contains the secret keys which are serialized in keys
and is
symmetrically encrypted using the backupCode
.keys
- serialized OpenPGP secret keys in transferable key formatbackupCode
- passphrase for symmetric encryptionSecretkeyElement
org.bouncycastle.openpgp.PGPException
- PGP is brittleIOException
- IO is dangerouspublic static org.bouncycastle.openpgp.PGPSecretKeyRing restoreSecretKeyBackup(SecretkeyElement backup, String backupCode) throws InvalidBackupCodeException, IOException, org.bouncycastle.openpgp.PGPException
PGPSecretKeyRing
contained in it.
TODO: Return a PGPSecretKeyRingCollection instead?backup
- encrypted SecretkeyElement
containing the backupbackupCode
- passphrase for decrypting the SecretkeyElement
.InvalidBackupCodeException
- in case the provided backup code is invalid.IOException
- IO is dangerous.org.bouncycastle.openpgp.PGPException
- PGP is brittle.