/** Verifies a signature with the data and a PublicKey * * @param signed the original data * @param signature the signature to be verified * @param publicKey the PublicKey that is alleged to have signed it * * @returns boolean true or false */ static boolean verify(byte[] signed, byte[] signature, PublicKey publicKey){ System.out.println("Verifying " + signed.length + "bytes"); try { Signature signer = Signature.getInstance("SHA1withRSA"); signer.initVerify(publicKey); signer.update(signed); boolean verified = signer.verify(signature); return verified; } catch (InvalidKeyException ex) { ex.printStackTrace(); } catch (NoSuchAlgorithmException ex) { ex.printStackTrace(); } catch (SignatureException ex) { ex.printStackTrace(); } return false; }