Package org.pgpainless.signature.consumer

# 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 (see `SignatureValidator`), as well as cryptographic verification of signature correctness.

## Method Summary

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 given `InputStream`.
`static boolean`
`verifyDirectKeySignature(org.bouncycastle.openpgp.PGPSignature signature, org.bouncycastle.openpgp.PGPPublicKey signingKey, org.bouncycastle.openpgp.PGPPublicKey signedKey, Policy policy, Date referenceDate)`
Verify a direct-key signature.
`static boolean`
`verifyDirectKeySignature(org.bouncycastle.openpgp.PGPSignature signature, org.bouncycastle.openpgp.PGPPublicKey primaryKey, Policy policy, Date referenceDate)`
Verify a direct-key self-signature.
`static boolean`
`verifyInitializedSignature(org.bouncycastle.openpgp.PGPSignature signature, org.bouncycastle.openpgp.PGPPublicKey signingKey, Policy policy, Date referenceDate)`
Verify an initialized signature.
`static boolean`
`verifyKeyRevocationSignature(org.bouncycastle.openpgp.PGPSignature signature, org.bouncycastle.openpgp.PGPPublicKey primaryKey, Policy policy, Date referenceDate)`
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 referenceDate)`
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 referenceDate)`
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 referenceDate)`
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 referenceDate)`
Verify a subkey binding signature.
`static boolean`
`verifyUninitializedSignature(org.bouncycastle.openpgp.PGPSignature signature, InputStream signedData, org.bouncycastle.openpgp.PGPPublicKey signingKey, Policy policy, Date referenceDate)`
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 referenceDate)`
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 referenceDate)`
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 referenceDate)`
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 referenceDate)`
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 referenceDate)`
Verify a user-id certification.
`static boolean`
`verifyUserIdCertification(String userId, org.bouncycastle.openpgp.PGPSignature signature, org.bouncycastle.openpgp.PGPPublicKey primaryKey, Policy policy, Date referenceDate)`
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 referenceDate)`
Verify a user-id revocation signature.
`static boolean`
`verifyUserIdRevocation(String userId, org.bouncycastle.openpgp.PGPSignature signature, org.bouncycastle.openpgp.PGPPublicKey primaryKey, Policy policy, Date referenceDate)`
Verify a user-id revocation self-signature.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Method Details

### 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 referenceDate) throws SignatureValidationException
Verify a signature (certification or revocation) over a user-id.

Parameters:
  `userId` - user-id
  `signature` - certification signature
  `signingKey` - key that created the certification
  `keyWithUserId` - key carrying the user-id
  `policy` - policy
  `referenceDate` - 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 referenceDate) throws SignatureValidationException
Verify a certification self-signature over a user-id.

Parameters:
  `userId` - user-id
  `signature` - certification signature
  `primaryKey` - primary key
  `policy` - policy
  `referenceDate` - 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 referenceDate) throws SignatureValidationException
Verify a user-id certification.

Parameters:
  `userId` - user-id
  `signature` - certification signature
  `signingKey` - key that created the certification
  `keyWithUserId` - primary key that carries the user-id
  `policy` - policy
  `referenceDate` - 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 referenceDate) throws SignatureValidationException
Verify a user-id revocation self-signature.

Parameters:
  `userId` - user-id
  `signature` - user-id revocation signature
  `primaryKey` - primary key
  `policy` - policy
  `referenceDate` - 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 referenceDate) throws SignatureValidationException
Verify a user-id revocation signature.

Parameters:
  `userId` - user-id
  `signature` - revocation signature
  `signingKey` - key that created the revocation signature
  `keyWithUserId` - primary key carrying the user-id
  `policy` - policy
  `referenceDate` - 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 referenceDate) throws SignatureValidationException
Verify a certification self-signature over a user-attributes packet.

Parameters:
  `userAttributes` - user attributes
  `signature` - certification self-signature
  `primaryKey` - primary key that carries the user-attributes
  `policy` - policy
  `referenceDate` - 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 referenceDate) throws SignatureValidationException
Verify a certification signature over a user-attributes packet.

Parameters:
  `userAttributes` - user attributes
  `signature` - certification signature
  `signingKey` - key that created the user-attributes certification
  `keyWithUserAttributes` - key that carries the user-attributes certification
  `policy` - policy
  `referenceDate` - 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 referenceDate) throws SignatureValidationException
Verify a user-attributes revocation self-signature.

Parameters:
  `userAttributes` - user-attributes
  `signature` - user-attributes revocation signature
  `primaryKey` - primary key that carries the user-attributes
  `policy` - policy
  `referenceDate` - 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 referenceDate) throws SignatureValidationException
Verify a user-attributes revocation signature.

Parameters:
  `userAttributes` - user-attributes
  `signature` - revocation signature
  `signingKey` - revocation key
  `keyWithUserAttributes` - key that carries the user-attributes
  `policy` - policy
  `referenceDate` - 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 referenceDate) throws SignatureValidationException
Verify a subkey binding signature.

Parameters:
  `signature` - binding signature
  `primaryKey` - primary key
  `subkey` - subkey
  `policy` - policy
  `referenceDate` - 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 referenceDate) throws SignatureValidationException
Verify a subkey revocation signature.

Parameters:
  `signature` - subkey revocation signature
  `primaryKey` - primary key
  `subkey` - subkey
  `policy` - policy
  `referenceDate` - 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 referenceDate) throws SignatureValidationException
Verify a direct-key self-signature.

Parameters:
  `signature` - signature
  `primaryKey` - primary key
  `policy` - policy
  `referenceDate` - 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 referenceDate) throws SignatureValidationException
Verify a direct-key signature.

Parameters:
  `signature` - signature
  `signingKey` - signing key
  `signedKey` - signed key
  `policy` - policy
  `referenceDate` - 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 referenceDate) throws SignatureValidationException
Verify a key revocation signature.

Parameters:
  `signature` - signature
  `primaryKey` - primary key
  `policy` - policy
  `referenceDate` - 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 referenceDate) throws SignatureValidationException
Initialize a signature and verify it afterwards by updating it with the signed data.

Parameters:
  `signature` - OpenPGP signature
  `signedData` - input stream containing the signed data
  `signingKey` - the key that created the signature
  `policy` - policy
  `referenceDate` - 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 given `InputStream`.

Parameters:
  `signature` - OpenPGP signature
  `signedData` - input stream containing signed data
  `signingKey` - 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 referenceDate) throws SignatureValidationException
Verify an initialized signature. An initialized signature was already updated with the signed data.

Parameters:
  `signature` - OpenPGP signature
  `signingKey` - key that created the signature
  `policy` - policy
  `referenceDate` - 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 referenceDate) throws SignatureValidationException
Verify a signature (certification or revocation) over a user-id.

Parameters:
  `userId` - user-id
  `signature` - self-signature
  `primaryKey` - primary key that created the signature
  `policy` - policy
  `referenceDate` - reference date for signature verification
Returns:
  true if the signature is successfully verified
Throws:
  `SignatureValidationException` - if signature verification fails for some reason