mirror of
https://github.com/pgpainless/pgpainless.git
synced 2025-09-09 18:29:39 +02:00
SOP encrypt --profile=rfc9580: Only override enc mechanism with seipd2 if exclusively symmetric encryption is used
This commit is contained in:
parent
24887e2521
commit
fd85f8e567
2 changed files with 6 additions and 1 deletions
|
@ -9,6 +9,7 @@ import org.bouncycastle.openpgp.PGPPublicKeyRing
|
||||||
import org.bouncycastle.openpgp.api.MessageEncryptionMechanism
|
import org.bouncycastle.openpgp.api.MessageEncryptionMechanism
|
||||||
import org.bouncycastle.openpgp.api.OpenPGPCertificate
|
import org.bouncycastle.openpgp.api.OpenPGPCertificate
|
||||||
import org.bouncycastle.openpgp.api.OpenPGPCertificate.OpenPGPComponentKey
|
import org.bouncycastle.openpgp.api.OpenPGPCertificate.OpenPGPComponentKey
|
||||||
|
import org.bouncycastle.openpgp.operator.PBEKeyEncryptionMethodGenerator
|
||||||
import org.bouncycastle.openpgp.operator.PGPKeyEncryptionMethodGenerator
|
import org.bouncycastle.openpgp.operator.PGPKeyEncryptionMethodGenerator
|
||||||
import org.pgpainless.PGPainless
|
import org.pgpainless.PGPainless
|
||||||
import org.pgpainless.algorithm.EncryptionPurpose
|
import org.pgpainless.algorithm.EncryptionPurpose
|
||||||
|
@ -427,6 +428,9 @@ class EncryptionOptions(private val purpose: EncryptionPurpose, private val api:
|
||||||
|
|
||||||
fun hasEncryptionMethod() = _encryptionMethods.isNotEmpty()
|
fun hasEncryptionMethod() = _encryptionMethods.isNotEmpty()
|
||||||
|
|
||||||
|
fun usesOnlyPasswordBasedEncryption() =
|
||||||
|
_encryptionMethods.all { it is PBEKeyEncryptionMethodGenerator }
|
||||||
|
|
||||||
internal fun negotiateEncryptionMechanism(): MessageEncryptionMechanism {
|
internal fun negotiateEncryptionMechanism(): MessageEncryptionMechanism {
|
||||||
if (encryptionMechanismOverride != null) {
|
if (encryptionMechanismOverride != null) {
|
||||||
return encryptionMechanismOverride!!
|
return encryptionMechanismOverride!!
|
||||||
|
|
|
@ -63,7 +63,8 @@ class EncryptImpl(private val api: PGPainless) : Encrypt {
|
||||||
throw SOPGPException.MissingArg("Missing encryption method.")
|
throw SOPGPException.MissingArg("Missing encryption method.")
|
||||||
}
|
}
|
||||||
|
|
||||||
if (profile == RFC9580_PROFILE.name) {
|
if (encryptionOptions.usesOnlyPasswordBasedEncryption() &&
|
||||||
|
profile == RFC9580_PROFILE.name) {
|
||||||
encryptionOptions.overrideEncryptionMechanism(
|
encryptionOptions.overrideEncryptionMechanism(
|
||||||
MessageEncryptionMechanism.aead(
|
MessageEncryptionMechanism.aead(
|
||||||
SymmetricKeyAlgorithm.AES_128.algorithmId, AEADAlgorithm.OCB.algorithmId))
|
SymmetricKeyAlgorithm.AES_128.algorithmId, AEADAlgorithm.OCB.algorithmId))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue