1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2024-11-22 12:22:06 +01:00

Deprecate addPassphrase()/addDecryptionPassphrase in favor of addMessagePassphrase()

This commit is contained in:
Paul Schaub 2024-08-22 13:41:51 +02:00
parent 6f46f75602
commit 69a57ef3bc
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311
2 changed files with 28 additions and 2 deletions

View file

@ -196,7 +196,22 @@ class ConsumerOptions {
* @param passphrase passphrase * @param passphrase passphrase
* @return options * @return options
*/ */
fun addDecryptionPassphrase(passphrase: Passphrase) = apply { @Deprecated(
"Deprecated in favor of addMessagePassphrase",
ReplaceWith("addMessagePassphrase(passphrase)"))
fun addDecryptionPassphrase(passphrase: Passphrase) = addMessagePassphrase(passphrase)
/**
* Add a passphrase for message decryption. This passphrase will be used to try to decrypt
* messages which were symmetrically encrypted for a passphrase.
*
* See
* [Symmetrically Encrypted Data Packet](https://datatracker.ietf.org/doc/html/rfc4880#section-5.7)
*
* @param passphrase passphrase
* @return options
*/
fun addMessagePassphrase(passphrase: Passphrase) = apply {
decryptionPassphrases.add(passphrase) decryptionPassphrases.add(passphrase)
} }

View file

@ -227,7 +227,18 @@ class EncryptionOptions(private val purpose: EncryptionPurpose) {
* @param passphrase passphrase * @param passphrase passphrase
* @return this * @return this
*/ */
fun addPassphrase(passphrase: Passphrase) = apply { @Deprecated(
"Deprecated in favor of addMessagePassphrase",
ReplaceWith("addMessagePassphrase(passphrase)"))
fun addPassphrase(passphrase: Passphrase) = addMessagePassphrase(passphrase)
/**
* Add a symmetric passphrase which the message will be encrypted to.
*
* @param passphrase passphrase
* @return this
*/
fun addMessagePassphrase(passphrase: Passphrase) = apply {
require(!passphrase.isEmpty) { "Passphrase MUST NOT be empty." } require(!passphrase.isEmpty) { "Passphrase MUST NOT be empty." }
addEncryptionMethod( addEncryptionMethod(
ImplementationFactory.getInstance().getPBEKeyEncryptionMethodGenerator(passphrase)) ImplementationFactory.getInstance().getPBEKeyEncryptionMethodGenerator(passphrase))