private void initVerify(PGPSignature pgpSignature, PGPPublicKey pgpSigningKey)
     throws PGPException, NoSuchProviderException {
   try {
     pgpSignature.initVerify(pgpSigningKey, "BC");
   } catch (NoSuchProviderException e) {
     LOGGER.debug(
         "No security provider found. Adding bouncy castle. This message can be ignored", e);
     Security.addProvider(new BouncyCastleProvider());
     pgpSignature.initVerify(pgpSigningKey, "BC");
   }
 }
Example #2
0
 /**
  * Verify this signature for a {@link SubKey} signed by a {@link MasterKey}.
  *
  * @param key a subkey
  * @param masterKey the signing master key
  * @return {@code true} if the signature is valid, {@code false} otherwise
  */
 public boolean verifyCertification(SubKey key, MasterKey masterKey) {
   try {
     signature.initVerify(masterKey.getPublicKey(), "BC");
     return signature.verifyCertification(masterKey.getPublicKey(), key.getPublicKey());
   } catch (Exception e) {
     return false;
   }
 }
Example #3
0
 /**
  * Verify this signature for a self-signed {@link MasterKey}.
  *
  * @param key a self-signed master key
  * @return {@code true} if the signature is valid, {@code false} otherwise
  */
 public boolean verifyCertification(MasterKey key) {
   try {
     signature.initVerify(key.getPublicKey(), "BC");
     return signature.verifyCertification(key.getUserID(), key.getPublicKey());
   } catch (PGPException e) {
     return false;
   } catch (SignatureException e) {
     return false;
   } catch (Exception e) {
     throw new RuntimeException(e);
   }
 }