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) {
if (encryptionAlgorithm == SymmetricKeyAlgorithm.NULL) {
throw new IllegalArgumentException("Plaintext encryption can only be used to denote unencrypted secret keys.");
}
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;
import java.util.List;
@ -29,8 +44,4 @@ public interface EvaluatedKeyRing {
PGPSignature signature = getUserIdCertification(userId);
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.NoSuchAlgorithmException;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;