From 0bfc12c1e12983834f95252c5f9d09233c14fa8e Mon Sep 17 00:00:00 2001 From: Paul Schaub Date: Tue, 24 May 2022 21:18:47 +0200 Subject: [PATCH] Add withKeypassword() methods to Decrypt --- .../src/main/java/sop/operation/Decrypt.java | 29 +++++++++++++++---- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/sop-java/src/main/java/sop/operation/Decrypt.java b/sop-java/src/main/java/sop/operation/Decrypt.java index a300f3e..d892314 100644 --- a/sop-java/src/main/java/sop/operation/Decrypt.java +++ b/sop-java/src/main/java/sop/operation/Decrypt.java @@ -4,16 +4,17 @@ package sop.operation; -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.Date; - import sop.DecryptionResult; import sop.ReadyWithResult; import sop.SessionKey; import sop.exception.SOPGPException; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.nio.charset.Charset; +import java.util.Date; + public interface Decrypt { /** @@ -121,6 +122,24 @@ public interface Decrypt { return withKey(new ByteArrayInputStream(key)); } + /** + * Provide the decryption password for the secret key. + * + * @param password password + * @return builder instance + */ + default Decrypt withKeyPassword(String password) { + return withKeyPassword(password.getBytes(Charset.forName("UTF8"))); + } + + /** + * Provide the decryption password for the secret key. + * + * @param password password + * @return builder instance + */ + Decrypt withKeyPassword(byte[] password); + /** * Decrypts the given ciphertext, returning verification results and plaintext. * @param ciphertext ciphertext