mirror of
https://github.com/pgpainless/pgpainless.git
synced 2025-09-10 18:59:39 +02:00
Prevent NULL encryption algorithm
This commit is contained in:
parent
620f35cdd1
commit
7062681d03
2 changed files with 6 additions and 4 deletions
|
@ -4,7 +4,6 @@
|
||||||
|
|
||||||
package org.pgpainless.algorithm.negotiation
|
package org.pgpainless.algorithm.negotiation
|
||||||
|
|
||||||
import java.lang.IllegalArgumentException
|
|
||||||
import org.pgpainless.algorithm.SymmetricKeyAlgorithm
|
import org.pgpainless.algorithm.SymmetricKeyAlgorithm
|
||||||
import org.pgpainless.policy.Policy
|
import org.pgpainless.policy.Policy
|
||||||
|
|
||||||
|
@ -36,9 +35,8 @@ interface SymmetricKeyAlgorithmNegotiator {
|
||||||
override: SymmetricKeyAlgorithm?,
|
override: SymmetricKeyAlgorithm?,
|
||||||
keyPreferences: List<Set<SymmetricKeyAlgorithm>>
|
keyPreferences: List<Set<SymmetricKeyAlgorithm>>
|
||||||
): SymmetricKeyAlgorithm {
|
): SymmetricKeyAlgorithm {
|
||||||
if (override == SymmetricKeyAlgorithm.NULL) {
|
require (override != SymmetricKeyAlgorithm.NULL) {
|
||||||
throw IllegalArgumentException(
|
"Algorithm override cannot be NULL (plaintext)."
|
||||||
"Algorithm override cannot be NULL (plaintext).")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (override != null) {
|
if (override != null) {
|
||||||
|
|
|
@ -405,6 +405,10 @@ class EncryptionOptions(private val purpose: EncryptionPurpose, private val api:
|
||||||
}
|
}
|
||||||
|
|
||||||
fun overrideEncryptionMechanism(encryptionMechanism: MessageEncryptionMechanism) = apply {
|
fun overrideEncryptionMechanism(encryptionMechanism: MessageEncryptionMechanism) = apply {
|
||||||
|
require(api.algorithmPolicy.symmetricKeyEncryptionAlgorithmPolicy.isAcceptable(
|
||||||
|
encryptionMechanism.symmetricKeyAlgorithm)) {
|
||||||
|
"Provided symmetric encryption algorithm is not acceptable."
|
||||||
|
}
|
||||||
_encryptionMechanismOverride = encryptionMechanism
|
_encryptionMechanismOverride = encryptionMechanism
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue