From 70eecace7e783651de8fdb3cb9b91dd290e67913 Mon Sep 17 00:00:00 2001 From: mbilel Date: Sun, 12 Jan 2020 17:23:09 +0100 Subject: [PATCH] Update BCPGPDecryptor.java throw exception when a file is not signed when it is expected to be signed --- src/main/java/com/test/pgp/bc/BCPGPDecryptor.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 +}