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

Prevent plaintext encryption

This commit is contained in:
Paul Schaub 2021-05-20 12:40:38 +02:00
parent 803e507ae7
commit d70ee86468
3 changed files with 18 additions and 5 deletions

View file

@ -124,6 +124,9 @@ public class EncryptionOptions {
} }
public void overrideEncryptionAlgorithm(SymmetricKeyAlgorithm encryptionAlgorithm) { public void overrideEncryptionAlgorithm(SymmetricKeyAlgorithm encryptionAlgorithm) {
if (encryptionAlgorithm == SymmetricKeyAlgorithm.NULL) {
throw new IllegalArgumentException("Plaintext encryption can only be used to denote unencrypted secret keys.");
}
this.encryptionAlgorithmOverride = encryptionAlgorithm; this.encryptionAlgorithmOverride = encryptionAlgorithm;
} }
} }

View file

@ -1,3 +1,18 @@
/*
* Copyright 2021 Paul Schaub.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.pgpainless.key; package org.pgpainless.key;
import java.util.List; import java.util.List;
@ -29,8 +44,4 @@ public interface EvaluatedKeyRing {
PGPSignature signature = getUserIdCertification(userId); PGPSignature signature = getUserIdCertification(userId);
return SignatureSubpacketsUtil.parseKeyFlags(signature); return SignatureSubpacketsUtil.parseKeyFlags(signature);
} }
} }

View file

@ -21,7 +21,6 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
import java.security.InvalidAlgorithmParameterException; import java.security.InvalidAlgorithmParameterException;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
import java.util.Collections;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;