mirror of
https://github.com/pgpainless/pgpainless.git
synced 2025-09-14 12:49:39 +02:00
SOP: Add convenience methods to deal with byte arrays
This commit is contained in:
parent
32f3f0246e
commit
15736586dd
25 changed files with 451 additions and 128 deletions
|
@ -4,6 +4,7 @@
|
|||
|
||||
package sop.operation;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Date;
|
||||
|
@ -43,6 +44,17 @@ public interface Decrypt {
|
|||
throws SOPGPException.BadData,
|
||||
IOException;
|
||||
|
||||
/**
|
||||
* Adds the verification cert.
|
||||
*
|
||||
* @param cert byte array containing the cert
|
||||
* @return builder instance
|
||||
*/
|
||||
default Decrypt verifyWithCert(byte[] cert)
|
||||
throws SOPGPException.BadData, IOException {
|
||||
return verifyWithCert(new ByteArrayInputStream(cert));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to decrypt with the given session key.
|
||||
*
|
||||
|
@ -73,6 +85,19 @@ public interface Decrypt {
|
|||
SOPGPException.BadData,
|
||||
SOPGPException.UnsupportedAsymmetricAlgo;
|
||||
|
||||
/**
|
||||
* Adds the decryption key.
|
||||
*
|
||||
* @param key byte array containing the key
|
||||
* @return builder instance
|
||||
*/
|
||||
default Decrypt withKey(byte[] key)
|
||||
throws SOPGPException.KeyIsProtected,
|
||||
SOPGPException.BadData,
|
||||
SOPGPException.UnsupportedAsymmetricAlgo {
|
||||
return withKey(new ByteArrayInputStream(key));
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrypts the given ciphertext, returning verification results and plaintext.
|
||||
* @param ciphertext ciphertext
|
||||
|
@ -80,4 +105,14 @@ public interface Decrypt {
|
|||
*/
|
||||
ReadyWithResult<DecryptionResult> ciphertext(InputStream ciphertext)
|
||||
throws SOPGPException.BadData, SOPGPException.MissingArg, SOPGPException.CannotDecrypt;
|
||||
|
||||
/**
|
||||
* Decrypts the given ciphertext, returning verification results and plaintext.
|
||||
* @param ciphertext ciphertext
|
||||
* @return ready with result
|
||||
*/
|
||||
default ReadyWithResult<DecryptionResult> ciphertext(byte[] ciphertext)
|
||||
throws SOPGPException.BadData, SOPGPException.MissingArg, SOPGPException.CannotDecrypt {
|
||||
return ciphertext(new ByteArrayInputStream(ciphertext));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue