SOP encrypt: Throw MissingArg if no encryption method was provided.

This commit is contained in:
Paul Schaub 2023-01-31 18:20:03 +01:00
parent 695e03f8b6
commit 83ef9cfe80
Signed by: vanitasvitae
GPG Key ID: 62BEE9264BF17311
1 changed files with 3 additions and 0 deletions

View File

@ -113,6 +113,9 @@ public class EncryptImpl implements Encrypt {
@Override
public Ready plaintext(InputStream plaintext) throws IOException {
if (!encryptionOptions.hasEncryptionMethod()) {
throw new SOPGPException.MissingArg("Missing encryption method.");
}
ProducerOptions producerOptions = signingOptions != null ?
ProducerOptions.signAndEncrypt(encryptionOptions, signingOptions) :
ProducerOptions.encrypt(encryptionOptions);