public class PGPPublicKey extends Object implements PublicKeyAlgorithmTags
DIFFIE_HELLMAN, DSA, EC, ECDH, ECDSA, ELGAMAL_ENCRYPT, ELGAMAL_GENERAL, EXPERIMENTAL_1, EXPERIMENTAL_10, EXPERIMENTAL_11, EXPERIMENTAL_2, EXPERIMENTAL_3, EXPERIMENTAL_4, EXPERIMENTAL_5, EXPERIMENTAL_6, EXPERIMENTAL_7, EXPERIMENTAL_8, EXPERIMENTAL_9, RSA_ENCRYPT, RSA_GENERAL, RSA_SIGN
Constructor and Description |
---|
PGPPublicKey(PublicKeyPacket publicKeyPacket,
KeyFingerPrintCalculator fingerPrintCalculator)
Create a PGP public key from a packet descriptor using the passed in fingerPrintCalculator to do calculate
the fingerprint and keyID.
|
Modifier and Type | Method and Description |
---|---|
static PGPPublicKey |
addCertification(PGPPublicKey key,
byte[] rawID,
PGPSignature certification)
Add a certification for an id to the given public key.
|
static PGPPublicKey |
addCertification(PGPPublicKey key,
PGPSignature certification)
Add a revocation or some other key certification to a key.
|
static PGPPublicKey |
addCertification(PGPPublicKey key,
PGPUserAttributeSubpacketVector userAttributes,
PGPSignature certification)
Add a certification for the given UserAttributeSubpackets to the given public key.
|
static PGPPublicKey |
addCertification(PGPPublicKey key,
String id,
PGPSignature certification)
Add a certification for an id to the given public key.
|
void |
encode(OutputStream outStream) |
void |
encode(OutputStream outStream,
boolean forTransfer)
Encode the key to outStream, with trust packets stripped out if forTransfer is true.
|
int |
getAlgorithm()
Return the algorithm code associated with the public key.
|
int |
getBitStrength()
Return the strength of the key in bits.
|
Date |
getCreationTime() |
byte[] |
getEncoded() |
byte[] |
getEncoded(boolean forTransfer)
Return an encoding of the key, with trust packets stripped out if forTransfer is true.
|
byte[] |
getFingerprint()
Return the fingerprint of the key.
|
long |
getKeyID()
Return the keyID associated with the public key.
|
Iterator |
getKeySignatures()
Return all signatures/certifications directly associated with this key (ie, not to a user id).
|
PublicKeyPacket |
getPublicKeyPacket() |
Iterator |
getRawUserIDs()
Return any userIDs associated with the key in raw byte form.
|
Iterator |
getSignatures()
Return all signatures/certifications associated with this key.
|
Iterator<PGPSignature> |
getSignaturesForID(byte[] rawID)
Return any signatures associated with the passed in id.
|
Iterator<PGPSignature> |
getSignaturesForID(String id)
Return any signatures associated with the passed in id.
|
Iterator<PGPSignature> |
getSignaturesForKeyID(long keyID)
Return any signatures associated with the passed in key identifier keyID.
|
Iterator |
getSignaturesForUserAttribute(PGPUserAttributeSubpacketVector userAttributes)
Return an iterator of signatures associated with the passed in user attributes.
|
Iterator |
getSignaturesOfType(int signatureType)
Return signatures of the passed in type that are on this key.
|
byte[] |
getTrustData()
Return the trust data associated with the public key, if present.
|
Iterator |
getUserAttributes()
Return any user attribute vectors associated with the key.
|
Iterator |
getUserIDs()
Return any userIDs associated with the key.
|
int |
getValidDays()
Deprecated.
use getValidSeconds(): greater than version 3 keys may be valid for less than a day.
|
long |
getValidSeconds() |
int |
getVersion() |
boolean |
hasRevocation()
Check whether this (sub)key has a revocation signature on it.
|
boolean |
isEncryptionKey()
Return true if this key has an algorithm type that makes it suitable to use for encryption.
|
boolean |
isMasterKey()
Return true if this is a master key.
|
boolean |
isRevoked()
Deprecated.
this method is poorly named, use hasRevocation().
|
static PGPPublicKey |
removeCertification(PGPPublicKey key,
byte[] rawID)
Remove any certifications associated with a given id on a key.
|
static PGPPublicKey |
removeCertification(PGPPublicKey key,
byte[] id,
PGPSignature certification)
Remove a certification associated with a given id on a key.
|
static PGPPublicKey |
removeCertification(PGPPublicKey key,
PGPSignature certification)
Remove a certification from the key.
|
static PGPPublicKey |
removeCertification(PGPPublicKey key,
PGPUserAttributeSubpacketVector userAttributes)
Remove any certifications associated with a given user attribute subpacket
on a key.
|
static PGPPublicKey |
removeCertification(PGPPublicKey key,
PGPUserAttributeSubpacketVector userAttributes,
PGPSignature certification)
Remove a certification associated with a given user attributes on a key.
|
static PGPPublicKey |
removeCertification(PGPPublicKey key,
String id)
Remove any certifications associated with a given id on a key.
|
static PGPPublicKey |
removeCertification(PGPPublicKey key,
String id,
PGPSignature certification)
Remove a certification associated with a given id on a key.
|
public PGPPublicKey(PublicKeyPacket publicKeyPacket, KeyFingerPrintCalculator fingerPrintCalculator) throws PGPException
publicKeyPacket
- packet describing the public key.fingerPrintCalculator
- calculator providing the digest support ot create the key fingerprint.PGPException
- if the packet is faulty, or the required calculations fail.public int getVersion()
public Date getCreationTime()
public int getValidDays()
public byte[] getTrustData()
public long getValidSeconds()
public long getKeyID()
public byte[] getFingerprint()
public boolean isEncryptionKey()
Note: with version 4 keys KeyFlags subpackets should also be considered when present for determining the preferred use of the key.
public boolean isMasterKey()
public int getAlgorithm()
public int getBitStrength()
public Iterator getUserIDs()
public Iterator getRawUserIDs()
public Iterator getUserAttributes()
public Iterator<PGPSignature> getSignaturesForID(String id)
id
- the id to be matched.public Iterator<PGPSignature> getSignaturesForID(byte[] rawID)
rawID
- the id to be matched in raw byte form.public Iterator<PGPSignature> getSignaturesForKeyID(long keyID)
keyID
- the key id to be matched.public Iterator getSignaturesForUserAttribute(PGPUserAttributeSubpacketVector userAttributes)
userAttributes
- the vector of user attributes to be matched.public Iterator getSignaturesOfType(int signatureType)
signatureType
- the type of the signature to be returned.public Iterator getSignatures()
public Iterator getKeySignatures()
public PublicKeyPacket getPublicKeyPacket()
public byte[] getEncoded() throws IOException
IOException
public byte[] getEncoded(boolean forTransfer) throws IOException
forTransfer
- if the purpose of encoding is to send key to other users.IOException
- in case of encoding error.public void encode(OutputStream outStream) throws IOException
IOException
public void encode(OutputStream outStream, boolean forTransfer) throws IOException
outStream
- stream to write the key encoding to.forTransfer
- if the purpose of encoding is to send key to other users.IOException
- in case of encoding error.public boolean isRevoked()
public boolean hasRevocation()
public static PGPPublicKey addCertification(PGPPublicKey key, byte[] rawID, PGPSignature certification)
key
- the key the certification is to be added to.rawID
- the raw bytes making up the user id..certification
- the new certification.public static PGPPublicKey addCertification(PGPPublicKey key, String id, PGPSignature certification)
key
- the key the certification is to be added to.id
- the id the certification is associated with.certification
- the new certification.public static PGPPublicKey addCertification(PGPPublicKey key, PGPUserAttributeSubpacketVector userAttributes, PGPSignature certification)
key
- the key the certification is to be added to.userAttributes
- the attributes the certification is associated with.certification
- the new certification.public static PGPPublicKey removeCertification(PGPPublicKey key, PGPUserAttributeSubpacketVector userAttributes)
key
- the key the certifications are to be removed from.userAttributes
- the attributes to be removed.public static PGPPublicKey removeCertification(PGPPublicKey key, String id)
key
- the key the certifications are to be removed from.id
- the id that is to be removed.public static PGPPublicKey removeCertification(PGPPublicKey key, byte[] rawID)
key
- the key the certifications are to be removed from.rawID
- the id that is to be removed in raw byte form.public static PGPPublicKey removeCertification(PGPPublicKey key, byte[] id, PGPSignature certification)
key
- the key the certifications are to be removed from.id
- the id that the certification is to be removed from (in its raw byte form)certification
- the certification to be removed.public static PGPPublicKey removeCertification(PGPPublicKey key, String id, PGPSignature certification)
key
- the key the certifications are to be removed from.id
- the id that the certification is to be removed from.certification
- the certification to be removed.public static PGPPublicKey removeCertification(PGPPublicKey key, PGPUserAttributeSubpacketVector userAttributes, PGPSignature certification)
key
- the key the certifications are to be removed from.userAttributes
- the user attributes that the certification is to be removed from.certification
- the certification to be removed.public static PGPPublicKey addCertification(PGPPublicKey key, PGPSignature certification)
key
- the key the revocation is to be added to.certification
- the key signature to be added.public static PGPPublicKey removeCertification(PGPPublicKey key, PGPSignature certification)
key
- the key the certifications are to be removed from.certification
- the certification to be removed.Copyright © 2018 BouncyCastle.org. All rights reserved.