diff --git a/src/main/java/com/test/pgp/bc/BCPGPDecryptor.java b/src/main/java/com/test/pgp/bc/BCPGPDecryptor.java index 3e5944c..d32f456 100644 --- a/src/main/java/com/test/pgp/bc/BCPGPDecryptor.java +++ b/src/main/java/com/test/pgp/bc/BCPGPDecryptor.java @@ -153,6 +153,9 @@ public InputStream decryptFile(InputStream in) throws Exception { bytes = IOUtils.toByteArray(is); if (isSigned) { + if(ops == null){ + throw new PGPException("Unsigned file, it's expected to be signed!"); + } ops.update(bytes); PGPSignatureList p3 = (PGPSignatureList) pgpFact.nextObject(); if (!ops.verify(p3.get(0))) { @@ -165,4 +168,4 @@ public InputStream decryptFile(InputStream in) throws Exception { return new ByteArrayInputStream(bytes); } -} \ No newline at end of file +}