sop decrypt: Throw NoSignature if no verifiable signature found

This commit is contained in:
Paul Schaub 2023-01-13 17:40:51 +01:00
parent 14c665565e
commit ff5f98e8ee

View file

@ -101,6 +101,7 @@ public class DecryptCmd extends AbstractSopCmd {
DecryptionResult result = ready.writeTo(System.out); DecryptionResult result = ready.writeTo(System.out);
writeSessionKeyOut(result); writeSessionKeyOut(result);
writeVerifyOut(result); writeVerifyOut(result);
} catch (SOPGPException.BadData badData) { } catch (SOPGPException.BadData badData) {
String errorMsg = getMsg("sop.error.input.stdin_not_a_message"); String errorMsg = getMsg("sop.error.input.stdin_not_a_message");
throw new SOPGPException.BadData(errorMsg, badData); throw new SOPGPException.BadData(errorMsg, badData);
@ -114,6 +115,11 @@ public class DecryptCmd extends AbstractSopCmd {
private void writeVerifyOut(DecryptionResult result) throws IOException { private void writeVerifyOut(DecryptionResult result) throws IOException {
if (verifyOut != null) { if (verifyOut != null) {
if (result.getVerifications().isEmpty()) {
String errorMsg = getMsg("sop.error.runtime.no_verifiable_signature_found");
throw new SOPGPException.NoSignature(errorMsg);
}
try (OutputStream fileOut = getOutput(verifyOut)) { try (OutputStream fileOut = getOutput(verifyOut)) {
PrintWriter writer = new PrintWriter(fileOut); PrintWriter writer = new PrintWriter(fileOut);
for (Verification verification : result.getVerifications()) { for (Verification verification : result.getVerifications()) {