/** * Looks up an {@link EmailIdentity} that has the same public encryption key and the * same public signing key as a given {@link EmailDestination}.<br/> * Returns <code>null</code> if nothing is found. * @param destination * @throws PasswordException * @throws GeneralSecurityException * @throws IOException */ public EmailIdentity get(EmailDestination destination) throws PasswordException, IOException, GeneralSecurityException { initializeIfNeeded(); if (identities == null) return null; for (EmailIdentity identity: identities) if (identity.getPublicEncryptionKey().equals(destination.getPublicEncryptionKey()) && identity.getPublicSigningKey().equals(destination.getPublicSigningKey())) return identity; return null; }
/** * Verifies the signature and the fingerprint. * @return * @throws GeneralSecurityException */ public boolean verify() throws GeneralSecurityException { if (signature==null || fingerprint==null) return false; CryptoImplementation cryptoImpl = destination.getCryptoImpl(); PublicKey key = destination.getPublicSigningKey(); boolean valid = cryptoImpl.verify(getDataToSign(), signature, key); valid &= fingerprint.isValid(); return valid; }
return cryptoImpl.verify(toByteArray(), signature, senderDestination.getPublicSigningKey()); } catch (Exception e) { log.error("Cannot verify email signature. Email: [" + this + "]", e);