public class KeyForSigning extends Key
Regardless of PGP usage flags associated with the original key source,
only the last subkey flagged for signing will be used, and the key will be
used for nothing else (so the Encryptor
will use this key only for
signing, and not for encryption; and the Decryptor
will ignore this
key entirely). If no subkeys have been flagged for signing, this class
will automatically flag the subkey most likely to have been intended to be
used for signing.
Use like the following:
new Encryptor(
new KeyForSigning(new File("path/to/my/keys/alice-sec.gpg"), "password123"),
new KeyForEncryption(new File("path/to/my/keys/bob-pub.gpg"))
).encrypt(
new File("path/to/plaintext.txt"),
new File("path/to/ciphertext.txt.gpg")
);
Key
NO_PASSPHRASE
Constructor and Description |
---|
KeyForSigning()
Constructs a new empty key.
|
KeyForSigning(java.io.File file)
Loads first key from the specified file.
|
KeyForSigning(java.io.File file,
char[] passphraseChars)
Loads first key from the specified file,
and sets the passphrase of all subkeys to the specified passphrase.
|
KeyForSigning(java.io.File file,
java.lang.String passphrase)
Loads first key from the specified file,
and sets the passphrase of all subkeys to the specified passphrase.
|
KeyForSigning(java.io.InputStream stream)
Loads first key from the specified input stream.
|
KeyForSigning(java.io.InputStream stream,
char[] passphraseChars)
Loads first key from the specified input stream,
and sets the passphrase of all subkeys to the specified passphrase.
|
KeyForSigning(java.io.InputStream stream,
java.lang.String passphrase)
Loads first key from the specified input stream,
and sets the passphrase of all subkeys to the specified passphrase.
|
KeyForSigning(java.util.List<Subkey> subkeys)
Constructs a new key with the specified subkeys.
|
KeyForSigning(java.lang.String armor)
Loads first key from the specified armored text.
|
KeyForSigning(java.lang.String armor,
char[] passphraseChars)
Loads first key from the specified armored text,
and sets the passphrase of all subkeys to the specified passphrase.
|
KeyForSigning(java.lang.String armor,
java.lang.String passphrase)
Loads first key from the specified armored text,
and sets the passphrase of all subkeys to the specified passphrase.
|
clearSecrets, clone, findAll, findAll, findById, getDecryption, getEncryption, getMaster, getSigning, getSigningUid, getSubkeys, getUids, getVerification, isForDecryption, isForEncryption, isForSigning, isForVerification, load, load, load, matches, matches, setNoPassphrase, setPassphrase, setPassphraseChars, setSigningUid, toPublicKey, toString
public KeyForSigning()
public KeyForSigning(java.util.List<Subkey> subkeys)
public KeyForSigning(java.lang.String armor) throws java.io.IOException, org.bouncycastle.openpgp.PGPException
org.bouncycastle.openpgp.PGPException
- if the text contains no keys.java.io.IOException
public KeyForSigning(java.lang.String armor, char[] passphraseChars) throws java.io.IOException, org.bouncycastle.openpgp.PGPException
org.bouncycastle.openpgp.PGPException
- if the text contains no keys.java.io.IOException
public KeyForSigning(java.lang.String armor, java.lang.String passphrase) throws java.io.IOException, org.bouncycastle.openpgp.PGPException
KeyForSigning(String, char[])
to avoid creating
extra copies of the passphrase in memory that cannot be cleaned up.org.bouncycastle.openpgp.PGPException
- if the text contains no keys.java.io.IOException
public KeyForSigning(java.io.File file) throws java.io.IOException, org.bouncycastle.openpgp.PGPException
org.bouncycastle.openpgp.PGPException
- if the file contains no keys.java.io.IOException
public KeyForSigning(java.io.File file, char[] passphraseChars) throws java.io.IOException, org.bouncycastle.openpgp.PGPException
org.bouncycastle.openpgp.PGPException
- if the file contains no keys.java.io.IOException
public KeyForSigning(java.io.File file, java.lang.String passphrase) throws java.io.IOException, org.bouncycastle.openpgp.PGPException
KeyForSigning(File, char[])
to avoid creating
extra copies of the passphrase in memory that cannot be cleaned up.org.bouncycastle.openpgp.PGPException
- if the file contains no keys.java.io.IOException
public KeyForSigning(java.io.InputStream stream) throws java.io.IOException, org.bouncycastle.openpgp.PGPException
org.bouncycastle.openpgp.PGPException
- if the input streame contains no keys.java.io.IOException
public KeyForSigning(java.io.InputStream stream, char[] passphraseChars) throws java.io.IOException, org.bouncycastle.openpgp.PGPException
org.bouncycastle.openpgp.PGPException
- if the input streame contains no keys.java.io.IOException
public KeyForSigning(java.io.InputStream stream, java.lang.String passphrase) throws java.io.IOException, org.bouncycastle.openpgp.PGPException
KeyForSigning(InputStream, char[])
to avoid creating
extra copies of the passphrase in memory that cannot be cleaned up.org.bouncycastle.openpgp.PGPException
- if the input streame contains no keys.java.io.IOException