// Read the detached signature
//**********************************************************************
PGPDetachedSignatureMessage detachedSig = null;
try {
MessageFactory mf = MessageFactory.getInstance("OpenPGP");
//System.out.println(signed);
byte[] bm = PGPArmoury.unarmour(signed);
detachedSig = (PGPDetachedSignatureMessage)
mf.generateMessages(new ByteArrayInputStream(bm)).iterator().next();
} catch (NoSuchAlgorithmException nsae) {
System.err.println("Cannot find the OpenPGP MessageFactory. "+
"This usually means that the Cryptix OpenPGP provider is not "+
"installed correctly.");
nsae.printStackTrace();
return;
} catch (MessageException me) {
System.err.println("Reading the message failed.");
me.printStackTrace();
return;
} catch (IOException ioe) {
System.err.println("Reading the message failed.");
ioe.printStackTrace();
return;
}
//**********************************************************************
// Verify the message.
//**********************************************************************
try {
if (detachedSig.verify(originalMsg, bundle)) {
System.out.println("Signature OK");
} else {
System.out.println("Signature BAD");
}