|
Bouncy Castle Cryptography Library 1.81 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.bouncycastle.openpgp.PGPPublicKey
general class to handle a PGP public key object.
Field Summary |
Fields inherited from interface org.bouncycastle.bcpg.PublicKeyAlgorithmTags |
AEDH, AEDSA, DIFFIE_HELLMAN, DSA, EC, ECDH, ECDSA, Ed25519, Ed448, EDDSA, EDDSA_LEGACY, 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, X25519, X448 |
Constructor Summary | |
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. |
Method Summary | |
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,
java.lang.String id,
PGPSignature certification)
Add a certification for an id to the given public key. |
void |
encode(java.io.OutputStream outStream)
|
void |
encode(java.io.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. |
java.util.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 public key. |
long |
getKeyID()
Return the keyID associated with the public key. |
KeyIdentifier |
getKeyIdentifier()
Return a KeyIdentifier identifying this key. |
java.util.Iterator |
getKeySignatures()
Return all signatures/certifications directly associated with this key (ie, not to a user id). |
PublicKeyPacket |
getPublicKeyPacket()
|
java.util.Iterator |
getRawUserIDs()
Return any userIDs associated with the key in raw byte form. |
java.util.Iterator |
getSignatures()
Return all signatures/certifications associated with this key. |
java.util.Iterator |
getSignaturesForID(byte[] rawID)
Return any signatures associated with the passed in id. |
java.util.Iterator |
getSignaturesForID(java.lang.String id)
Return any signatures associated with the passed in id. |
java.util.Iterator |
getSignaturesForKey(KeyIdentifier identifier)
|
java.util.Iterator |
getSignaturesForKeyID(long keyID)
Return any signatures associated with the passed in key identifier keyID. |
java.util.Iterator |
getSignaturesForUserAttribute(PGPUserAttributeSubpacketVector userAttributes)
Return an iterator of signatures associated with the passed in user attributes. |
java.util.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. |
java.util.Iterator |
getUserAttributes()
Return any user attribute vectors associated with the key. |
java.util.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 |
hasFingerprint(byte[] fingerprint)
|
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 could be a master key. |
boolean |
isRevoked()
Deprecated. this method is poorly named, use hasRevocation(). |
static PGPPublicKey |
join(PGPPublicKey key,
PGPPublicKey copy,
boolean joinTrustPackets,
boolean allowSubkeySigsOnNonSubkey)
Merge this the given local public key with another, potentially fresher copy. |
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,
java.lang.String id)
Remove any certifications associated with a given id on a key. |
static PGPPublicKey |
removeCertification(PGPPublicKey key,
java.lang.String id,
PGPSignature certification)
Remove a certification associated with a given id on a key. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
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.Method Detail |
public int getVersion()
public java.util.Date getCreationTime()
public int getValidDays()
public byte[] getTrustData()
public long getValidSeconds()
public long getKeyID()
public KeyIdentifier getKeyIdentifier()
KeyIdentifier
identifying this key.
public byte[] getFingerprint()
public boolean hasFingerprint(byte[] fingerprint)
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 java.util.Iterator getUserIDs()
public java.util.Iterator getRawUserIDs()
public java.util.Iterator getUserAttributes()
public java.util.Iterator getSignaturesForID(java.lang.String id)
id
- the id to be matched.
public java.util.Iterator getSignaturesForID(byte[] rawID)
rawID
- the id to be matched in raw byte form.
public java.util.Iterator getSignaturesForKeyID(long keyID)
keyID
- the key id to be matched.
public java.util.Iterator getSignaturesForKey(KeyIdentifier identifier)
public java.util.Iterator getSignaturesForUserAttribute(PGPUserAttributeSubpacketVector userAttributes)
userAttributes
- the vector of user attributes to be matched.
public java.util.Iterator getSignaturesOfType(int signatureType)
signatureType
- the type of the signature to be returned.
public java.util.Iterator getSignatures()
public java.util.Iterator getKeySignatures()
public PublicKeyPacket getPublicKeyPacket()
public byte[] getEncoded() throws java.io.IOException
java.io.IOException
public byte[] getEncoded(boolean forTransfer) throws java.io.IOException
forTransfer
- if the purpose of encoding is to send key to other users.
java.io.IOException
- in case of encoding error.public void encode(java.io.OutputStream outStream) throws java.io.IOException
java.io.IOException
public void encode(java.io.OutputStream outStream, boolean forTransfer) throws java.io.IOException
outStream
- stream to write the key encoding to.forTransfer
- if the purpose of encoding is to send key to other users.
java.io.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, java.lang.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, java.lang.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, java.lang.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.
public static PGPPublicKey join(PGPPublicKey key, PGPPublicKey copy, boolean joinTrustPackets, boolean allowSubkeySigsOnNonSubkey) throws PGPException
PGPPublicKey
contains the sum of both keys user-ids and signatures.
If joinTrustPackets is set to true and the copy carries a trust packet, the joined key will copy the trust-packet from the copy. Otherwise, it will carry the trust packet of the local key.
key
- local public keycopy
- copy of the public key (e.g. from a key server)joinTrustPackets
- if true, trust packets from the copy are copied over into the resulting keyallowSubkeySigsOnNonSubkey
- if true, subkey signatures on the copy will be present in the merged key, even if key was not a subkey before.
PGPException
|
Bouncy Castle Cryptography Library 1.81 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |