Class SignatureVerifier
- java.lang.Object
-
- org.pgpainless.signature.consumer.SignatureVerifier
-
public final class SignatureVerifier extends Object
Collection of static methods for signature verification. Signature verification entails validation of certain criteria (seeSignatureValidator
), as well as cryptographic verification of signature correctness.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
initializeSignatureAndUpdateWithSignedData(org.bouncycastle.openpgp.PGPSignature signature, InputStream signedData, org.bouncycastle.openpgp.PGPPublicKey signingKey)
Initialize a signature and then update it with the signed data from the givenInputStream
.static boolean
verifyDirectKeySignature(org.bouncycastle.openpgp.PGPSignature signature, org.bouncycastle.openpgp.PGPPublicKey signingKey, org.bouncycastle.openpgp.PGPPublicKey signedKey, Policy policy, Date validationDate)
Verify a direct-key signature.static boolean
verifyDirectKeySignature(org.bouncycastle.openpgp.PGPSignature signature, org.bouncycastle.openpgp.PGPPublicKey primaryKey, Policy policy, Date validationDate)
Verify a direct-key self-signature.static boolean
verifyInitializedSignature(org.bouncycastle.openpgp.PGPSignature signature, org.bouncycastle.openpgp.PGPPublicKey signingKey, Policy policy, Date validationDate)
Verify an initialized signature.static boolean
verifyKeyRevocationSignature(org.bouncycastle.openpgp.PGPSignature signature, org.bouncycastle.openpgp.PGPPublicKey primaryKey, Policy policy, Date validationDate)
Verify a key revocation signature.static boolean
verifyOnePassSignature(org.bouncycastle.openpgp.PGPSignature signature, org.bouncycastle.openpgp.PGPPublicKey signingKey, OnePassSignatureCheck onePassSignature, Policy policy)
static boolean
verifySignatureOverUserId(String userId, org.bouncycastle.openpgp.PGPSignature signature, org.bouncycastle.openpgp.PGPPublicKey signingKey, org.bouncycastle.openpgp.PGPPublicKey keyWithUserId, Policy policy, Date validationDate)
Verify a signature (certification or revocation) over a user-id.static boolean
verifySignatureOverUserId(String userId, org.bouncycastle.openpgp.PGPSignature signature, org.bouncycastle.openpgp.PGPPublicKey primaryKey, Policy policy, Date validationDate)
Verify a signature (certification or revocation) over a user-id.static boolean
verifySubkeyBindingRevocation(org.bouncycastle.openpgp.PGPSignature signature, org.bouncycastle.openpgp.PGPPublicKey primaryKey, org.bouncycastle.openpgp.PGPPublicKey subkey, Policy policy, Date validationDate)
Verify a subkey revocation signature.static boolean
verifySubkeyBindingSignature(org.bouncycastle.openpgp.PGPSignature signature, org.bouncycastle.openpgp.PGPPublicKey primaryKey, org.bouncycastle.openpgp.PGPPublicKey subkey, Policy policy, Date validationDate)
Verify a subkey binding signature.static boolean
verifyUninitializedSignature(org.bouncycastle.openpgp.PGPSignature signature, InputStream signedData, org.bouncycastle.openpgp.PGPPublicKey signingKey, Policy policy, Date validationDate)
Initialize a signature and verify it afterwards by updating it with the signed data.static boolean
verifyUserAttributesCertification(org.bouncycastle.openpgp.PGPUserAttributeSubpacketVector userAttributes, org.bouncycastle.openpgp.PGPSignature signature, org.bouncycastle.openpgp.PGPPublicKey signingKey, org.bouncycastle.openpgp.PGPPublicKey keyWithUserAttributes, Policy policy, Date validationDate)
Verify a certification signature over a user-attributes packet.static boolean
verifyUserAttributesCertification(org.bouncycastle.openpgp.PGPUserAttributeSubpacketVector userAttributes, org.bouncycastle.openpgp.PGPSignature signature, org.bouncycastle.openpgp.PGPPublicKey primaryKey, Policy policy, Date validationDate)
Verify a certification self-signature over a user-attributes packet.static boolean
verifyUserAttributesRevocation(org.bouncycastle.openpgp.PGPUserAttributeSubpacketVector userAttributes, org.bouncycastle.openpgp.PGPSignature signature, org.bouncycastle.openpgp.PGPPublicKey signingKey, org.bouncycastle.openpgp.PGPPublicKey keyWithUserAttributes, Policy policy, Date validationDate)
Verify a user-attributes revocation signature.static boolean
verifyUserAttributesRevocation(org.bouncycastle.openpgp.PGPUserAttributeSubpacketVector userAttributes, org.bouncycastle.openpgp.PGPSignature signature, org.bouncycastle.openpgp.PGPPublicKey primaryKey, Policy policy, Date validationDate)
Verify a user-attributes revocation self-signature.static boolean
verifyUserIdCertification(String userId, org.bouncycastle.openpgp.PGPSignature signature, org.bouncycastle.openpgp.PGPPublicKey signingKey, org.bouncycastle.openpgp.PGPPublicKey keyWithUserId, Policy policy, Date validationDate)
Verify a user-id certification.static boolean
verifyUserIdCertification(String userId, org.bouncycastle.openpgp.PGPSignature signature, org.bouncycastle.openpgp.PGPPublicKey primaryKey, Policy policy, Date validationDate)
Verify a certification self-signature over a user-id.static boolean
verifyUserIdRevocation(String userId, org.bouncycastle.openpgp.PGPSignature signature, org.bouncycastle.openpgp.PGPPublicKey signingKey, org.bouncycastle.openpgp.PGPPublicKey keyWithUserId, Policy policy, Date validationDate)
Verify a user-id revocation signature.static boolean
verifyUserIdRevocation(String userId, org.bouncycastle.openpgp.PGPSignature signature, org.bouncycastle.openpgp.PGPPublicKey primaryKey, Policy policy, Date validationDate)
Verify a user-id revocation self-signature.
-
-
-
Method Detail
-
verifySignatureOverUserId
public static boolean verifySignatureOverUserId(String userId, org.bouncycastle.openpgp.PGPSignature signature, org.bouncycastle.openpgp.PGPPublicKey signingKey, org.bouncycastle.openpgp.PGPPublicKey keyWithUserId, Policy policy, Date validationDate) throws SignatureValidationException
Verify a signature (certification or revocation) over a user-id.- Parameters:
userId
- user-idsignature
- certification signaturesigningKey
- key that created the certificationkeyWithUserId
- key carrying the user-idpolicy
- policyvalidationDate
- reference date for signature verification- Returns:
- true if signature verification is successful
- Throws:
SignatureValidationException
- if signature verification fails for some reason
-
verifyUserIdCertification
public static boolean verifyUserIdCertification(String userId, org.bouncycastle.openpgp.PGPSignature signature, org.bouncycastle.openpgp.PGPPublicKey primaryKey, Policy policy, Date validationDate) throws SignatureValidationException
Verify a certification self-signature over a user-id.- Parameters:
userId
- user-idsignature
- certification signatureprimaryKey
- primary keypolicy
- policyvalidationDate
- reference date for signature verification- Returns:
- true if the self-signature is verified successfully
- Throws:
SignatureValidationException
- if signature verification fails for some reason
-
verifyUserIdCertification
public static boolean verifyUserIdCertification(String userId, org.bouncycastle.openpgp.PGPSignature signature, org.bouncycastle.openpgp.PGPPublicKey signingKey, org.bouncycastle.openpgp.PGPPublicKey keyWithUserId, Policy policy, Date validationDate) throws SignatureValidationException
Verify a user-id certification.- Parameters:
userId
- user-idsignature
- certification signaturesigningKey
- key that created the certificationkeyWithUserId
- primary key that carries the user-idpolicy
- policyvalidationDate
- reference date for signature verification- Returns:
- true if signature verification is successful
- Throws:
SignatureValidationException
- if signature verification fails for some reason
-
verifyUserIdRevocation
public static boolean verifyUserIdRevocation(String userId, org.bouncycastle.openpgp.PGPSignature signature, org.bouncycastle.openpgp.PGPPublicKey primaryKey, Policy policy, Date validationDate) throws SignatureValidationException
Verify a user-id revocation self-signature.- Parameters:
userId
- user-idsignature
- user-id revocation signatureprimaryKey
- primary keypolicy
- policyvalidationDate
- reference date for signature verification- Returns:
- true if the user-id revocation signature is successfully verified
- Throws:
SignatureValidationException
- if signature verification fails for some reason
-
verifyUserIdRevocation
public static boolean verifyUserIdRevocation(String userId, org.bouncycastle.openpgp.PGPSignature signature, org.bouncycastle.openpgp.PGPPublicKey signingKey, org.bouncycastle.openpgp.PGPPublicKey keyWithUserId, Policy policy, Date validationDate) throws SignatureValidationException
Verify a user-id revocation signature.- Parameters:
userId
- user-idsignature
- revocation signaturesigningKey
- key that created the revocation signaturekeyWithUserId
- primary key carrying the user-idpolicy
- policyvalidationDate
- reference date for signature verification- Returns:
- true if the user-id revocation signature is successfully verified
- Throws:
SignatureValidationException
- if signature verification fails for some reason
-
verifyUserAttributesCertification
public static boolean verifyUserAttributesCertification(org.bouncycastle.openpgp.PGPUserAttributeSubpacketVector userAttributes, org.bouncycastle.openpgp.PGPSignature signature, org.bouncycastle.openpgp.PGPPublicKey primaryKey, Policy policy, Date validationDate) throws SignatureValidationException
Verify a certification self-signature over a user-attributes packet.- Parameters:
userAttributes
- user attributessignature
- certification self-signatureprimaryKey
- primary key that carries the user-attributespolicy
- policyvalidationDate
- reference date for signature verification- Returns:
- true if the signature can be verified successfully
- Throws:
SignatureValidationException
- if signature verification fails for some reason
-
verifyUserAttributesCertification
public static boolean verifyUserAttributesCertification(org.bouncycastle.openpgp.PGPUserAttributeSubpacketVector userAttributes, org.bouncycastle.openpgp.PGPSignature signature, org.bouncycastle.openpgp.PGPPublicKey signingKey, org.bouncycastle.openpgp.PGPPublicKey keyWithUserAttributes, Policy policy, Date validationDate) throws SignatureValidationException
Verify a certification signature over a user-attributes packet.- Parameters:
userAttributes
- user attributessignature
- certification signaturesigningKey
- key that created the user-attributes certificationkeyWithUserAttributes
- key that carries the user-attributes certificationpolicy
- policyvalidationDate
- reference date for signature verification- Returns:
- true if the signature can be verified successfully
- Throws:
SignatureValidationException
- if signature verification fails for some reason
-
verifyUserAttributesRevocation
public static boolean verifyUserAttributesRevocation(org.bouncycastle.openpgp.PGPUserAttributeSubpacketVector userAttributes, org.bouncycastle.openpgp.PGPSignature signature, org.bouncycastle.openpgp.PGPPublicKey primaryKey, Policy policy, Date validationDate) throws SignatureValidationException
Verify a user-attributes revocation self-signature.- Parameters:
userAttributes
- user-attributessignature
- user-attributes revocation signatureprimaryKey
- primary key that carries the user-attributespolicy
- policyvalidationDate
- reference date for signature verification- Returns:
- true if the revocation signature can be verified successfully
- Throws:
SignatureValidationException
- if signature verification fails for some reason
-
verifyUserAttributesRevocation
public static boolean verifyUserAttributesRevocation(org.bouncycastle.openpgp.PGPUserAttributeSubpacketVector userAttributes, org.bouncycastle.openpgp.PGPSignature signature, org.bouncycastle.openpgp.PGPPublicKey signingKey, org.bouncycastle.openpgp.PGPPublicKey keyWithUserAttributes, Policy policy, Date validationDate) throws SignatureValidationException
Verify a user-attributes revocation signature.- Parameters:
userAttributes
- user-attributessignature
- revocation signaturesigningKey
- revocation keykeyWithUserAttributes
- key that carries the user-attributespolicy
- policyvalidationDate
- reference date for signature verification- Returns:
- true if the revocation signature can be verified successfully
- Throws:
SignatureValidationException
- if signature verification fails for some reason
-
verifySubkeyBindingSignature
public static boolean verifySubkeyBindingSignature(org.bouncycastle.openpgp.PGPSignature signature, org.bouncycastle.openpgp.PGPPublicKey primaryKey, org.bouncycastle.openpgp.PGPPublicKey subkey, Policy policy, Date validationDate) throws SignatureValidationException
Verify a subkey binding signature.- Parameters:
signature
- binding signatureprimaryKey
- primary keysubkey
- subkeypolicy
- policyvalidationDate
- reference date for signature verification- Returns:
- true if the binding signature can be verified successfully
- Throws:
SignatureValidationException
- if signature verification fails for some reason
-
verifySubkeyBindingRevocation
public static boolean verifySubkeyBindingRevocation(org.bouncycastle.openpgp.PGPSignature signature, org.bouncycastle.openpgp.PGPPublicKey primaryKey, org.bouncycastle.openpgp.PGPPublicKey subkey, Policy policy, Date validationDate) throws SignatureValidationException
Verify a subkey revocation signature.- Parameters:
signature
- subkey revocation signatureprimaryKey
- primary keysubkey
- subkeypolicy
- policyvalidationDate
- reference date for signature verification- Returns:
- true if the subkey revocation signature can be verified successfully
- Throws:
SignatureValidationException
- if signature verification fails for some reason
-
verifyDirectKeySignature
public static boolean verifyDirectKeySignature(org.bouncycastle.openpgp.PGPSignature signature, org.bouncycastle.openpgp.PGPPublicKey primaryKey, Policy policy, Date validationDate) throws SignatureValidationException
Verify a direct-key self-signature.- Parameters:
signature
- signatureprimaryKey
- primary keypolicy
- policyvalidationDate
- reference date for signature verification- Returns:
- true if the signature can be verified successfully
- Throws:
SignatureValidationException
- if signature verification fails for some reason
-
verifyDirectKeySignature
public static boolean verifyDirectKeySignature(org.bouncycastle.openpgp.PGPSignature signature, org.bouncycastle.openpgp.PGPPublicKey signingKey, org.bouncycastle.openpgp.PGPPublicKey signedKey, Policy policy, Date validationDate) throws SignatureValidationException
Verify a direct-key signature.- Parameters:
signature
- signaturesigningKey
- signing keysignedKey
- signed keypolicy
- policyvalidationDate
- reference date for signature verification- Returns:
- true if signature verification is successful
- Throws:
SignatureValidationException
- if signature verification fails for some reason
-
verifyKeyRevocationSignature
public static boolean verifyKeyRevocationSignature(org.bouncycastle.openpgp.PGPSignature signature, org.bouncycastle.openpgp.PGPPublicKey primaryKey, Policy policy, Date validationDate) throws SignatureValidationException
Verify a key revocation signature.- Parameters:
signature
- signatureprimaryKey
- primary keypolicy
- policyvalidationDate
- reference date for signature verification- Returns:
- true if signature verification is successful
- Throws:
SignatureValidationException
- if signature verification fails for some reason
-
verifyUninitializedSignature
public static boolean verifyUninitializedSignature(org.bouncycastle.openpgp.PGPSignature signature, InputStream signedData, org.bouncycastle.openpgp.PGPPublicKey signingKey, Policy policy, Date validationDate) throws SignatureValidationException
Initialize a signature and verify it afterwards by updating it with the signed data.- Parameters:
signature
- OpenPGP signaturesignedData
- input stream containing the signed datasigningKey
- the key that created the signaturepolicy
- policyvalidationDate
- reference date of signature verification- Returns:
- true if the signature is successfully verified
- Throws:
SignatureValidationException
- if the signature verification fails for some reason
-
initializeSignatureAndUpdateWithSignedData
public static void initializeSignatureAndUpdateWithSignedData(org.bouncycastle.openpgp.PGPSignature signature, InputStream signedData, org.bouncycastle.openpgp.PGPPublicKey signingKey) throws SignatureValidationException
Initialize a signature and then update it with the signed data from the givenInputStream
.- Parameters:
signature
- OpenPGP signaturesignedData
- input stream containing signed datasigningKey
- key that created the signature- Throws:
SignatureValidationException
- in case the signature cannot be verified for some reason
-
verifyInitializedSignature
public static boolean verifyInitializedSignature(org.bouncycastle.openpgp.PGPSignature signature, org.bouncycastle.openpgp.PGPPublicKey signingKey, Policy policy, Date validationDate) throws SignatureValidationException
Verify an initialized signature. An initialized signature was already updated with the signed data.- Parameters:
signature
- OpenPGP signaturesigningKey
- key that created the signaturepolicy
- policyvalidationDate
- reference date for signature verification- Returns:
- true if signature is verified successfully
- Throws:
SignatureValidationException
- if signature verification fails for some reason
-
verifyOnePassSignature
public static boolean verifyOnePassSignature(org.bouncycastle.openpgp.PGPSignature signature, org.bouncycastle.openpgp.PGPPublicKey signingKey, OnePassSignatureCheck onePassSignature, Policy policy) throws SignatureValidationException
- Throws:
SignatureValidationException
-
verifySignatureOverUserId
public static boolean verifySignatureOverUserId(String userId, org.bouncycastle.openpgp.PGPSignature signature, org.bouncycastle.openpgp.PGPPublicKey primaryKey, Policy policy, Date validationDate) throws SignatureValidationException
Verify a signature (certification or revocation) over a user-id.- Parameters:
userId
- user-idsignature
- self-signatureprimaryKey
- primary key that created the signaturepolicy
- policyvalidationDate
- reference date for signature verification- Returns:
- true if the signature is successfully verified
- Throws:
SignatureValidationException
- if signature verification fails for some reason
-
-